Package org.serviceconnector.api.cln

Examples of org.serviceconnector.api.cln.SCClient


   * Description: Invoke keep alive timeout with value = Integer.MIN_VALUE<br>
   * Expectation: throws validation exception
   */
  @Test(expected = SCMPValidatorException.class)
  public void t25_keepAliveTimeout() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    client.setKeepAliveTimeoutSeconds(Integer.MIN_VALUE); // can be set before attach
  }
View Full Code Here


        TestConstants.sesServerName1, TestConstants.PORT_SES_SRV_TCP, TestConstants.PORT_SC0_TCP, 1000, 10,
        TestConstants.sesServiceName1);
    pubSrvCtx = ctrl.startServer(TestConstants.COMMUNICATOR_TYPE_PUBLISH, TestConstants.log4jSrvProperties,
        TestConstants.pubServerName1, TestConstants.PORT_PUB_SRV_TCP, TestConstants.PORT_SC0_TCP, 1000, 10,
        TestConstants.pubServiceName1);
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    client.attach();
  }
View Full Code Here

  }

  public void process(String hostToConnect, int portToConnect, ConnectionType conType, String serviceName,
      FILE_SERVICE_FUNCTION function, String filePath, String targetFileName, int otiInSecs) throws Exception {

    SCClient sc = new SCClient(hostToConnect, portToConnect, conType);

    try {
      sc.setMaxConnections(20);
      sc.setKeepAliveIntervalSeconds(30);
      sc.attach();

      LOGGER.info("FileUploader attached to: " + hostToConnect + ":" + portToConnect + " " + conType + " - " + serviceName);
      SCFileService service = sc.newFileService(serviceName);

      switch (function) {
      case LIST:
        list(service);
        break;
      case UPLOAD:
        upload(service, filePath, targetFileName, otiInSecs);
        break;
      case DOWNLOAD:
        download(service, filePath, targetFileName, otiInSecs);
        break;
      }

    } catch (Exception e) {
      LOGGER.error("run", e);
      throw e;
    } finally {
      try {
        sc.detach(); // detaches from SC, stops communication
      } catch (Exception e) {
        LOGGER.error("cleanup", e);
        throw e;
      }
    }
View Full Code Here

    }
  }

  public void p_initAttach() throws Exception {
    client = new SCClient(this.host, this.port, this.connectionType);
    client.setKeepAliveIntervalSeconds(this.keepAliveIntervalSeconds);
    client.setMaxConnections(this.maxConnections);
    client.attach();
  }
View Full Code Here

   * Description: Attach/detach 10000 times to SC on localhost and tcp-connection type. Measure performance <br>
   * Expectation: Performance better than 100 cycles/sec.
   */
  @Test
  public void t_10000_tcp() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    int nr = 10000;
    int sleep = 0;
    long start = System.currentTimeMillis();
    for (int i = 0; i < nr; i++) {
      if (((i + 1) % 200) == 0)
View Full Code Here

   * Description: Attach/defach 10000 times to SC on localhost and http-connection type. Measure performance <br>
   * Expectation: Performance better than 100 cycles/sec.
   */
  @Test
  public void t_10000_http() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    int nr = 10000;
    int sleep = 0;
    long start = System.currentTimeMillis();
    for (int i = 0; i < nr; i++) {
      if (((i + 1) % 200) == 0)
View Full Code Here

  public void t_5000_clients_http() throws Exception {
    int nr = 5000;
    SCClient[] clients = new SCClient[nr];
    // create clients
    for (int i= 0; i < nr; i++) {
      clients[i] = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    }
    //attach
    long start = System.currentTimeMillis();
    for (int i= 0; i < nr; i++) {
      if (((i+1) % 200) == 0) testLogger.info("Attaching client nr. " + (i+1) );
View Full Code Here

  public void t_5000_clients_tcp() throws Exception {
    int nr = 5000;
    SCClient[] clients = new SCClient[nr];
    // create clients
    for (int i= 0; i < nr; i++) {
      clients[i] = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    }
    //attach
    long start = System.currentTimeMillis();
    for (int i= 0; i < nr; i++) {
      if (((i+1) % 200) == 0) testLogger.info("Attaching client nr. " + (i+1) );
View Full Code Here

    this.methodName = methodName;
  }

  @Override
  public void run() {
    SCClient client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);

    try {
      client.attach();

      if (getMethodName() == "createSession_whiteSpaceSessionInfo_sessionIdIsNotEmpty") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo(" ");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.deleteSession();

      } else if (getMethodName() == "createSession_arbitrarySpaceSessionInfo_sessionIdIsNotEmpty") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("The quick brown fox jumps over a lazy dog.");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.deleteSession();

      } else if (getMethodName() == "createSession_arbitrarySpaceSessionInfoDataOneChar_sessionIdIsNotEmpty") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage("a");
        scMessage.setSessionInfo("The quick brown fox jumps over a lazy dog.");
        sessionService.createSession(10, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.deleteSession();

      } else if (getMethodName() == "createSession_256LongSessionInfoData60kBByteArray_sessionIdIsNotEmpty") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage(new byte[TestConstants.dataLength60kB]);
        scMessage.setSessionInfo(TestConstants.stringLength256);
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.deleteSession();

      } else if (getMethodName() == "deleteSession_beforeCreateSession_noSessionId") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        sessionService.deleteSession();

      } else if (getMethodName() == "deleteSession_afterValidNewSessionService_noSessionId") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.deleteSession();

      } else if (getMethodName() == "createSession_rejectTheSessionThenCreateValidSessionThenExecuteAMessage_passes") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);

        try {
          SCMessage scMessage = new SCMessage("reject");
          scMessage.setSessionInfo("sessionInfo");
          sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        } catch (Exception e) {
        }
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(10, scMessage, new TestSessionServiceMessageCallback(sessionService));

        sessionService.execute(new SCMessage());
        sessionService.deleteSession();

      } else if (getMethodName() == "execute_messageData1MBArray_returnsTheSameMessageData") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));

        SCMessage message = new SCMessage(new byte[TestConstants.dataLength1MB]);
        message.setCompressed(false);

        sessionService.execute(message);
        sessionService.deleteSession();

      } else if (getMethodName() == "createSessionExecuteDeleteSession_twice_6MessagesArrive") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);

        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.execute(new SCMessage(new byte[128]));
        sessionService.deleteSession();

        scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(60, scMessage, new TestSessionServiceMessageCallback(sessionService));
        sessionService.execute(new SCMessage(new byte[128]));
        sessionService.deleteSession();

      } else if (getMethodName() == "echo_waitFor3EchoMessages_5MessagesArrive") {
        SCSessionService sessionService = client.newSessionService(TestConstants.sesServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(1, scMessage, new TestSessionServiceMessageCallback(sessionService));
        Thread.sleep(6000);
        sessionService.deleteSession();
      }

    } catch (Exception e) {
      LOGGER.error("run", e);
    } finally {
      try {
        client.detach();
      } catch (Exception e) {
        LOGGER.error("run", e);
      }
    }
  }
