DefaultHttp2Connection implements Http2Connection { @Override public Endpoint<Http2LocalFlowController> local() { return localEndpoint; } DefaultHttp2Connection(boolean server); @Override void addListener(Listener listener); @Override void removeListener(Listener listener); @Override boolean isServer(); @Override Http2Stream connectionStream(); @Override Http2Stream stream(int streamId); @Override boolean streamMayHaveExisted(int streamId); @Override int numActiveStreams(); @Override Http2Stream forEachActiveStream(Http2StreamVisitor visitor); @Override Endpoint<Http2LocalFlowController> local(); @Override Endpoint<Http2RemoteFlowController> remote(); @Override boolean goAwayReceived(); @Override void goAwayReceived(final int lastKnownStream, long errorCode, ByteBuf debugData); @Override boolean goAwaySent(); @Override void goAwaySent(final int lastKnownStream, long errorCode, ByteBuf debugData); @Override PropertyKey newKey();  }
@Test(expected = Http2Exception.class) public void newStreamBehindExpectedShouldThrow() throws Http2Exception { server.local().createStream(0, true); }
@Test(expected = Http2Exception.class) public void newStreamNotForServerShouldThrow() throws Http2Exception { server.local().createStream(11, true); }
@Test(expected = Http2Exception.class) public void newStreamNotForClientShouldThrow() throws Http2Exception { client.local().createStream(10, true); }
@Test(expected = Http2Exception.class) public void createShouldThrowWhenMaxAllowedStreamsExceeded() throws Http2Exception { server.local().maxActiveStreams(0); server.local().createStream(2, true); }
@Test public void createIdleShouldSucceedWhenMaxAllowedStreamsExceeded() throws Http2Exception { server.local().maxActiveStreams(0); Http2Stream stream = server.local().createIdleStream(2); thrown.expect(Http2Exception.class); thrown.expectMessage("Maximum active streams violated for this endpoint."); stream.open(false); }
@SuppressWarnings("NumericOverflow") @Test(expected = Http2Exception.class) public void localStreamInvalidStreamIdShouldThrow() throws Http2Exception { client.local().createStream(Integer.MAX_VALUE + 2, false); }