Esempio n. 1
0
 @Test
 public void headersFrameWithPriorityShouldMatch() throws Exception {
   final Http2Headers headers =
       new DefaultHttp2Headers.Builder()
           .method("GET")
           .scheme("https")
           .authority("example.org")
           .path("/some/path/resource2")
           .build();
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writeHeaders(
               ctx(), newPromise(), 0x7FFFFFFF, headers, 4, (short) 255, true, 0, true);
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onHeadersRead(
           any(ChannelHandlerContext.class),
           eq(0x7FFFFFFF),
           eq(headers),
           eq(4),
           eq((short) 255),
           eq(true),
           eq(0),
           eq(true));
 }
Esempio n. 2
0
 @Test
 public void stressTest() throws Exception {
   final Http2Headers headers =
       new DefaultHttp2Headers.Builder()
           .method("GET")
           .scheme("https")
           .authority("example.org")
           .path("/some/path/resource2")
           .build();
   final String text = "hello world";
   final int numStreams = 10000;
   int expectedFrames = numStreams * 2;
   requestLatch = new CountDownLatch(expectedFrames);
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           for (int i = 1; i < numStreams + 1; ++i) {
             frameWriter.writeHeaders(
                 ctx(), newPromise(), i, headers, 0, (short) 16, false, 0, false);
             frameWriter.writeData(
                 ctx(), newPromise(), i, Unpooled.copiedBuffer(text.getBytes()), 0, true);
           }
         }
       });
   awaitRequests();
 }
Esempio n. 3
0
 @Test
 public void windowUpdateFrameShouldMatch() throws Exception {
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writeWindowUpdate(ctx(), newPromise(), 0x7FFFFFFF, 0x7FFFFFFF);
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onWindowUpdateRead(any(ChannelHandlerContext.class), eq(0x7FFFFFFF), eq(0x7FFFFFFF));
 }
Esempio n. 4
0
 @Test
 public void pingFrameShouldMatch() throws Exception {
   final ByteBuf buf = Unpooled.copiedBuffer("01234567", UTF_8);
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writePing(ctx(), ctx().newPromise(), true, buf);
         }
       });
   awaitRequests();
   verify(serverObserver).onPingAckRead(any(ChannelHandlerContext.class), dataCaptor.capture());
 }
Esempio n. 5
0
 @Test
 public void priorityFrameShouldMatch() throws Exception {
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writePriority(ctx(), newPromise(), 0x7FFFFFFF, 1, (short) 1, true);
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onPriorityRead(
           any(ChannelHandlerContext.class), eq(0x7FFFFFFF), eq(1), eq((short) 1), eq(true));
 }
Esempio n. 6
0
 @Test
 public void settingsFrameShouldMatch() throws Exception {
   final Http2Settings settings = new Http2Settings();
   settings.initialWindowSize(10);
   settings.maxConcurrentStreams(1000);
   settings.headerTableSize(4096);
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writeSettings(ctx(), newPromise(), settings);
         }
       });
   awaitRequests();
   verify(serverObserver).onSettingsRead(any(ChannelHandlerContext.class), eq(settings));
 }
Esempio n. 7
0
 @Test
 public void dataFrameShouldMatch() throws Exception {
   final String text = "hello world";
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writeData(
               ctx(), newPromise(), 0x7FFFFFFF, Unpooled.copiedBuffer(text.getBytes()), 100, true);
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onDataRead(
           any(ChannelHandlerContext.class),
           eq(0x7FFFFFFF),
           dataCaptor.capture(),
           eq(100),
           eq(true));
 }
Esempio n. 8
0
 @Test
 public void pushPromiseFrameShouldMatch() throws Exception {
   final Http2Headers headers =
       new DefaultHttp2Headers.Builder()
           .method("GET")
           .scheme("https")
           .authority("example.org")
           .path("/some/path/resource2")
           .build();
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writePushPromise(ctx(), newPromise(), 0x7FFFFFFF, 1, headers, 5);
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onPushPromiseRead(
           any(ChannelHandlerContext.class), eq(0x7FFFFFFF), eq(1), eq(headers), eq(5));
 }
Esempio n. 9
0
 @Test
 public void goAwayFrameShouldMatch() throws Exception {
   final String text = "test";
   runInChannel(
       clientChannel,
       new Http2Runnable() {
         @Override
         public void run() {
           frameWriter.writeGoAway(
               ctx(),
               newPromise(),
               0x7FFFFFFF,
               0xFFFFFFFFL,
               Unpooled.copiedBuffer(text.getBytes()));
         }
       });
   awaitRequests();
   verify(serverObserver)
       .onGoAwayRead(
           any(ChannelHandlerContext.class),
           eq(0x7FFFFFFF),
           eq(0xFFFFFFFFL),
           dataCaptor.capture());
 }