View Full Code Here

    this.methodName = methodName;
  }

  @Override
  public void run() {
    SCClient sc = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);

    try {
      sc.attach();

      SCSubscribeMessage subscibeMessage = new SCSubscribeMessage();
      subscibeMessage.setMask(TestConstants.mask);
      subscibeMessage.setSessionInfo("sessionInfo");

      if (getMethodName() == "subscribe_serviceNameValidMaskSameAsInServer_isSubscribedSessionIdExists") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.subscribe(subscibeMessage, new TestPublishServiceMessageCallback(service));
        service.unsubscribe();

      } else if (getMethodName() == "subscribe_timeoutMaxAllowed_isSubscribedSessionIdExists") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.subscribe(3600, subscibeMessage, new TestPublishServiceMessageCallback(service));
        service.unsubscribe();

      } else if (getMethodName() == "changeSubscription_toMaskWhiteSpace_passes") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.subscribe(subscibeMessage, new TestPublishServiceMessageCallback(service));
        subscibeMessage.setMask(" ");
        service.changeSubscription(subscibeMessage);
        service.unsubscribe();

      } else if (getMethodName() == "subscribeUnsubscribe_twice_isSubscribedThenNot") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.subscribe(subscibeMessage, new TestPublishServiceMessageCallback(service));
        service.unsubscribe();
        service.subscribe(subscibeMessage, new TestPublishServiceMessageCallback(service));
        service.unsubscribe();

      } else if (getMethodName() == "changeSubscription_twice_passes") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.subscribe(subscibeMessage, new TestPublishServiceMessageCallback(service));

        service.changeSubscription(subscibeMessage);
        service.changeSubscription(subscibeMessage);

        service.unsubscribe();

      } else if (getMethodName() == "unsubscribe_serviceNameValid_notSubscribedEmptySessionId") {
        SCPublishService service = sc.newPublishService(TestConstants.pubServiceName1);
        service.unsubscribe();

      } else if (getMethodName() == "createSession_rejectTheSessionThenCreateValidSessionThenExecuteAMessage_passes") {
        SCSessionService sessionService = sc.newSessionService(TestConstants.pubServiceName1);

        try {
          SCMessage scMessage = new SCMessage("reject");
          scMessage.setSessionInfo("sessionInfo");
          sessionService.createSession(10, scMessage, new TestSessionServiceMessageCallback(sessionService));
        } catch (Exception e) {
        }
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(10, scMessage, new TestSessionServiceMessageCallback(sessionService));

        sessionService.execute(new SCMessage());
        sessionService.deleteSession();

      } else if (getMethodName() == "execute_messageData1MBArray_returnsTheSameMessageData") {
        SCSessionService sessionService = sc.newSessionService(TestConstants.pubServiceName1);
        SCMessage scMessage = new SCMessage();
        scMessage.setSessionInfo("sessionInfo");
        sessionService.createSession(10, scMessage, new TestSessionServiceMessageCallback(sessionService));

        SCMessage message = new SCMessage(new byte[TestConstants.dataLength1MB]);
        message.setCompressed(false);

        sessionService.execute(message);
        sessionService.deleteSession();

      }

    } catch (Exception e) {
      LOGGER.error("run", e);
    } finally {
      try {
        sc.detach();
      } catch (Exception e) {
        LOGGER.error("run", e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.cln.SCClient

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.