Search in sources :

Example 1 with Http2GoAwayException

use of io.netty.handler.codec.http2.StreamBufferingEncoder.Http2GoAwayException in project netty by netty.

the class StreamBufferingEncoderTest method receivingGoAwayFailsBufferedStreams.

@Test
public void receivingGoAwayFailsBufferedStreams() throws Http2Exception {
    encoder.writeSettingsAck(ctx, newPromise());
    setMaxConcurrentStreams(5);
    int streamId = 3;
    List<ChannelFuture> futures = new ArrayList<ChannelFuture>();
    for (int i = 0; i < 9; i++) {
        futures.add(encoderWriteHeaders(streamId, newPromise()));
        streamId += 2;
    }
    assertEquals(5, connection.numActiveStreams());
    assertEquals(4, encoder.numBufferedStreams());
    connection.goAwayReceived(11, 8, EMPTY_BUFFER);
    assertEquals(5, connection.numActiveStreams());
    assertEquals(0, encoder.numBufferedStreams());
    int failCount = 0;
    for (ChannelFuture f : futures) {
        if (f.cause() != null) {
            assertTrue(f.cause() instanceof Http2GoAwayException);
            failCount++;
        }
    }
    assertEquals(4, failCount);
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Http2GoAwayException(io.netty.handler.codec.http2.StreamBufferingEncoder.Http2GoAwayException) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 2 with Http2GoAwayException

use of io.netty.handler.codec.http2.StreamBufferingEncoder.Http2GoAwayException in project netty by netty.

the class StreamBufferingEncoderTest method receivingGoAwayFailsNewStreamIfMaxConcurrentStreamsReached.

@Test
public void receivingGoAwayFailsNewStreamIfMaxConcurrentStreamsReached() throws Http2Exception {
    encoder.writeSettingsAck(ctx, newPromise());
    setMaxConcurrentStreams(1);
    encoderWriteHeaders(3, newPromise());
    connection.goAwayReceived(11, 8, EMPTY_BUFFER);
    ChannelFuture f = encoderWriteHeaders(5, newPromise());
    assertTrue(f.cause() instanceof Http2GoAwayException);
    assertEquals(0, encoder.numBufferedStreams());
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Http2GoAwayException(io.netty.handler.codec.http2.StreamBufferingEncoder.Http2GoAwayException) Test(org.junit.jupiter.api.Test)

Aggregations

ChannelFuture (io.netty.channel.ChannelFuture)2 Http2GoAwayException (io.netty.handler.codec.http2.StreamBufferingEncoder.Http2GoAwayException)2 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1