Exemplo n.º 1
0
  @Test
  public void oneMediaPipelineTest() throws InterruptedException {

    JsonRpcClientKeepAliveController controller = new JsonRpcClientKeepAliveController();

    KeepAliveManager keepAliveManager =
        new KeepAliveManager(
            controller.getClient(),
            KEEPALIVE_INTERVAL_TIME,
            KeepAliveManager.Mode.PER_ID_AS_SESSION);

    keepAliveManager.start();

    Thread.sleep(KEEPALIVE_INTERVAL_TIME * 2);

    Assert.assertTrue(
        "KeepAliveManager in pipeline mode without pipelines shouldn't send any keepAlive event",
        controller.clearEvents() == 0);

    keepAliveManager.addId("XXXXX");

    Thread.sleep(KEEPALIVE_INTERVAL_TIME * 3);

    Assert.assertTrue("keepAlive events should be at least 2", controller.clearEvents() >= 2);

    keepAliveManager.stop();
  }
Exemplo n.º 2
0
  @Test
  public void addRemovePipelinesTest() throws InterruptedException {

    JsonRpcClientKeepAliveController controller = new JsonRpcClientKeepAliveController();

    KeepAliveManager keepAliveManager =
        new KeepAliveManager(
            controller.getClient(),
            KEEPALIVE_INTERVAL_TIME,
            KeepAliveManager.Mode.PER_ID_AS_SESSION);

    keepAliveManager.start();

    String mediaPipelineIdA = "XXXXX";
    String mediaPipelineIdB = "YYYYY";

    keepAliveManager.addId(mediaPipelineIdA);
    keepAliveManager.addId(mediaPipelineIdB);

    Thread.sleep(KEEPALIVE_INTERVAL_TIME * 3);

    Assert.assertTrue(
        "keepAlive events should be at least 2 x 2 = 4", controller.clearEvents() >= 4);

    keepAliveManager.removeId(mediaPipelineIdA);
    keepAliveManager.removeId(mediaPipelineIdB);

    Thread.sleep(KEEPALIVE_INTERVAL_TIME);
    log.info("Removed media pipelines and wait a keepAliveIntervalTime");

    controller.clearEvents();
    log.info("Cleared events after removing media pipelines");

    Thread.sleep(KEEPALIVE_INTERVAL_TIME * 3);

    Assert.assertTrue(
        "keepAliveManager without pipelines shouldn't send keepAlives",
        controller.clearEvents() == 0);

    keepAliveManager.stop();
  }