Package org.jgroups.nio
Class MockSocketChannel
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.SelectableChannel
-
- java.nio.channels.spi.AbstractSelectableChannel
-
- java.nio.channels.SocketChannel
-
- org.jgroups.nio.MockSocketChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.ByteChannel,java.nio.channels.Channel,java.nio.channels.GatheringByteChannel,java.nio.channels.InterruptibleChannel,java.nio.channels.NetworkChannel,java.nio.channels.ReadableByteChannel,java.nio.channels.ScatteringByteChannel,java.nio.channels.WritableByteChannel
public class MockSocketChannel extends java.nio.channels.SocketChannelA mockSocketChannelfor testing- Since:
- 3.6.5
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.ByteBufferbytes_to_readprotected intbytes_to_writeprotected booleanclosedprotected java.nio.ByteBufferrecorder
-
Constructor Summary
Constructors Constructor Description MockSocketChannel()MockSocketChannel(java.nio.channels.spi.SelectorProvider provider)Initializes a new instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.channels.SocketChannelbind(java.net.SocketAddress local)java.nio.ByteBufferbytesToRead()MockSocketChannelbytesToRead(byte[] buf)MockSocketChannelbytesToRead(java.nio.ByteBuffer buf)MockSocketChannelbytesToWrite(int num)booleanconnect(java.net.SocketAddress remote)voiddoClose()booleanfinishConnect()java.net.SocketAddressgetLocalAddress()<T> TgetOption(java.net.SocketOption<T> name)java.net.SocketAddressgetRemoteAddress()protected voidimplCloseSelectableChannel()protected voidimplConfigureBlocking(boolean block)booleanisConnected()booleanisConnectionPending()intread(java.nio.ByteBuffer dst)longread(java.nio.ByteBuffer[] dsts, int offset, int length)java.nio.ByteBufferrecorder()MockSocketChannelrecorder(java.nio.ByteBuffer buf)<T> java.nio.channels.SocketChannelsetOption(java.net.SocketOption<T> name, T value)java.nio.channels.SocketChannelshutdownInput()java.nio.channels.SocketChannelshutdownOutput()java.net.Socketsocket()java.util.Set<java.net.SocketOption<?>>supportedOptions()intwrite(java.nio.ByteBuffer buf)longwrite(java.nio.ByteBuffer[] srcs, int offset, int length)-
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Method Detail
-
bytesToWrite
public MockSocketChannel bytesToWrite(int num)
-
bytesToRead
public MockSocketChannel bytesToRead(byte[] buf)
-
bytesToRead
public MockSocketChannel bytesToRead(java.nio.ByteBuffer buf)
-
bytesToRead
public java.nio.ByteBuffer bytesToRead()
-
recorder
public MockSocketChannel recorder(java.nio.ByteBuffer buf)
-
recorder
public java.nio.ByteBuffer recorder()
-
bind
public java.nio.channels.SocketChannel bind(java.net.SocketAddress local) throws java.io.IOException- Specified by:
bindin interfacejava.nio.channels.NetworkChannel- Specified by:
bindin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
doClose
public void doClose()
-
setOption
public <T> java.nio.channels.SocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException- Specified by:
setOptionin interfacejava.nio.channels.NetworkChannel- Specified by:
setOptionin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
getOption
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException- Throws:
java.io.IOException
-
supportedOptions
public java.util.Set<java.net.SocketOption<?>> supportedOptions()
-
shutdownInput
public java.nio.channels.SocketChannel shutdownInput() throws java.io.IOException- Specified by:
shutdownInputin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
shutdownOutput
public java.nio.channels.SocketChannel shutdownOutput() throws java.io.IOException- Specified by:
shutdownOutputin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
socket
public java.net.Socket socket()
- Specified by:
socketin classjava.nio.channels.SocketChannel
-
isConnected
public boolean isConnected()
- Specified by:
isConnectedin classjava.nio.channels.SocketChannel
-
isConnectionPending
public boolean isConnectionPending()
- Specified by:
isConnectionPendingin classjava.nio.channels.SocketChannel
-
connect
public boolean connect(java.net.SocketAddress remote) throws java.io.IOException- Specified by:
connectin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
finishConnect
public boolean finishConnect() throws java.io.IOException- Specified by:
finishConnectin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress() throws java.io.IOException- Specified by:
getRemoteAddressin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Specified by:
readin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
read
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ScatteringByteChannel- Specified by:
readin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer buf) throws java.io.IOException- Specified by:
writein interfacejava.nio.channels.WritableByteChannel- Specified by:
writein classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException- Specified by:
writein interfacejava.nio.channels.GatheringByteChannel- Specified by:
writein classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
getLocalAddress
public java.net.SocketAddress getLocalAddress() throws java.io.IOException- Specified by:
getLocalAddressin interfacejava.nio.channels.NetworkChannel- Specified by:
getLocalAddressin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
implCloseSelectableChannel
protected void implCloseSelectableChannel() throws java.io.IOException- Specified by:
implCloseSelectableChannelin classjava.nio.channels.spi.AbstractSelectableChannel- Throws:
java.io.IOException
-
implConfigureBlocking
protected void implConfigureBlocking(boolean block) throws java.io.IOException- Specified by:
implConfigureBlockingin classjava.nio.channels.spi.AbstractSelectableChannel- Throws:
java.io.IOException
-
-