Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCMessage


   * Description: screw up sessionId before message send<br>
   * Expectation: passes because sessionId is set internally again.
   */
  @Test
  public void t130_sessionId() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    request.setDataLength(TestConstants.pangram.length());
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    String sessionId = sessionService1.getSessionId();
    request.setMessageInfo(TestConstants.echoCmd);
    request.setSessionId("aaaa0000-bb11-cc22-dd33-eeeeee444444");
    sessionService1.send(request);
    msgCallback1.waitForMessage(10);
    response = msgCallback1.getResponse();
    Assert.assertEquals("sessionId is not the same", sessionId, response.getSessionId());
    Assert.assertEquals("message body is not the same length", request.getDataLength(), response.getDataLength());
    Assert.assertEquals("messageInfo is not the same", request.getMessageInfo(), response.getMessageInfo());
    Assert.assertEquals("compression is not the same", request.isCompressed(), response.isCompressed());
    sessionService1.deleteSession();
  }
View Full Code Here


   * Description: operation timeout expired during execution<br>
   * Expectation: passes, gets back a fault response
   */
  @Test
  public void t150_operationTimeout() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    request.setMessageInfo(TestConstants.sleepCmd);
    request.setData("5000"); // server will sleep 5000ms
View Full Code Here

   * Description: operation timeout expired during execution, catch exception and continue after a while<br>
   * Expectation: passes
   */
  @Test
  public void t151_operationTimeout() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    request.setMessageInfo(TestConstants.sleepCmd);
    request.setData("5000"); // server will sleep 5000ms
    sessionService1.send(3, request); // SC oti = 3*0.8*1000 = 2400ms => will return exception
    msgCallback1.waitForMessage(10); // will wait max 10 seconds for response
    response = msgCallback1.getResponse();
    Thread.sleep(4000); // wait 4000ms to allow server sleep request completion

    // second message
    messageReceived = false;
    request.setMessageInfo(TestConstants.echoCmd);
    request.setData("hallo"); // send second message
    request.setDataLength(((String) request.getData()).length());
    sessionService1.send(request);
    msgCallback1.waitForMessage(10); // will wait max 10 seconds for the second response
    response = msgCallback1.getResponse();
    Assert.assertEquals("message body is not the same length", request.getDataLength(), response.getDataLength());
    Assert.assertEquals("messageInfo is not the same", request.getMessageInfo(), response.getMessageInfo());
    Assert.assertEquals("compression is not the same", request.isCompressed(), response.isCompressed());
    sessionService1.deleteSession();
  }
View Full Code Here

   * Description: operation timeout expired during execution, catch exception and continue immediately<br>
   * Expectation: passes
   */
  @Test
  public void t152_operationTimeout() throws Exception {
    SCMessage request = new SCMessage(TestConstants.pangram);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    request.setMessageInfo(TestConstants.sleepCmd);
    request.setData("5000"); // server will sleep 5000ms
    sessionService1.send(3, request); // SC oti = 3*0.8*1000 = 2400ms => will return exception
    msgCallback1.waitForMessage(10); // will wait max 10 seconds for response
    response = msgCallback1.getResponse();

    // second message
    messageReceived = false;
    request.setMessageInfo(TestConstants.echoCmd);
    request.setData("gaga");
    request.setDataLength(((String) request.getData()).length());
    sessionService1.send(request);
    msgCallback1.waitForMessage(10); // will wait max 10 seconds for response
    response = msgCallback1.getResponse();
    Assert.assertEquals("message body is not the same length", request.getDataLength(), response.getDataLength());
    Assert.assertEquals("messageInfo is not the same", request.getMessageInfo(), response.getMessageInfo());
    Assert.assertEquals("compression is not the same", request.isCompressed(), response.isCompressed());

    // third message (synchronous)
    request.setData("abraka-dabra");
    request.setDataLength(((String) request.getData()).length());
    response = sessionService1.execute(request);
    Assert.assertEquals("message body is not the same length", request.getDataLength(), response.getDataLength());
    Assert.assertEquals("messageInfo is not the same", request.getMessageInfo(), response.getMessageInfo());
    Assert.assertEquals("compression is not the same", request.isCompressed(), response.isCompressed());
    sessionService1.deleteSession();
  }
