예제 #1
0
  @Test
  public void testRemoveMessageFuture() throws Exception {
    HashedWheelTimer timer = getTimer();
    RequestManager requestManager = new RequestManager(timer);
    try {
      RequestPacket packet = new RequestPacket(1, new byte[0]);
      DefaultFuture future = requestManager.register(packet, 2000);

      future.setFailure(new RuntimeException());

      Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
      Assert.assertNull(nullFuture);

    } finally {
      requestManager.close();
      timer.stop();
    }
  }
예제 #2
0
  @Test
  public void testRegisterRequest() throws Exception {
    HashedWheelTimer timer = getTimer();
    RequestManager requestManager = new RequestManager(timer);
    try {
      RequestPacket packet = new RequestPacket(new byte[0]);
      Future future = requestManager.register(packet, 50);
      Thread.sleep(200);

      Assert.assertTrue(future.isReady());
      Assert.assertFalse(future.isSuccess());
      Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
      logger.debug(future.getCause().getMessage());
    } finally {
      requestManager.close();
      timer.stop();
    }
  }