Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCSubscribeMessage


    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

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

    // 3: verify callback retrieval - 3 appendixes within 10sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);
View Full Code Here


    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 for client1 - 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 guardian1 for client2 - publish 3 large appendix
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk2);

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

    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
    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: restart cache guardian of client1 - publish 3 large appendix, different mask
    sessionClient.stopCacheGuardian();
    subMsg.setData("600");
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    subMsg.setMask(TestConstants.mask1);
    sessionClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 11: verify callback of client1 guardian1 retrieval - 3 appendix within 10sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t01_subscribe() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertTrue("is not subscribed", publishService.isSubscribed());
    publishService.unsubscribe();
    Assert.assertNull("the session ID is not null", publishService.getSessionId());
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t16_subscribeAPPError() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.echoAppErrorCmd);
    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertEquals("appErrorCode is not the same", TestConstants.appErrorCode, subMsgResponse.getAppErrorCode());
    Assert.assertEquals("appErrorText is not the same", TestConstants.appErrorText, subMsgResponse.getAppErrorText());
    Assert.assertTrue("is not subscribed", publishService.isSubscribed());
    publishService.unsubscribe();
    Assert.assertNull("the session ID is not null", publishService.getSessionId());
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t17_subscribeSessionInfo() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    subMsgRequest.setMask(TestConstants.mask);
    String sessionInfo = "sessionInfoFromServer";
    subMsgRequest.setSessionInfo(sessionInfo);
    subMsgRequest.setNoDataIntervalSeconds(100);
    SCSubscribeMessage subMsgResponse = null;
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
    Assert.assertEquals("sessionInfo is not the same", sessionInfo, subMsgResponse.getSessionInfo());
    Assert.assertTrue("is not subscribed", publishService.isSubscribed());
    publishService.unsubscribe();
  }
View Full Code Here

   * Expectation: throws SCServiceException
   */
  @Test(expected = SCServiceException.class)
  public void t30_disabledService() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);

View Full Code Here

  @Test
  public void t40_twoSubscriptions() throws Exception {
    SCPublishService service1 = client.newPublishService(TestConstants.pubServiceName1);
    SCPublishService service2 = client.newPublishService(TestConstants.pubServiceName1);

    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(10);

    MsgCallback cbk1 = new MsgCallback(service1);
    MsgCallback cbk2 = new MsgCallback(service2);

    subMsgResponse = service1.subscribe(subMsgRequest, cbk1);
    Assert.assertNotNull("the session ID is null", service1.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertTrue("is not subscribed", service1.isSubscribed());

    subMsgResponse = service2.subscribe(subMsgRequest, cbk2);
    Assert.assertNotNull("the session ID is null", service2.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertTrue("is not subscribed", service2.isSubscribed());

    service1.unsubscribe();
    Assert.assertNull("the session ID is not null)", service1.getSessionId());
    service2.unsubscribe();
View Full Code Here

   * Expectation: throws SCServiceException
   */
  @Test(expected = SCServiceException.class)
  public void t41_subscribeTwice() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(10);
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
View Full Code Here

   * Expectation: throws SCServiceException
   */
  @Test(expected = SCServiceException.class)
  public void t50_reject() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.rejectCmd);
    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCSubscribeMessage

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.