From: Jeff M. <cus...@us...> - 2002-06-19 15:26:29
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/net In directory usw-pr-cvs1:/tmp/cvs-serv12913/src/jdk/common/com/mockobjects/net Added Files: MockSocket.java MockSocketFactory.java Log Message: Lots of small changes to mocks --- NEW FILE: MockSocket.java --- package com.mockobjects.net; import alt.java.net.Socket; import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationValue; import com.mockobjects.MockObject; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.SocketException; public class MockSocket extends MockObject implements Socket { private final ExpectationValue mySoTimeout = new ExpectationValue("so timeout"); private InputStream myInputStream; private OutputStream myOutputStream; private final ExpectationCounter myCloseCalls = new ExpectationCounter("close calls"); public InetAddress getInetAddress() { notImplemented(); return null; } public InetAddress getLocalAddress() { notImplemented(); return null; } public int getPort() { notImplemented(); return 0; } public int getLocalPort() { notImplemented(); return 0; } public void setupGetInputStream(InputStream anInputStream) { myInputStream = anInputStream; } public InputStream getInputStream() throws IOException { return myInputStream; } public void setupGetOutputStream(OutputStream anOutputStream) { myOutputStream = anOutputStream; } public OutputStream getOutputStream() throws IOException { return myOutputStream; } public void setTcpNoDelay(boolean on) throws SocketException { notImplemented(); } public boolean getTcpNoDelay() throws SocketException { notImplemented(); return false; } public void setSoLinger(boolean on, int linger) throws SocketException { notImplemented(); } public int getSoLinger() throws SocketException { notImplemented(); return 0; } public void setExpectedSoTimeout(int aSoTimeout) { mySoTimeout.setExpected(aSoTimeout); } public void setSoTimeout(int aSoTimeout) throws SocketException { mySoTimeout.setActual(aSoTimeout); } public int getSoTimeout() throws SocketException { notImplemented(); return 0; } public void setSendBufferSize(int size) throws SocketException { notImplemented(); } public int getSendBufferSize() throws SocketException { notImplemented(); return 0; } public void setReceiveBufferSize(int size) throws SocketException { notImplemented(); } public int getReceiveBufferSize() throws SocketException { notImplemented(); return 0; } public void setKeepAlive(boolean on) throws SocketException { notImplemented(); } public boolean getKeepAlive() throws SocketException { notImplemented(); return false; } public void setExpectedCloseCalls(int aCount) { myCloseCalls.setExpected(aCount); } public void close() throws IOException { myCloseCalls.inc(); } public void shutdownInput() throws IOException { notImplemented(); } public void shutdownOutput() throws IOException { notImplemented(); } } --- NEW FILE: MockSocketFactory.java --- package com.mockobjects.net; import alt.java.net.SocketFactory; import alt.java.net.Socket; import com.mockobjects.MockObject; import com.mockobjects.ExpectationValue; public class MockSocketFactory extends MockObject implements SocketFactory{ private final ExpectationValue myHost = new ExpectationValue("host"); private final ExpectationValue myPort = new ExpectationValue("port"); private Socket mySocket; public void setupCreateSocket(Socket aSocket){ mySocket = aSocket; } public void setExpectedHost(String aHost){ myHost.setExpected(aHost); } public void setExpectedPort(String aPort){ myPort.setExpected(aPort); } public Socket createSocket(String aHost, int aPort) { myHost.setActual(aHost); myPort.setActual(aPort); return mySocket; } } |