Package com.kurento.kmf.jsonrpcconnector.client

Examples of com.kurento.kmf.jsonrpcconnector.client.JsonRpcClient


  @SuppressWarnings("resource")
  public static JsonRpcClient createJsonRpcClientFromSystemProperties(
      String prefix) {

    JsonRpcClient client;

    String kmfTransport = getKmfTransport(prefix);

    switch (kmfTransport) {
    case KMF_TRANSPORT_THRIFT_VALUE:
View Full Code Here


  // TODO this test has been disabled awaiting fixup
  @Ignore
  @Test
  public void test() throws IOException, InterruptedException {

    JsonRpcClient client = createJsonRpcClient("/error_handler");

    try {

      client.sendRequest("explicitError");

      Assert.fail("An exception should be thrown");

    } catch (JsonRpcErrorException e) {

      checkException(e, "Exception message", "Data");
    }

    try {

      client.sendRequest("asyncError");

      Assert.fail("An exception should be thrown");

    } catch (JsonRpcErrorException e) {

      checkException(e, "Exception message", "Data");
    }

    try {

      client.sendRequest("exceptionError");

      Assert.fail("An exception should be thrown");

    } catch (JsonRpcErrorException e) {

      checkException(e, "RuntimeException:Exception message.",
          "java.lang.RuntimeException:");
    }

    client.close();
  }
View Full Code Here

    HttpHeaders headers = new HttpHeaders();
    headers.add(
        "X-Auth-Token",
        "jm1-vF_kcarImdhRh0v4axk0FcndHbZPaNRpiRMyddp2Qb1Kojllfm63Ikv3uN3KFx850CCYzUamjNl5GwApnQ");

    JsonRpcClient client = new JsonRpcClientWebSocket("ws://localhost:"
        + getPort()  + "/thrift", headers);

    client.setServerRequestHandler(new DefaultJsonRpcHandler<JsonObject>() {
      @Override
      public void handleRequest(Transaction transaction,
          Request<JsonObject> request) throws Exception {

        LOG.info("Request received: " + request);
View Full Code Here

  }

  @Test
  public void test() throws IOException, InterruptedException {

    JsonRpcClient client = createJsonRpcClient("/new_session_handler");

    Assert.assertEquals("new",
        client.sendRequest("sessiontest", String.class));
    Assert.assertEquals("old",
        client.sendRequest("sessiontest", String.class));
    Assert.assertEquals("old",
        client.sendRequest("sessiontest", String.class));

    client.close();

  }
View Full Code Here

  }
 
  public boolean secuentialPipelinesOneConnection() throws IOException, InterruptedException,
      ExecutionException {
   
    JsonRpcClient client = createClient();
   
    for(int i=0; i<SEQUENTIAL_PIPELINES; i++){
      LOG.info("Starting pipeline OneConnection {}",i);
      if(!createPipeline(client)){
        return false;
      }
      LOG.info("Finished pipeline OneConnection {}",i);
    }   
   
    client.close();
    return true;
  }
View Full Code Here

    execService.awaitTermination(10, TimeUnit.SECONDS);
  }

  private boolean createPipeline() throws IOException {

    JsonRpcClient client = createClient();

    boolean result = createPipeline(client);
   
    client.close();
       
    return result;
  }
View Full Code Here

  }

  @Test
  public void test() throws IOException {

    JsonRpcClient client = createJsonRpcClient("/reconnection");

    if (client instanceof JsonRpcClientWebSocket) {

      Assert.assertEquals("new",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));

      log.info("SessionId: " + client.getSession().getSessionId());

      JsonRpcClientWebSocket webSocketClient = (JsonRpcClientWebSocket) client;

      WebSocketSession session = webSocketClient.getWebSocketSession();
      session.close();

      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));

      client.setSessionId(null);

      // With this we test if the transportId is used to recognize the
      // session

      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));

      log.info("SessionId: " + client.getSession().getSessionId());

    }

    client.close();

  }
View Full Code Here

  @Test
  public void timeoutReconnectionTest() throws IOException,
      InterruptedException {

    JsonRpcClient client = createJsonRpcClient("/reconnection");

    if (client instanceof JsonRpcClientWebSocket) {

      Assert.assertEquals("new",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));
      Assert.assertEquals("old",
          client.sendRequest("sessiontest", String.class));

      JsonRpcClientWebSocket webSocketClient = (JsonRpcClientWebSocket) client;
      WebSocketSession session = webSocketClient.getWebSocketSession();
      session.close();

      Thread.sleep(1000);

      try {
        client.sendRequest("sessiontest", String.class);
        Assert.fail("The reconnection shoudn't be succesful because timeout");
      } catch (JsonRpcErrorException e) {
        Assert.assertEquals(JsonRpcConstants.RECONNECTION_ERROR,
            e.getMessage());
      }
    }

    client.close();

  }
View Full Code Here

    LOG.info("Server started");

    LOG.info("Starting client");

    JsonRpcClient client = createJsonRpcClient();
    useRom(client);

    client.close();

    destroyJsonRpcServer();
  }
View Full Code Here

        getRabbitMqAddress(RABBITMQ_CONNECTOR_PREFIX));
  }

  private static void startMediaConnector() {

    JsonRpcClient client = KmfMediaApi
        .createJsonRpcClientFromSystemProperties(MEDIA_CONNECTOR_PREFIX);

    mediaConnector = new MediaConnectorManager(client, getKmcHttpPort());
  }
View Full Code Here

TOP

Related Classes of com.kurento.kmf.jsonrpcconnector.client.JsonRpcClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.