Search in sources :

Example 11 with ByteChannel

use of java.nio.channels.ByteChannel in project spring-boot by spring-projects.

the class SocketTargetServerConnectionTests method readData.

@Test
public void readData() throws Exception {
    this.server.willSend("hello".getBytes());
    this.server.start();
    ByteChannel channel = this.connection.open(DEFAULT_TIMEOUT);
    ByteBuffer buffer = ByteBuffer.allocate(5);
    channel.read(buffer);
    assertThat(buffer.array()).isEqualTo("hello".getBytes());
}
Also used : ByteChannel(java.nio.channels.ByteChannel) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ByteChannel (java.nio.channels.ByteChannel)11 ByteBuffer (java.nio.ByteBuffer)5 Test (org.junit.Test)5 IOException (java.io.IOException)3 SocketChannel (java.nio.channels.SocketChannel)3 Before (org.junit.Before)2 Frame (water.fvec.Frame)2 InetAddress (java.net.InetAddress)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 Timestamp (java.sql.Timestamp)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)1 ServletServerHttpResponse (org.springframework.http.server.ServletServerHttpResponse)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 TestFrameBuilder (water.fvec.TestFrameBuilder)1 BufferedString (water.parser.BufferedString)1