use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.
the class DefaultHttp2ConnectionEncoderTest method dataWriteShouldCreateHalfClosedStream.
@Test
public void dataWriteShouldCreateHalfClosedStream() throws Exception {
writeAllFlowControlledFrames();
Http2Stream stream = createStream(STREAM_ID, false);
ByteBuf data = dummyData();
ChannelPromise promise = newPromise();
encoder.writeData(ctx, STREAM_ID, data.retain(), 0, true, promise);
assertTrue(promise.isSuccess());
verify(remoteFlow).addFlowControlled(eq(stream), any(FlowControlled.class));
verify(lifecycleManager).closeStreamLocal(stream, promise);
assertEquals(data.toString(UTF_8), writtenData.get(0));
data.release();
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.
the class DefaultHttp2ConnectionEncoderTest method canWriteHeaderFrameAfterGoAwayReceived.
@Test
public void canWriteHeaderFrameAfterGoAwayReceived() throws Http2Exception {
writeAllFlowControlledFrames();
goAwayReceived(STREAM_ID);
ChannelPromise promise = newPromise();
encoder.writeHeaders(ctx, STREAM_ID, EmptyHttp2Headers.INSTANCE, 0, false, promise);
verify(writer).writeHeaders(eq(ctx), eq(STREAM_ID), eq(EmptyHttp2Headers.INSTANCE), eq(0), eq(false), eq(promise));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.
the class DefaultHttp2ConnectionEncoderTest method priorityWriteAfterGoAwayShouldSucceed.
@Test
public void priorityWriteAfterGoAwayShouldSucceed() throws Exception {
createStream(STREAM_ID, false);
goAwayReceived(Integer.MAX_VALUE);
ChannelPromise promise = newPromise();
encoder.writePriority(ctx, STREAM_ID, 0, (short) 255, true, promise);
verify(writer).writePriority(eq(ctx), eq(STREAM_ID), eq(0), eq((short) 255), eq(true), eq(promise));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.
the class DefaultHttp2ConnectionEncoderTest method settingsWriteShouldNotUpdateSettings.
@Test
public void settingsWriteShouldNotUpdateSettings() throws Exception {
Http2Settings settings = new Http2Settings();
settings.initialWindowSize(100);
settings.maxConcurrentStreams(1000);
settings.headerTableSize(2000);
ChannelPromise promise = newPromise();
encoder.writeSettings(ctx, settings, promise);
verify(writer).writeSettings(eq(ctx), eq(settings), eq(promise));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise in project netty by netty.
the class DefaultHttp2ConnectionEncoderTest method dataFramesShouldMergeUseVoidPromise.
@Test
public void dataFramesShouldMergeUseVoidPromise() throws Exception {
createStream(STREAM_ID, false);
final ByteBuf data = dummyData().retain();
ChannelPromise promise1 = newVoidPromise(channel);
encoder.writeData(ctx, STREAM_ID, data, 0, true, promise1);
ChannelPromise promise2 = newVoidPromise(channel);
encoder.writeData(ctx, STREAM_ID, data, 0, true, promise2);
// Now merge the two payloads.
List<FlowControlled> capturedWrites = payloadCaptor.getAllValues();
FlowControlled mergedPayload = capturedWrites.get(0);
mergedPayload.merge(ctx, capturedWrites.get(1));
assertEquals(16, mergedPayload.size());
assertFalse(promise1.isSuccess());
assertFalse(promise2.isSuccess());
// Write the merged payloads and verify it was written correctly.
mergedPayload.write(ctx, 16);
assertEquals(0, mergedPayload.size());
assertEquals("abcdefghabcdefgh", writtenData.get(0));
assertEquals(0, data.refCnt());
// The promises won't be set since there are no listeners.
assertFalse(promise1.isSuccess());
assertFalse(promise2.isSuccess());
}
Aggregations