Scotts comment

This commit is contained in:
Norman Maurer 2019-07-26 13:31:14 +02:00
parent fb6c8c658b
commit 780b04ad44

View File

@ -23,6 +23,7 @@ import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultChannelPromise;
import io.netty.handler.codec.http.HttpResponseStatus;
import junit.framework.AssertionFailedError;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@ -44,6 +45,7 @@ import static io.netty.handler.codec.http2.Http2Stream.State.OPEN;
import static io.netty.handler.codec.http2.Http2Stream.State.RESERVED_REMOTE;
import static io.netty.util.CharsetUtil.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;
@ -273,13 +275,16 @@ public class DefaultHttp2ConnectionDecoderTest {
}
}
@Test(expected = Http2Exception.class)
@Test
public void dataReadForUnknownStreamThatNeverExistedShouldThrow() throws Exception {
when(connection.streamMayHaveExisted(STREAM_ID)).thenReturn(false);
when(connection.stream(STREAM_ID)).thenReturn(null);
final ByteBuf data = dummyData();
try {
decode().onDataRead(ctx, STREAM_ID, data, 0, true);
fail();
} catch (Http2Exception expected) {
assertThat(expected, CoreMatchers.not(CoreMatchers.instanceOf(Http2Exception.StreamException.class)));
} finally {
data.release();
}