// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static Matcher<RequestSocketData> address(Matcher<String> addressMatcher)
// {
// 	return new CombinableMatcher<RequestSocketData>(new AddressMatcher(addressMatcher));
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static List<RequestSocketData> recordedConnections()
// {
// 	return StaticConnectionFactory.getRequestRecorder().requestData();
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> header(String header, Matcher<String> headerMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new HeaderMatcher(header, headerMatcher));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> method(Matcher<String> methodMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new MethodMatcher(methodMatcher));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static HttpRequest request(int index)
// {
// 	return new HttpParser(recordedConnections().get(index));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static HttpResponseGenerator response()
// {
// 	return new HttpResponseGenerator();
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> uri(Matcher<String> uriMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new UriMatcher(uriMatcher));
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocketException.java
// public class MockSocketException extends RuntimeException {
// 	private static final long serialVersionUID = -6476984055059688027L;
// 
// 	public MockSocketException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public MockSocketException(String message) {
// 		super(message);
// 	}
// 
// 	public MockSocketException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 
// }


import static net.javacrumbs.mocksocket.MockSocket.address;
import static net.javacrumbs.mocksocket.MockSocket.recordedConnections;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.expectCall;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.header;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.method;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.request;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.response;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.uri;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.javacrumbs.mocksocket.MockSocketException;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.After;
import org.junit.Test;
			.andWhenRequest(uri(is("/test/other.do"))).thenReturn(response().withContent("Text")).thenReturn(response().withContent("Text"));
		
		HttpClient httpclient = new DefaultHttpClient();
		
		doGet(httpclient);
		doGet(httpclient);

		HttpPost httppost = new HttpPost(ADDRESS+"test/something.do");
		HttpResponse postResponse = httpclient.execute(httppost);
		assertThat(postResponse.getStatusLine().getStatusCode(), is(404));
		httppost.abort();
	}

	private void doGet(HttpClient httpclient) throws IOException, ClientProtocolException {
		HttpGet httpget = new HttpGet(ADDRESS+"test/other.do");
		httpget.addHeader("Accept","text/plain");
		HttpResponse getResponse = httpclient.execute(httpget);
		assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
		
		assertThat(recordedConnections(), hasItem(header("Accept", is("text/plain"))));
		assertThat(recordedConnections().get(0), method(is("GET")));
		assertThat(request(0).getMethod(), is("GET"));
		assertThat(request(0).getAddress(), is("localhost:80"));
						
		ByteArrayOutputStream outstream = new ByteArrayOutputStream();
		getResponse.getEntity().writeTo(outstream);
		assertThat(new String(outstream.toByteArray()), is("Text"));
		httpget.abort();
	}
	
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static Matcher<RequestSocketData> address(Matcher<String> addressMatcher)
// {
// 	return new CombinableMatcher<RequestSocketData>(new AddressMatcher(addressMatcher));
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static List<RequestSocketData> recordedConnections()
// {
// 	return StaticConnectionFactory.getRequestRecorder().requestData();
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> header(String header, Matcher<String> headerMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new HeaderMatcher(header, headerMatcher));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> method(Matcher<String> methodMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new MethodMatcher(methodMatcher));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static HttpRequest request(int index)
// {
// 	return new HttpParser(recordedConnections().get(index));
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static HttpResponseGenerator response()
// {
// 	return new HttpResponseGenerator();
// }
// 
// Path: http/src/main/java/net/javacrumbs/mocksocket/http/HttpMockSocket.java
// public static CombinableMatcher<RequestSocketData> uri(Matcher<String> uriMatcher) {
// 	return new CombinableMatcher<RequestSocketData>(new UriMatcher(uriMatcher));
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocketException.java
// public class MockSocketException extends RuntimeException {
// 	private static final long serialVersionUID = -6476984055059688027L;
// 
// 	public MockSocketException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public MockSocketException(String message) {
// 		super(message);
// 	}
// 
// 	public MockSocketException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 
// }


// Path: http/src/test/java/net/javacrumbs/mocksocket/http/SampleTest.java
import static net.javacrumbs.mocksocket.MockSocket.address;
import static net.javacrumbs.mocksocket.MockSocket.recordedConnections;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.expectCall;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.header;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.method;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.request;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.response;
import static net.javacrumbs.mocksocket.http.HttpMockSocket.uri;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.javacrumbs.mocksocket.MockSocketException;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.After;
import org.junit.Test;

			.andWhenRequest(uri(is("/test/other.do"))).thenReturn(response().withContent("Text")).thenReturn(response().withContent("Text"));
		
		HttpClient httpclient = new DefaultHttpClient();
		
		doGet(httpclient);
		doGet(httpclient);

		HttpPost httppost = new HttpPost(ADDRESS+"test/something.do");
		HttpResponse postResponse = httpclient.execute(httppost);
		assertThat(postResponse.getStatusLine().getStatusCode(), is(404));
		httppost.abort();
	}

	private void doGet(HttpClient httpclient) throws IOException, ClientProtocolException {
		HttpGet httpget = new HttpGet(ADDRESS+"test/other.do");
		httpget.addHeader("Accept","text/plain");
		HttpResponse getResponse = httpclient.execute(httpget);
		assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
		
		assertThat(recordedConnections(), hasItem(header("Accept", is("text/plain"))));
		assertThat(recordedConnections().get(0), method(is("GET")));
		assertThat(request(0).getMethod(), is("GET"));
		assertThat(request(0).getAddress(), is("localhost:80"));
						
		ByteArrayOutputStream outstream = new ByteArrayOutputStream();
		getResponse.getEntity().writeTo(outstream);
		assertThat(new String(outstream.toByteArray()), is("Text"));
		httpget.abort();
	}
	
	@Test(expected=MockSocketException.class)