View Full Code Here

   * Description: send 1 uncompressed 20MB message with Constants.MAX_MESSAGE_SIZE parts<br>
   * Expectation: passes
   */
  @Test
  public void t155_sendMessageMaxPartSize() throws Exception {
    SCMessage request = new SCMessage();

    String string10MB = TestUtil.get10MBString();
    StringBuilder sb = new StringBuilder();
    sb.append(string10MB);
    sb.append(string10MB);

    request.setData(sb.toString());
    request.setPartSize(Constants.MAX_MESSAGE_SIZE);
    request.setDataLength(sb.length());
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(new SCMessage(), msgCallback1);
    long startTime = System.currentTimeMillis();
    sessionService1.execute(request);
    System.out.println("Sent string " + sb.length() + " bytes long in " + (System.currentTimeMillis() - startTime) + " millis");
    response = msgCallback1.getResponse();
    sessionService1.deleteSession();
View Full Code Here

   * Description: send 1 uncompressed 20MB message 1MB parts<br>
   * Expectation: passes
   */
  @Test
  public void t156_sendMessage1MBPartSize() throws Exception {
    SCMessage request = new SCMessage();

    String string10MB = TestUtil.get10MBString();
    StringBuilder sb = new StringBuilder();
    sb.append(string10MB);
    sb.append(string10MB);

    request.setData(sb.toString());
    request.setPartSize(1048576);
    request.setDataLength(sb.length());
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(new SCMessage(), msgCallback1);
    long startTime = System.currentTimeMillis();
    sessionService1.execute(request);
    System.out.println("Sent string " + sb.length() + " bytes long in " + (System.currentTimeMillis() - startTime) + " millis");
    response = msgCallback1.getResponse();
    sessionService1.deleteSession();
View Full Code Here

   * Description: send 1 uncompressed 20MB message 100KB parts<br>
   * Expectation: passes
   */
  @Test
  public void t157_sendMessage100KBPartSize() throws Exception {
    SCMessage request = new SCMessage();

    String string10MB = TestUtil.get10MBString();
    StringBuilder sb = new StringBuilder();
    sb.append(string10MB);
    sb.append(string10MB);

    request.setData(sb.toString());
    request.setPartSize(102400);
    request.setDataLength(sb.length());
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(new SCMessage(), msgCallback1);
    long startTime = System.currentTimeMillis();
    sessionService1.execute(request);
    System.out.println("Sent string " + sb.length() + " bytes long in " + (System.currentTimeMillis() - startTime) + " millis");
    response = msgCallback1.getResponse();
    sessionService1.deleteSession();
View Full Code Here

  private SCMessage message;

  @Before
  public void beforeOneTest() throws Exception {
    super.beforeOneTest();
    message = new SCMessage();
  }
View Full Code Here

   * Description: send 1 uncompressed 20MB message 200KB parts<br>
   * Expectation: passes
   */
  @Test
  public void t157_sendMessage200KBPartSize() throws Exception {
    SCMessage request = new SCMessage();

    String string10MB = TestUtil.get10MBString();
    StringBuilder sb = new StringBuilder();
    sb.append(string10MB);
    sb.append(string10MB);

    request.setData(sb.toString());
    request.setPartSize(204800);
    request.setDataLength(sb.length());
    request.setCompressed(false);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(new SCMessage(), msgCallback1);
    long startTime = System.currentTimeMillis();
    sessionService1.execute(request);
    System.out.println("Sent string " + sb.length() + " bytes long in " + (System.currentTimeMillis() - startTime) + " millis");
    response = msgCallback1.getResponse();
    sessionService1.deleteSession();
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t158_executeLargeUncompressedLongerThanECI() throws Exception {
    // load message to cache
    SCMessage request = new SCMessage(TestConstants.pangram);
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    sessionService1.setEchoIntervalSeconds(10);
    response = sessionService1.createSession(request, msgCallback1);
    request.setMessageInfo(TestConstants.cacheCmd);
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.