Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCSubscribeMessage


   * Expectation: passes
   */
  @Test
  public void t03_receive() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    SCSubscribeMessage subMsgResponse = null;
    msgCallback = new MsgCallback(publishService);
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.publishMsgWithDelayCmd);
    int nrMessages = 5;
    String waitMillis = "1000";
    subMsgRequest.setData(nrMessages + "|" + waitMillis);
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
    msgCallback.setExpectedMessages(nrMessages);
    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());

    msgCallback.waitForMessage(5);
    Assert.assertEquals("Nr messages does not match", nrMessages, msgCallback.getMessageCount());
    SCMessage response = msgCallback.getMessage();
View Full Code Here


   * Expectation: passes (catch exception while waiting for message)
   */
  @Test
  public void t04_receiveNoMatch() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    SCSubscribeMessage subMsgResponse = null;
    msgCallback = new MsgCallback(publishService);
    // wrong mask
    subMsgRequest.setMask(TestConstants.mask1);
    subMsgRequest.setSessionInfo(TestConstants.publishCompressedMsgCmd);
    int nrMessages = 200;
    subMsgRequest.setData(Integer.toString(nrMessages));
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
    msgCallback.setExpectedMessages(nrMessages);
    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());

    try {
      msgCallback.waitForMessage(2);
      Assert.fail("TimeoutException should have been thrown!");
View Full Code Here

    MsgCallback cbk1 = new MsgCallback(service1);
    cbk1.setExpectedMessages(nrMessages);
    MsgCallback cbk2 = new MsgCallback(service2);
    cbk2.setExpectedMessages(nrMessages);

    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setData(Integer.toString(nrMessages));
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());

    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());

    subMsgRequest.setSessionInfo(TestConstants.publishCompressedMsgCmd);
    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());

    cbk1.waitForMessage(200);
    Assert.assertEquals("Nr messages does not match", nrMessages, cbk1.getMessageCount());
    SCMessage response = cbk1.getMessage();
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t11_receive() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    msgCallback = new MsgCallback(publishService);
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.publishMsgWithDelayCmd);
    int nrMessages = 2;
    String waitMillis = "124000";
    subMsgRequest.setData(nrMessages + "|" + waitMillis);
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
    subMsgRequest.setNoDataIntervalSeconds(63);
    msgCallback.setExpectedMessages(nrMessages);
    publishService.subscribe(subMsgRequest, msgCallback);
    msgCallback.waitForMessage(124000);
    Assert.assertEquals("Nr messages does not match", nrMessages, msgCallback.getMessageCount());
    msgCallback.getMessage();
View Full Code Here

    // look up srvService
    SrvPublishService srvService = this.getSrvPublishServiceByServiceName(serviceName);

    String sessionId = reqMessage.getSessionId();
    // create scMessage
    SCSubscribeMessage scMessage = new SCSubscribeMessage();
    scMessage.setData(reqMessage.getBody());
    scMessage.setDataLength(reqMessage.getBodyLength());
    scMessage.setCompressed(reqMessage.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    scMessage.setMessageInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
    scMessage.setSessionInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    scMessage.setSessionId(sessionId);
    scMessage.setMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK));
    scMessage.setServiceName(reqMessage.getServiceName());
    int oti = Integer.parseInt(reqMessage.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT));

    // inform callback with scMessages
    SCMessage scReply = srvService.getCallback().subscribe(scMessage, oti);
View Full Code Here

  public void t01_() throws Exception {
    SCSessionService sessService = client.newSessionService(TestConstants.sesServerName1);
    SCMessage scMessage = new SCMessage();
    sessService.createSession(scMessage, new TestSessionServiceMessageCallback(sessService));
    SCPublishService pubService = client.newPublishService(TestConstants.pubServerName1);
    SCSubscribeMessage scSubscribeMessage = new SCSubscribeMessage();
    scSubscribeMessage.setMask(TestConstants.mask);
    pubService.subscribe(scSubscribeMessage, new TestPublishServiceMessageCallback(pubService));

    SCPublishService pubService1 = client.newPublishService(TestConstants.pubServiceName1);
    scSubscribeMessage.setNoDataIntervalSeconds(40);
    pubService1.subscribe(scSubscribeMessage, new TestPublishServiceMessageCallback(pubService1));

    System.out.println("APISessionSubscriptionTest.t01_()");

    try {
View Full Code Here

      // connects to SC, checks connection to SC
      sc.attach();

      publishServiceA = sc.newPublishService("publish-1");
      SCMessageCallback callback = new TestPublishCallback(publishServiceA);
      SCSubscribeMessage subscibeMessage = new SCSubscribeMessage();
      subscibeMessage.setMask("000012100012832102FADF-----------X-----------");
      subscibeMessage.setSessionInfo("sessionInfo");
      publishServiceA.subscribe(subscibeMessage, callback);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
View Full Code Here

    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();
View Full Code Here

    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);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

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

    // 5: verify callback of client2 guardian1A retrieval - 3 appendix within 10sec
    cacheGuardianCbk2.waitForAppendMessage(3, 10);
View Full Code Here

    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);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.publish1LargeInitialMsgCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: verify callback of client1 guardian1 retrieval - 1 large initial message within 10sec
    cacheGuardianCbk.waitForMessage(1, 10);

    // 5: start cache guardian1A of client2 - publish 1 large initial
    subMsg.setSessionInfo(TestConstants.publish1LargeInitialMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1A, subMsg, cacheGuardianCbk2);

    // 6: verify callback of client2 guardian1A retrieval - 1 large initial message within 10sec
    cacheGuardianCbk2.waitForMessage(1, 10);
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.