Search in sources :

Example 26 with EmbeddedChannel

use of org.apache.flink.shaded.netty4.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 org.apache.flink.shaded.netty4.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 org.apache.flink.shaded.netty4.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 org.apache.flink.shaded.netty4.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 org.apache.flink.shaded.netty4.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)1065 Test (org.junit.jupiter.api.Test)540 ByteBuf (io.netty.buffer.ByteBuf)371 Test (org.junit.Test)342 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)88 HttpResponse (io.netty.handler.codec.http.HttpResponse)75 HttpRequest (io.netty.handler.codec.http.HttpRequest)72 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)65 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)62 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)60 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)55 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)49 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)47 ArrayList (java.util.ArrayList)47 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)42 IOException (java.io.IOException)39 InetSocketAddress (java.net.InetSocketAddress)38 Executable (org.junit.jupiter.api.function.Executable)36 Before (org.junit.Before)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32