// 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 SocketData data(byte[] data)
// {
// 	return new DefaultSocketData(data);
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static SocketData emptyResponse()
// {
// 	return new DefaultSocketData(new byte[0]);
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static UniversalMockRecorder expectCall() {
// 	return StaticConnectionFactory.expectCall();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static List<RequestSocketData> recordedConnections()
// {
// 	return StaticConnectionFactory.getRequestRecorder().requestData();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static void reset()
// {
// 	StaticConnectionFactory.reset();
// }


import org.junit.After;
import org.junit.Test;
import static net.javacrumbs.mocksocket.MockSocket.address;
import static net.javacrumbs.mocksocket.MockSocket.data;
import static net.javacrumbs.mocksocket.MockSocket.emptyResponse;
import static net.javacrumbs.mocksocket.MockSocket.expectCall;
import static net.javacrumbs.mocksocket.MockSocket.recordedConnections;
import static net.javacrumbs.mocksocket.MockSocket.reset;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.net.Socket;
import javax.net.SocketFactory;
import org.apache.commons.io.IOUtils;
		expectCall().andReturn(data(mockData1)).andReturn(data(mockData2));
		
		Socket socket1 = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data1 = IOUtils.toByteArray(socket1.getInputStream());
		socket1.close();
		assertThat(data1, is(mockData1));

		Socket socket2 = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data2 = IOUtils.toByteArray(socket2.getInputStream());
		socket2.close();
		assertThat(data2, is(mockData2));
	}
	
	@Test
	public void testConditionalAddress() throws Exception
	{
		byte[] mockData = new byte[]{1,2,3,4};
		expectCall().andWhenRequest(address(is("example.org:1234"))).thenReturn(data(mockData));
		
		Socket socket = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data = IOUtils.toByteArray(socket.getInputStream());
		socket.close();
		assertThat(data, is(mockData));
	}
	
	@Test
	public void testConditionalData() throws Exception
	{
		byte[] dataToWrite = new byte[]{5,4,3,2};
		byte[] mockData = new byte[]{1,2,3,4};
// 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 SocketData data(byte[] data)
// {
// 	return new DefaultSocketData(data);
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static SocketData emptyResponse()
// {
// 	return new DefaultSocketData(new byte[0]);
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static UniversalMockRecorder expectCall() {
// 	return StaticConnectionFactory.expectCall();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static List<RequestSocketData> recordedConnections()
// {
// 	return StaticConnectionFactory.getRequestRecorder().requestData();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocket.java
// public static void reset()
// {
// 	StaticConnectionFactory.reset();
// }


// Path: core/src/test/java/net/javacrumbs/mocksocket/SampleTest.java
import org.junit.After;
import org.junit.Test;
import static net.javacrumbs.mocksocket.MockSocket.address;
import static net.javacrumbs.mocksocket.MockSocket.data;
import static net.javacrumbs.mocksocket.MockSocket.emptyResponse;
import static net.javacrumbs.mocksocket.MockSocket.expectCall;
import static net.javacrumbs.mocksocket.MockSocket.recordedConnections;
import static net.javacrumbs.mocksocket.MockSocket.reset;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.net.Socket;
import javax.net.SocketFactory;
import org.apache.commons.io.IOUtils;

		expectCall().andReturn(data(mockData1)).andReturn(data(mockData2));
		
		Socket socket1 = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data1 = IOUtils.toByteArray(socket1.getInputStream());
		socket1.close();
		assertThat(data1, is(mockData1));

		Socket socket2 = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data2 = IOUtils.toByteArray(socket2.getInputStream());
		socket2.close();
		assertThat(data2, is(mockData2));
	}
	
	@Test
	public void testConditionalAddress() throws Exception
	{
		byte[] mockData = new byte[]{1,2,3,4};
		expectCall().andWhenRequest(address(is("example.org:1234"))).thenReturn(data(mockData));
		
		Socket socket = SocketFactory.getDefault().createSocket("example.org", 1234);
		byte[] data = IOUtils.toByteArray(socket.getInputStream());
		socket.close();
		assertThat(data, is(mockData));
	}
	
	@Test
	public void testConditionalData() throws Exception
	{
		byte[] dataToWrite = new byte[]{5,4,3,2};
		byte[] mockData = new byte[]{1,2,3,4};
		expectCall().andWhenRequest(data(is(dataToWrite))).thenReturn(data(mockData));