Search in sources :

Example 36 with ChannelPromise

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.

the class DefaultHttp2ConnectionEncoderTest method tooManyHeadersWithDataThrows.

private void tooManyHeadersWithDataThrows(boolean eos) {
    writeAllFlowControlledFrames();
    final int streamId = 6;
    ChannelPromise promise = newPromise();
    encoder.writeHeaders(ctx, streamId, EmptyHttp2Headers.INSTANCE, 0, false, promise);
    Http2Stream stream = connection.stream(streamId);
    when(remoteFlow.hasFlowControlled(eq(stream))).thenReturn(true);
    ChannelPromise promise2 = newPromise();
    encoder.writeHeaders(ctx, streamId, EmptyHttp2Headers.INSTANCE, 0, true, promise2);
    ChannelPromise promise3 = newPromise();
    ChannelFuture future = encoder.writeHeaders(ctx, streamId, EmptyHttp2Headers.INSTANCE, 0, eos, promise3);
    assertTrue(future.isDone());
    assertFalse(future.isSuccess());
    verify(writer, times(1)).writeHeaders(eq(ctx), eq(streamId), eq(EmptyHttp2Headers.INSTANCE), eq(0), eq(false), eq(promise));
    verify(writer, times(1)).writeHeaders(eq(ctx), eq(streamId), eq(EmptyHttp2Headers.INSTANCE), eq(0), eq(true), eq(promise2));
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) ChannelPromise(io.netty.channel.ChannelPromise) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise)

Example 37 with ChannelPromise

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.

the class DefaultHttp2ConnectionEncoderTest method pingWriteShouldSucceed.

@Test
public void pingWriteShouldSucceed() throws Exception {
    ChannelPromise promise = newPromise();
    encoder.writePing(ctx, false, 0L, promise);
    verify(writer).writePing(eq(ctx), eq(false), eq(0L), eq(promise));
}
Also used : ChannelPromise(io.netty.channel.ChannelPromise) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) Test(org.junit.jupiter.api.Test)

Example 38 with ChannelPromise

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.

the class DefaultHttp2ConnectionEncoderTest method priorityWriteOnPreviouslyExistingParentStreamShouldSucceed.

@Test
public void priorityWriteOnPreviouslyExistingParentStreamShouldSucceed() throws Exception {
    final int parentStreamId = STREAM_ID + 2;
    createStream(STREAM_ID, false);
    createStream(parentStreamId, false).close();
    ChannelPromise promise = newPromise();
    short weight = 255;
    encoder.writePriority(ctx, STREAM_ID, parentStreamId, weight, true, promise);
    verify(writer).writePriority(eq(ctx), eq(STREAM_ID), eq(parentStreamId), eq(weight), eq(true), eq(promise));
}
Also used : ChannelPromise(io.netty.channel.ChannelPromise) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) Test(org.junit.jupiter.api.Test)

Example 39 with ChannelPromise

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.

the class DefaultHttp2ConnectionEncoderTest method headersWithNoPriority.

@Test
public void headersWithNoPriority() {
    writeAllFlowControlledFrames();
    final int streamId = 6;
    ChannelPromise promise = newPromise();
    encoder.writeHeaders(ctx, streamId, EmptyHttp2Headers.INSTANCE, 0, false, promise);
    verify(writer).writeHeaders(eq(ctx), eq(streamId), eq(EmptyHttp2Headers.INSTANCE), eq(0), eq(false), eq(promise));
}
Also used : ChannelPromise(io.netty.channel.ChannelPromise) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) Test(org.junit.jupiter.api.Test)

Example 40 with ChannelPromise

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.

the class DefaultHttp2ConnectionEncoderTest method settingsWriteAfterGoAwayShouldSucceed.

@Test
public void settingsWriteAfterGoAwayShouldSucceed() throws Exception {
    goAwayReceived(0);
    ChannelPromise promise = newPromise();
    encoder.writeSettings(ctx, new Http2Settings(), promise);
    verify(writer).writeSettings(eq(ctx), any(Http2Settings.class), eq(promise));
}
Also used : ChannelPromise(io.netty.channel.ChannelPromise) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) Test(org.junit.jupiter.api.Test)

Aggregations

ChannelPromise (io.netty.channel.ChannelPromise)223 Test (org.junit.jupiter.api.Test)88 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)63 ChannelFuture (io.netty.channel.ChannelFuture)62 DefaultChannelPromise (io.netty.channel.DefaultChannelPromise)58 ByteBuf (io.netty.buffer.ByteBuf)56 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)30 Test (org.junit.Test)25 Channel (io.netty.channel.Channel)23 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)22 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)22 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)21 ClosedChannelException (java.nio.channels.ClosedChannelException)20 ChannelFutureListener (io.netty.channel.ChannelFutureListener)19 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)18 InvocationOnMock (org.mockito.invocation.InvocationOnMock)18 AsciiString (io.netty.util.AsciiString)15 IOException (java.io.IOException)14 CountDownLatch (java.util.concurrent.CountDownLatch)13 Bootstrap (io.netty.bootstrap.Bootstrap)12