Package org.serviceconnector

Examples of org.serviceconnector.TestCallback


  @Test
  public void t52_LargeRequestSmallResponseCompressed() throws Exception {
    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    String largeString = TestUtil.getLargeString();
    clnExecuteCall.setRequestBody(largeString);
    TestCallback cbk = new TestCallback();
    clnExecuteCall.invoke(cbk, 3000);
    SCMPMessage scmpReply = cbk.getMessageSync(3000);
    Assert.assertNotNull(scmpReply.getSessionId());
    Assert.assertEquals(0, scmpReply.getBodyLength());
    Assert.assertEquals(null, scmpReply.getBody());
  }
View Full Code Here


  public void t53_LargeRequestLargeResponseCompressed() throws Exception {
    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    String largeString = TestUtil.getLargeString();
    clnExecuteCall.setMessageInfo(TestConstants.largeResponseCmd);
    clnExecuteCall.setRequestBody(largeString);
    TestCallback cbk = new TestCallback();
    clnExecuteCall.invoke(cbk, 3000);
    SCMPMessage scmpReply = cbk.getMessageSync(3000);
    Assert.assertEquals(largeString.length() + "", scmpReply.getBodyLength() + "");
    Assert.assertEquals(largeString, scmpReply.getBody());
    Assert.assertEquals(SCMPBodyType.TEXT.getValue(), scmpReply.getHeader(SCMPHeaderAttributeKey.BODY_TYPE));
    Assert.assertEquals(SCMPMsgType.CLN_EXECUTE.getValue(), scmpReply.getMessageType());
    String serviceName = clnExecuteCall.getRequest().getServiceName();
View Full Code Here

    // reserve connection 1 with standard session
    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("3000");
    TestCallback cbk = new TestCallback();
    clnExecuteCall.invoke(cbk, 10000);

    // create another session2
    SCMPClnCreateSessionCall createSessionCall = new SCMPClnCreateSessionCall(this.requester, TestConstants.sesServerName1);
    createSessionCall.setSessionInfo("sessionInfo");
    createSessionCall.setEchoIntervalSeconds(3600);
    TestCallback cbk2 = new TestCallback();
    createSessionCall.invoke(cbk2, 3000);
    SCMPMessage resp = cbk2.getMessageSync(3000);
    String sessionId2 = resp.getSessionId();

    // create another session3
    createSessionCall = new SCMPClnCreateSessionCall(this.requester, TestConstants.sesServerName1);
    createSessionCall.setSessionInfo("sessionInfo");
    createSessionCall.setEchoIntervalSeconds(3600);
    TestCallback cbk3 = new TestCallback();
    createSessionCall.invoke(cbk3, 3000);
    resp = cbk3.getMessageSync(3000);
    String sessionId3 = resp.getSessionId();

    // reserve connection 2 with session2
    clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, sessionId3);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("3000");
    TestCallback cbk4 = new TestCallback();
    clnExecuteCall.invoke(cbk4, 10000);

    // to assure second create is not faster
    Thread.sleep(20);
    // try to get a third connection with a third session - should not work
    clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, sessionId2);
    TestCallback cbk5 = new TestCallback();
    clnExecuteCall.invoke(cbk5, 2000);

    SCMPMessage reply = cbk4.getMessageSync(4000);
    SCMPMessage reply1 = cbk5.getMessageSync(4000);

    TestUtil.checkReply(reply);
    Assert.assertTrue(reply1.isFault());
    TestUtil.verifyError(reply1, SCMPError.NO_FREE_CONNECTION, SCMPMsgType.CLN_EXECUTE);
  }
