@Test public void testWrite_Empty() throws Exception { System.out.println("write"); SocketChannelWithTimeoutsEmul instance = new SocketChannelWithTimeoutsEmul(); SocketChannelEmul sc = (SocketChannelEmul) instance.socketChannel; assertEquals(4, instance.write(ByteBuffer.wrap("test".getBytes()))); Assert.assertEquals(4, sc.getWrittenBytesCount()); assertEquals(0, instance.write(ByteBuffer.wrap("".getBytes()))); Assert.assertEquals(0, sc.getWrittenBytesCount()); }
@Override public int write(ByteBuffer src) throws IOException { fastFirstPacketRead = false; int res = 0; int size = src.remaining(); while (res < size) { res += socketChannel.write(src); } return res; }
SocketChannelWithTimeouts extends SocketChannel { @Override public int write(ByteBuffer src) throws IOException { fastFirstPacketRead = false; int res = 0; int size = src.remaining(); while (res < size) { res += socketChannel.write(src); } return res; } }
SocketChannelWithTimeouts extends SocketChannel { @Override public int write(ByteBuffer src) throws IOException { fastFirstPacketRead = false; int res = 0; int size = src.remaining(); while (res < size) { res += socketChannel.write(src); } return res; } protected  SocketChannelWithTimeouts(); }
SocketChannelWithTimeouts extends SocketChannel { @Override public int write(ByteBuffer src) throws IOException { fastFirstPacketRead = false; int res = 0; int size = src.remaining(); while (res < size) { res += socketChannel.write(src); } return res; } protected  SocketChannelWithTimeouts(); static SocketChannel open(); @Override SocketChannel bind(SocketAddress socketAddress); @Override SocketAddress getLocalAddress(); @Override SocketChannel setOption(SocketOption<T> socketOption, T t); @Override T getOption(SocketOption<T> socketOption); @Override Set<SocketOption<?>> supportedOptions(); @Override SocketChannel shutdownInput(); @Override SocketChannel shutdownOutput(); @Override boolean connect(SocketAddress remote); @Override int read(ByteBuffer dst); @Override long read(ByteBuffer[] dsts, int offset, int length); @Override int write(ByteBuffer src); @Override long write(ByteBuffer[] srcs, int offset, int length); @Override Socket socket(); @Override boolean isConnected(); @Override boolean isConnectionPending(); @Override boolean finishConnect(); void setConnectTimeout(int t); void setReadTimeout(int t); SocketAddress getRemoteAddress(); }
SocketChannelWithTimeouts extends SocketChannel { @Override public int write(ByteBuffer src) throws IOException { fastFirstPacketRead = false; int res = 0; int size = src.remaining(); while (res < size) { res += socketChannel.write(src); } return res; } protected  SocketChannelWithTimeouts(); static SocketChannel open(); @Override SocketChannel bind(SocketAddress socketAddress); @Override SocketAddress getLocalAddress(); @Override SocketChannel setOption(SocketOption<T> socketOption, T t); @Override T getOption(SocketOption<T> socketOption); @Override Set<SocketOption<?>> supportedOptions(); @Override SocketChannel shutdownInput(); @Override SocketChannel shutdownOutput(); @Override boolean connect(SocketAddress remote); @Override int read(ByteBuffer dst); @Override long read(ByteBuffer[] dsts, int offset, int length); @Override int write(ByteBuffer src); @Override long write(ByteBuffer[] srcs, int offset, int length); @Override Socket socket(); @Override boolean isConnected(); @Override boolean isConnectionPending(); @Override boolean finishConnect(); void setConnectTimeout(int t); void setReadTimeout(int t); SocketAddress getRemoteAddress();  }