From: Jeff M. <cus...@us...> - 2002-06-19 15:26:29
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/alt/java/net In directory usw-pr-cvs1:/tmp/cvs-serv12913/src/jdk/common/alt/java/net Added Files: Socket.java SocketFactory.java SocketFactoryImpl.java SocketImpl.java Log Message: Lots of small changes to mocks --- NEW FILE: Socket.java --- package alt.java.net; import java.net.InetAddress; import java.net.SocketException; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; public interface Socket { InetAddress getInetAddress(); InetAddress getLocalAddress(); int getPort(); int getLocalPort(); InputStream getInputStream() throws IOException; OutputStream getOutputStream() throws IOException; void setTcpNoDelay(boolean on) throws SocketException; boolean getTcpNoDelay() throws SocketException; void setSoLinger(boolean on, int linger) throws SocketException; int getSoLinger() throws SocketException; void setSoTimeout(int timeout) throws SocketException; int getSoTimeout() throws SocketException; void setSendBufferSize(int size) throws SocketException; int getSendBufferSize() throws SocketException; void setReceiveBufferSize(int size) throws SocketException; int getReceiveBufferSize() throws SocketException; void setKeepAlive(boolean on) throws SocketException; boolean getKeepAlive() throws SocketException; void close() throws IOException; void shutdownInput() throws IOException; void shutdownOutput() throws IOException; } --- NEW FILE: SocketFactory.java --- package alt.java.net; import java.net.UnknownHostException; import java.io.IOException; public interface SocketFactory { Socket createSocket(String aHost, int aPort) throws UnknownHostException, IOException; } --- NEW FILE: SocketFactoryImpl.java --- package alt.java.net; import java.net.UnknownHostException; import java.io.IOException; public class SocketFactoryImpl implements SocketFactory { public Socket createSocket(String host, int port) throws UnknownHostException, IOException { return new SocketImpl(new java.net.Socket(host, port)); } } --- NEW FILE: SocketImpl.java --- package alt.java.net; import java.net.InetAddress; import java.net.SocketException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class SocketImpl implements Socket { private final java.net.Socket socket; public SocketImpl(java.net.Socket socket) { this.socket = socket; } public InetAddress getInetAddress() { return socket.getInetAddress(); } public InetAddress getLocalAddress() { return socket.getLocalAddress(); } public int getPort() { return socket.getPort(); } public int getLocalPort() { return socket.getLocalPort(); } public InputStream getInputStream() throws IOException { return socket.getInputStream(); } public OutputStream getOutputStream() throws IOException { return socket.getOutputStream(); } public void setTcpNoDelay(boolean on) throws SocketException { socket.setTcpNoDelay(on); } public boolean getTcpNoDelay() throws SocketException { return socket.getTcpNoDelay(); } public void setSoLinger(boolean on, int linger) throws SocketException { socket.setSoLinger(on, linger); } public int getSoLinger() throws SocketException { return socket.getSoLinger(); } public synchronized void setSoTimeout(int timeout) throws SocketException { socket.setSoTimeout(timeout); } public synchronized int getSoTimeout() throws SocketException { return socket.getSoTimeout(); } public synchronized void setSendBufferSize(int size) throws SocketException { socket.setSendBufferSize(size); } public synchronized int getSendBufferSize() throws SocketException { return socket.getSendBufferSize(); } public synchronized void setReceiveBufferSize(int size) throws SocketException { socket.setReceiveBufferSize(size); } public synchronized int getReceiveBufferSize() throws SocketException { return socket.getReceiveBufferSize(); } public void setKeepAlive(boolean on) throws SocketException { socket.setKeepAlive(on); } public boolean getKeepAlive() throws SocketException { return socket.getKeepAlive(); } public synchronized void close() throws IOException { socket.close(); } public void shutdownInput() throws IOException { socket.shutdownInput(); } public void shutdownOutput() throws IOException { socket.shutdownOutput(); } } |