View Full Code Here

  public void t71_LoopsForFreeConnectionAndWorksFineAfter() throws Exception {
    // reserve connection 1 with standard session
    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("3000");
    TestCallback cbk = new TestCallback();
    clnExecuteCall.invoke(cbk, 10000);

    // create another session2
    SCMPClnCreateSessionCall createSessionCall = new SCMPClnCreateSessionCall(this.requester, TestConstants.sesServerName1);
    createSessionCall.setSessionInfo("sessionInfo");
    createSessionCall.setEchoIntervalSeconds(3600);
    TestCallback cbk2 = new TestCallback();
    createSessionCall.invoke(cbk2, 3000);
    SCMPMessage resp = cbk2.getMessageSync(3000);
    String sessionId2 = resp.getSessionId();

    // create another session3
    createSessionCall = new SCMPClnCreateSessionCall(this.requester, TestConstants.sesServerName1);
    createSessionCall.setSessionInfo("sessionInfo");
    createSessionCall.setEchoIntervalSeconds(3600);
    TestCallback cbk3 = new TestCallback();
    createSessionCall.invoke(cbk3, 3000);
    resp = cbk3.getMessageSync(3000);
    String sessionId3 = resp.getSessionId();

    // reserve connection 2 with session2
    clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, sessionId3);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("3000");
    TestCallback cbk4 = new TestCallback();
    clnExecuteCall.invoke(cbk4, 10000);

    // to assure second create is not faster
    Thread.sleep(20);
    // try to get a third connection with a third session - should work with the wait mec for free connections
    clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, sessionId2);
    TestCallback cbk5 = new TestCallback();
    clnExecuteCall.invoke(cbk5, 7000);

    SCMPMessage reply = cbk4.getMessageSync(4000);
    SCMPMessage reply1 = cbk5.getMessageSync(7000);

    TestUtil.checkReply(reply);
    TestUtil.checkReply(reply1);
    Assert.assertEquals(SCMPMsgType.CLN_EXECUTE.getValue(), reply1.getMessageType());
    Assert.assertEquals(SCMPMsgType.CLN_EXECUTE.getValue(), reply.getMessageType());
View Full Code Here

  @Test
  public void t80_OTITimesOut() throws Exception {
    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("2000");
    TestCallback cbk = new TestCallback();
    clnExecuteCall.invoke(cbk, 2000);
    SCMPMessage responseMessage = cbk.getMessageSync(2000);
    TestUtil.verifyError(responseMessage, SCMPError.OPERATION_TIMEOUT, SCMPMsgType.CLN_EXECUTE);
  }
View Full Code Here

  public void t81_PendingRequestError() throws Exception {

    SCMPClnExecuteCall clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    clnExecuteCall.setMessageInfo(TestConstants.sleepCmd);
    clnExecuteCall.setRequestBody("3000");
    TestCallback cbk2 = new TestCallback();
    clnExecuteCall.invoke(cbk2, 10000);

    // to assure second create is not faster
    Thread.sleep(20);
    clnExecuteCall = new SCMPClnExecuteCall(this.requester, TestConstants.sesServerName1, this.sessionId);
    TestCallback cbk1 = new TestCallback();
    clnExecuteCall.invoke(cbk1, 2000);

    SCMPMessage reply = cbk2.getMessageSync(4000);
    SCMPMessage reply1 = cbk1.getMessageSync(4000);

    TestUtil.checkReply(reply);
    Assert.assertTrue(reply1.isFault());
    TestUtil.verifyError(reply1, SCMPError.PARALLEL_REQUEST, SCMPMsgType.CLN_EXECUTE);
  }
View Full Code Here

   */
  protected void createSession() throws Exception {
    SCMPClnCreateSessionCall createSessionCall = new SCMPClnCreateSessionCall(this.requester, TestConstants.sesServerName1);
    createSessionCall.setSessionInfo("sessionInfo");
    createSessionCall.setEchoIntervalSeconds(3600);
    TestCallback cbk = new TestCallback();
    createSessionCall.invoke(cbk, 3000);
    SCMPMessage resp = cbk.getMessageSync(3000);
    this.sessionId = resp.getSessionId();
  }
View Full Code Here

   *             the exception
   */
  private void deleteSession() throws Exception {
    SCMPClnDeleteSessionCall deleteSessionCall = new SCMPClnDeleteSessionCall(this.requester, TestConstants.sesServerName1,
        this.sessionId);
    TestCallback cbk = new TestCallback();
    deleteSessionCall.invoke(cbk, 3000);
    cbk.getMessageSync(3000);
  }
View Full Code Here

    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 10000; i++) {
      IConnection connection = connectionPool.getConnection();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      cbk.getMessageSync(1000);
      connectionPool.freeConnection(connection);
      if ((i + 1) % 5000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
    }
View Full Code Here

    for (int i = 0; i < 10000; i++) {
      ConnectionPool cp = new ConnectionPool(TestConstants.HOST, this.port, this.connectionType.getValue(),
          this.keepAliveSeconds, this.keepAliveOTIMillis);
      IConnection connection = cp.getConnection();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      cbk.getMessageSync(1000);
      cp.freeConnection(connection);
      cp.destroy();
      if ((i + 1) % 5000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
View Full Code Here

TOP

Related Classes of org.serviceconnector.TestCallback

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.