package org.bench4q.master.unitTest.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.JAXBException;

import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.junit.Before;

public class RecordPortControllerTest extends TestBase {
	private final String URLSTRING = BASE_URL + "/RecordPort";
	private final String PORT = "1100";
	private final String PARAM1 = "port";

	@Before
	public void prepare() {
		this.setAccessTocken(this.login());
	}

	public void AddPortToPool() throws IOException, JAXBException {
		String accesTocken = this.login();
		Map<String, String> params = new HashMap<String, String>();
		params.put(PARAM1, PORT);
		String urlString = URLSTRING + "/addPortToPortPool";

		HttpResponse httpResponse = this.httpRequester.sendPost(urlString,
				params, this.makeAccessTockenMap(accesTocken));

		System.out.println(httpResponse.getContent());
	}

	public void RemovePortFromPool() throws IOException, JAXBException {
		String accesTocken = this.login();
		Map<String, String> params = new HashMap<String, String>();
		params.put("portId", 3 + "");
		String urlString = URLSTRING + "/removePortFromPool";
		HttpResponse httpResponse = this.httpRequester.sendPost(urlString,
				params, this.makeAccessTockenMap(accesTocken));
		System.out.println(httpResponse.getContent());
	}

	public static void main(String[] args) throws Throwable {
		RecordPortControllerTest test = new RecordPortControllerTest();
		test.AddPortToPool();
		test.RemovePortFromPool();
	}
}
