Esempio n. 1
0
  private static void testSpdySessionHandlerPing(SpdyVersion version, boolean server) {
    EmbeddedChannel sessionHandler =
        new EmbeddedChannel(
            new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));

    while (sessionHandler.readOutbound() != null) {
      continue;
    }

    int localStreamId = server ? 1 : 2;
    int remoteStreamId = server ? 2 : 1;

    SpdyPingFrame localPingFrame = new DefaultSpdyPingFrame(localStreamId);
    SpdyPingFrame remotePingFrame = new DefaultSpdyPingFrame(remoteStreamId);

    // Check if session handler returns identical local PINGs
    sessionHandler.writeInbound(localPingFrame);
    assertPing(sessionHandler.readOutbound(), localPingFrame.getId());
    assertNull(sessionHandler.readOutbound());

    // Check if session handler ignores un-initiated remote PINGs
    sessionHandler.writeInbound(remotePingFrame);
    assertNull(sessionHandler.readOutbound());

    sessionHandler.finish();
  }
Esempio n. 2
0
 private static void assertPing(Object msg, int id) {
   assertNotNull(msg);
   assertTrue(msg instanceof SpdyPingFrame);
   SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
   assertEquals(spdyPingFrame.getId(), id);
 }