Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCMessage


   * Description: client has session and gets notified after SC was aborted<br>
   * Expectation: passes
   */
  @Test
  public void t01_notifyClientAfterSCcrash() throws Exception {
    SCMessage request = new SCMessage();
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    sessionService1.setEchoIntervalSeconds(10); // want be notified quickly!
    response = sessionService1.createSession(request, msgCallback1);
    Assert.assertNotNull("the session ID is null", sessionService1.getSessionId());
View Full Code Here


   * cacheId<br>
   * Expectation: passes
   */
  @Test
  public void t02_testCacheStateAfterStoppingLoadingClient() throws Exception {
    SCMessage request = new SCMessage();
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);

    SCMessage message = new SCMessage();
    message.setMessageInfo(TestConstants.cacheCmd);
    message.setData("cache50MBStringFor1Hour");
    message.setCacheId("700");
    sessionService1.send(message);
    // stop test server now, session on SC gets deleted
    ctrl.stopServer(srvCtxs.get(TestConstants.sesServerName1));
    ctrl.startServer(TestConstants.COMMUNICATOR_TYPE_SESSION, TestConstants.log4jSrvProperties, TestConstants.sesServerName1,
        TestConstants.PORT_SES_SRV_TCP, TestConstants.PORT_SC0_TCP, 100, 10, TestConstants.sesServiceName1);

    SCSessionService sessionService2 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService2);
    sessionService2.createSession(request, msgCallback1);
    message = new SCMessage();
    message.setMessageInfo(TestConstants.cacheCmd);
    message.setData("cache10MBStringFor1Hour");
    message.setCacheId("700");

    response = null;
    while (response == null) {
      try {
        response = sessionService2.execute(message);
View Full Code Here

    SCClient clientToSc0 = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    clientToSc0.attach();
    SCSessionService sessionSrvToSC0 = clientToSc0.newSessionService(TestConstants.sesServiceName1);

    // 3: load data to cache (cid=700) on SC0
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionSrvToSC0.createSession(new SCMessage(), new SessionMsgCallback(sessionSrvToSC0));
    sessionSrvToSC0.execute(request);

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

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

    // 6: verify data is in cache on SC0
    Map<String, String> inspectResponse = clientToSc0.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);

    // 7: start cache guardian over top level (cascaded) SC - doing nothing
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 8: stop cache guardian over SC0 - cached managed data should stay
    clientToSc0.stopCacheGuardian();

    // 9: verify data is still in cache on SC0
    inspectResponse = clientToSc0.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: verify data is NOT in top level cache
    inspectResponse = this.mgmtClient.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "notfound", SC_CACHE_ENTRY_STATE.UNDEFINDED, "700", "", "", "");

    // 11: reconnect client to top level (cascaded) SC - read data from cache
    this.sessionClient.attach();
    sessionService1 = sessionClient.newSessionService(TestConstants.sesServiceName1);
    sessionService1.createSession(new SCMessage(), new SessionMsgCallback(sessionService1));
    SCMessage response = sessionService1.execute(request);

    // 12: verify data is correct
    this.checkAppendices(response, 3);

    // 13: verify data is now in top level cache
View Full Code Here

   * Description: create session after SC was aborted<br>
   * Expectation: throws SCMPValidatorException
   */
  @Test(expected = SCMPValidatorException.class)
  public void t01_createSession() throws Exception {
    SCMessage request = null;
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);

    ctrl.stopServer(srvCtxs.get(TestConstants.sesServerName1)); // stop test server now, it cannot be stopped without SC later
    ctrl.stopSC(scCtxs.get(TestConstants.SC0));

View Full Code Here

   * Description: exchange message after SC was aborted<br>
   * Expectation: throws SCServiceException
   */
  @Test(expected = SCServiceException.class)
  public void t02_execute() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);

    ctrl.stopServer(srvCtxs.get(TestConstants.sesServerName1)); // stop test server now, it cannot be stopped without SC later
View Full Code Here

    // 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 of client1 - do nothing
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
View Full Code Here

   * Description: send message after SC was aborted<br>
   * Expectation: throws SCServiceException
   */
  @Test(expected = SCServiceException.class)
  public void t03_send() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    request.setMessageInfo(TestConstants.echoCmd);
    messageReceived = false;
View Full Code Here

   * Description: delete session after SC was aborted<br>
   * Expectation: throws SCMPValidatorException
   */
  @Test(expected = SCMPValidatorException.class)
  public void t04_deleteSession() throws Exception {
    SCMessage request = null;
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);

    ctrl.stopServer(srvCtxs.get(TestConstants.sesServerName1)); // stop test server now, it cannot be stopped without SC later
View Full Code Here

   * Description: create session after server was aborted<br>
   * Expectation: throws SCMPValidatorException
   */
  @Test(expected = SCMPValidatorException.class)
  public void t30_createSession() throws Exception {
    SCMessage request = null;
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);

    ctrl.stopServer(srvCtxs.get(TestConstants.sesServerName1));

    msgCallback1 = new MsgCallback(sessionService1);
View Full Code Here

    // 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 of client1 - publish 1 large initial
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCMessage

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.