diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java index b1b1d69a2d..96123cdf77 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoderTest.java @@ -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(); }