Package org.serviceconnector.api.cln

Examples of org.serviceconnector.api.cln.SCClient


   * Expectation: passes
   */
  @Test
  public void t32_cc_2Clients1Cache() throws Exception {
    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: load data to cache (cid=600) by client2
    request.setCacheId("600");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService2.execute(request);

    // 4: start cache guardian1 for client2 - do nothing
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk2);

    // 5: start cache guardian1 for client1 - publish 3 large appendix, cid=700
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    sessionClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 6: verify callback of client1 guardian1 retrieval - 3 appendix within 10sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);

    // 7: verify callback of client2 guardian1 retrieval - 3 appendix within 10sec
    cacheGuardianCbk2.waitForAppendMessage(3, 10);

    // 8: verify data (cid=600) is now in top level cache
    Map<String, String> inspectResponse = guardianClient.inspectCache("600");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "600", "0", "600/0/0=0&", "unset");

    // 9: verify data (cid=700) is now in top level cache
    inspectResponse = guardianClient.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
        "700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);

    // 10: change subscription for client2 different mask
    subMsg.setMask(TestConstants.mask1);
    subMsg.setSessionInfo(null);
    client2.changeCacheGuardian(subMsg);

    // 11: restart cache guardian of client1 - publish 3 large appendix, different mask
    sessionClient.stopCacheGuardian();
    subMsg.setData("600");
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
View Full Code Here


   * Expectation: passes
   */
  @Test
  public void t33_cc_2Clients2Server1Cache() throws Exception {
    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 - do nothing
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: start cache guardian2 - publish 3 large appendix
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian2, subMsg, cacheGuardianCbk2);

    // 5: verify callback of guardian2 retrieval - 3 appendix within 100sec
    cacheGuardianCbk2.waitForAppendMessage(3, 10);

    // 6: verify callback of guardian1 retrieval - nothing retrieved
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t34_cc_2Clients2Server1Cache() throws Exception {
    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 - publish 3 large appendix
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: start cache guardian2 - publish 3 large appendix
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian2, subMsg, cacheGuardianCbk2);

    // 5: verify callback of guardian1 retrieval - 3 appendix within 100sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);

    // 6: verify callback of guardian2 retrieval - 3 appendix within 100sec
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t34_cc_2Clients2Server1Cache30000Msgs() throws Exception {
    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk2);
   
    // 3: start cache guardian2 - publish 30000 appendices
    subMsg.setSessionInfo(TestConstants.publishAppendsWithDelayCmd);
    subMsg.setData("30000|0|700|" + SC_CACHING_METHOD.APPEND.getValue());
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);
View Full Code Here

   * @param port
   * @param connectionType
   * @return the created client
   */
  private SCClient newSCClient(String host, int port, ConnectionType connectionType) {
    SCClient client = new SCClient(host, port, connectionType);
    Assert.assertEquals("Host ", host, client.getHost());
    Assert.assertEquals("port ", port, client.getPort());
    Assert.assertEquals("Keep Alive Interval ", Constants.DEFAULT_KEEP_ALIVE_INTERVAL_SECONDS,
        client.getKeepAliveIntervalSeconds());
    Assert.assertEquals("Attached ", false, client.isAttached());
    Assert.assertEquals("max Connections ", Constants.DEFAULT_MAX_CONNECTION_POOL_SIZE, client.getMaxConnections());
    Assert.assertEquals("Connection Type ", connectionType, client.getConnectionType());
    Assert.assertNotNull("Client not created:", client);
    return client;
  }
View Full Code Here

   * Description: Attach and detach one time to SC on localhost, http-port and http-connection.<br>
   * Expectation: Client is detached.
   */
  @Test
  public void t01_attachDetach() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    Assert.assertEquals("Client is attached", false, client.isAttached());
    client.attach();
    Assert.assertEquals("Client is not attached", true, client.isAttached());
    client.detach();
    Assert.assertEquals("Client is attached", false, client.isAttached());
View Full Code Here

   * Description: Attach two times the same client to SC on localhost http-connection type.<br>
   * Expectation: Throws SCServiceException on the second attach.
   */
  @Test(expected = SCServiceException.class)
  public void t02_attachTwoTimes() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    client.attach();
    Assert.assertEquals("Client is not attached", true, client.isAttached());
    client.attach();
  }
View Full Code Here

   * Description: Detach the client without attach.<br>
   * Expectation: Client is detached.
   */
  @Test
  public void t03_detachNoAttach() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    Assert.assertEquals("Client is attached", false, client.isAttached());
    client.detach();
    Assert.assertEquals("Client is attached", false, client.isAttached());
  }
View Full Code Here

   * Description: first attach, then detach 100 times.<br>
   * Expectation: Client is detached.
   */
  @Test
  public void t04_attachDetach100times() throws Exception {
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_HTTP, ConnectionType.NETTY_HTTP);
    client.attach();
    Assert.assertEquals("Client is not attached", true, client.isAttached());
    int nr = 100;
    for (int i = 0; i < nr; i++) {
      client.detach();
View Full Code Here

      .getLogger(APINewServiceTest.class);

  @Before
  public void beforeOneTest() throws Exception {
    super.beforeOneTest();
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP,
        ConnectionType.NETTY_TCP);
    client.attach();
  }
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.