public class MockSocketChannel
extends java.nio.channels.SocketChannel
SocketChannel
for testingModifier and Type | Field and Description |
---|---|
protected java.nio.ByteBuffer |
bytes_to_read |
protected int |
bytes_to_write |
protected boolean |
closed |
protected java.nio.ByteBuffer |
recorder |
Constructor and Description |
---|
MockSocketChannel() |
MockSocketChannel(java.nio.channels.spi.SelectorProvider provider)
Initializes a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
java.nio.channels.SocketChannel |
bind(java.net.SocketAddress local) |
java.nio.ByteBuffer |
bytesToRead() |
MockSocketChannel |
bytesToRead(byte[] buf) |
MockSocketChannel |
bytesToRead(java.nio.ByteBuffer buf) |
MockSocketChannel |
bytesToWrite(int num) |
boolean |
connect(java.net.SocketAddress remote) |
void |
doClose() |
boolean |
finishConnect() |
java.net.SocketAddress |
getLocalAddress() |
<T> T |
getOption(java.net.SocketOption<T> name) |
java.net.SocketAddress |
getRemoteAddress() |
protected void |
implCloseSelectableChannel() |
protected void |
implConfigureBlocking(boolean block) |
boolean |
isConnected() |
boolean |
isConnectionPending() |
int |
read(java.nio.ByteBuffer dst) |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length) |
java.nio.ByteBuffer |
recorder() |
MockSocketChannel |
recorder(java.nio.ByteBuffer buf) |
<T> java.nio.channels.SocketChannel |
setOption(java.net.SocketOption<T> name,
T value) |
java.nio.channels.SocketChannel |
shutdownInput() |
java.nio.channels.SocketChannel |
shutdownOutput() |
java.net.Socket |
socket() |
java.util.Set<java.net.SocketOption<?>> |
supportedOptions() |
int |
write(java.nio.ByteBuffer buf) |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length) |
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
begin, close, end, isOpen
protected int bytes_to_write
protected java.nio.ByteBuffer bytes_to_read
protected boolean closed
protected java.nio.ByteBuffer recorder
public MockSocketChannel()
public MockSocketChannel(java.nio.channels.spi.SelectorProvider provider)
provider
- The provider that created this channelpublic MockSocketChannel bytesToWrite(int num)
public MockSocketChannel bytesToRead(byte[] buf)
public MockSocketChannel bytesToRead(java.nio.ByteBuffer buf)
public java.nio.ByteBuffer bytesToRead()
public MockSocketChannel recorder(java.nio.ByteBuffer buf)
public java.nio.ByteBuffer recorder()
public java.nio.channels.SocketChannel bind(java.net.SocketAddress local) throws java.io.IOException
bind
in interface java.nio.channels.NetworkChannel
bind
in class java.nio.channels.SocketChannel
java.io.IOException
public void doClose()
public <T> java.nio.channels.SocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
setOption
in interface java.nio.channels.NetworkChannel
setOption
in class java.nio.channels.SocketChannel
java.io.IOException
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
java.io.IOException
public java.util.Set<java.net.SocketOption<?>> supportedOptions()
public java.nio.channels.SocketChannel shutdownInput() throws java.io.IOException
shutdownInput
in class java.nio.channels.SocketChannel
java.io.IOException
public java.nio.channels.SocketChannel shutdownOutput() throws java.io.IOException
shutdownOutput
in class java.nio.channels.SocketChannel
java.io.IOException
public java.net.Socket socket()
socket
in class java.nio.channels.SocketChannel
public boolean isConnected()
isConnected
in class java.nio.channels.SocketChannel
public boolean isConnectionPending()
isConnectionPending
in class java.nio.channels.SocketChannel
public boolean connect(java.net.SocketAddress remote) throws java.io.IOException
connect
in class java.nio.channels.SocketChannel
java.io.IOException
public boolean finishConnect() throws java.io.IOException
finishConnect
in class java.nio.channels.SocketChannel
java.io.IOException
public java.net.SocketAddress getRemoteAddress() throws java.io.IOException
getRemoteAddress
in class java.nio.channels.SocketChannel
java.io.IOException
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
in interface java.nio.channels.ReadableByteChannel
read
in class java.nio.channels.SocketChannel
java.io.IOException
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read
in interface java.nio.channels.ScatteringByteChannel
read
in class java.nio.channels.SocketChannel
java.io.IOException
public int write(java.nio.ByteBuffer buf) throws java.io.IOException
write
in interface java.nio.channels.WritableByteChannel
write
in class java.nio.channels.SocketChannel
java.io.IOException
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
write
in class java.nio.channels.SocketChannel
java.io.IOException
public java.net.SocketAddress getLocalAddress() throws java.io.IOException
getLocalAddress
in interface java.nio.channels.NetworkChannel
getLocalAddress
in class java.nio.channels.SocketChannel
java.io.IOException
protected void implCloseSelectableChannel() throws java.io.IOException
implCloseSelectableChannel
in class java.nio.channels.spi.AbstractSelectableChannel
java.io.IOException
protected void implConfigureBlocking(boolean block) throws java.io.IOException
implConfigureBlocking
in class java.nio.channels.spi.AbstractSelectableChannel
java.io.IOException
Copyright © 1998-2020 Red Hat. All Rights Reserved.