Search in sources :

Example 26 with EmbeddedChannel

use of io.netty.channel.embedded.EmbeddedChannel in project alluxio by Alluxio.

the class DataServerBlockReadHandlerTest method before.

@Before
public void before() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    mBlockWorker = Mockito.mock(BlockWorker.class);
    Mockito.doNothing().when(mBlockWorker).accessBlock(Mockito.anyLong(), Mockito.anyLong());
    mChannel = new EmbeddedChannel(new DataServerBlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, FileTransferType.MAPPED));
    mChannelNoException = new EmbeddedNoExceptionChannel(new DataServerBlockReadHandler(NettyExecutors.BLOCK_READER_EXECUTOR, mBlockWorker, FileTransferType.MAPPED));
}
Also used : EmbeddedNoExceptionChannel(alluxio.EmbeddedNoExceptionChannel) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) BlockWorker(alluxio.worker.block.BlockWorker) Before(org.junit.Before)

Example 27 with EmbeddedChannel

use of io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.

the class GetSegmentRequestHandlerTest method successfulReadsShouldGenerateResponses.

@Test
public void successfulReadsShouldGenerateResponses() throws Exception {
    byte[] data = new byte[] { 3, 4, 5 };
    StandbySegmentReader reader = mock(StandbySegmentReader.class);
    when(reader.readSegment("segmentId")).thenReturn(data);
    EmbeddedChannel channel = new EmbeddedChannel(new GetSegmentRequestHandler(reader));
    channel.writeInbound(new GetSegmentRequest("clientId", "segmentId"));
    GetSegmentResponse response = (GetSegmentResponse) channel.readOutbound();
    assertEquals("clientId", response.getClientId());
    assertEquals("segmentId", response.getSegmentId());
    assertArrayEquals(data, response.getSegmentData());
}
Also used : GetSegmentResponse(org.apache.jackrabbit.oak.segment.standby.codec.GetSegmentResponse) GetSegmentRequest(org.apache.jackrabbit.oak.segment.standby.codec.GetSegmentRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.Test)

Example 28 with EmbeddedChannel

use of io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.

the class GetBlobRequestEncoderTest method encodeRequest.

@Test
public void encodeRequest() throws Exception {
    EmbeddedChannel channel = new EmbeddedChannel(new GetBlobRequestEncoder());
    channel.writeOutbound(new GetBlobRequest("clientId", "blobId"));
    String message = (String) channel.readOutbound();
    assertEquals(newGetBlobRequest("clientId", "blobId"), message);
}
Also used : Messages.newGetBlobRequest(org.apache.jackrabbit.oak.segment.standby.codec.Messages.newGetBlobRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.Test)

Example 29 with EmbeddedChannel

use of io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.

the class RequestDecoderTest method shouldDecodeValidGetHeadRequests.

@Test
public void shouldDecodeValidGetHeadRequests() throws Exception {
    EmbeddedChannel channel = new EmbeddedChannel(new RequestDecoder());
    channel.writeInbound(Messages.newGetHeadRequest("clientId", false));
    GetHeadRequest request = (GetHeadRequest) channel.readInbound();
    assertEquals("clientId", request.getClientId());
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.Test)

Example 30 with EmbeddedChannel

use of io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.

the class RequestDecoderTest method shouldDecodeValidGetBlobRequests.

@Test
public void shouldDecodeValidGetBlobRequests() throws Exception {
    EmbeddedChannel channel = new EmbeddedChannel(new RequestDecoder());
    channel.writeInbound(Messages.newGetBlobRequest("clientId", "blobId", false));
    GetBlobRequest request = (GetBlobRequest) channel.readInbound();
    assertEquals("clientId", request.getClientId());
    assertEquals("blobId", request.getBlobId());
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.Test)

Aggregations

EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1027 Test (org.junit.jupiter.api.Test)515 ByteBuf (io.netty.buffer.ByteBuf)356 Test (org.junit.Test)342 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)85 HttpResponse (io.netty.handler.codec.http.HttpResponse)73 HttpRequest (io.netty.handler.codec.http.HttpRequest)69 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)64 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)60 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)55 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)50 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)49 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)46 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)42 IOException (java.io.IOException)38 InetSocketAddress (java.net.InetSocketAddress)38 Executable (org.junit.jupiter.api.function.Executable)36 ArrayList (java.util.ArrayList)34 Before (org.junit.Before)32 ChannelHandler (io.netty.channel.ChannelHandler)27