package org.bench4q.master.unitTest;

import java.io.IOException;

import org.bench4q.share.communication.HttpRequester;
import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.TestPlanModel;
import org.junit.Test;

public class HttpRequestTest {
	private HttpRequester httpRequester;

	public HttpRequester getHttpRequester() {
		return httpRequester;
	}

	public void setHttpRequester(HttpRequester httpRequester) {
		this.httpRequester = httpRequester;
	}

	public HttpRequestTest() {
		this.setHttpRequester(new HttpRequester());
	}

	@Test
	public void testForError() {
		try {
			HttpResponse httpResponse = this
					.getHttpRequester()
					.sendPostXml(
							"http://127.0.0.1:7979/testPlan/runTestPlanWithTestPlanModel",
							MarshalHelper.marshal(TestPlanModel.class,
									new TestPlanModel()), null);

			System.out.println(httpResponse.getCode());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void testForRight() {
		try {
			HttpResponse httpResponse = this.getHttpRequester().sendGet(
					"127.0.0.1:7979/", null, null);
			System.out.println(httpResponse.getCode());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
