Package org.jboss.narayana.blacktie.jatmibroker.xatmi

Examples of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response


    log.trace("Returning: " + resp);

    X_OCTET buffer = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET",
        null, resp.length() + 1);
    buffer.setByteArray(resp.getBytes());
    return new Response(Connection.TPSUCCESS, 0, buffer, 0);
  }
View Full Code Here


    int sendlen = command.length() + 1;
    X_OCTET sendbuf = (X_OCTET) connection
        .tpalloc("X_OCTET", null, sendlen);
    sendbuf.setByteArray(command.getBytes());

    Response buf = connection.tpcall(service, sendbuf, 0);
    assertTrue(buf != null);
    byte[] received = ((X_OCTET) buf.getBuffer()).getByteArray();
    assertTrue(received[0] == expect);

    return new String(received, 1, received.length - 1);
  }
View Full Code Here

      int sendlen = toSend.length() + 1;
      X_OCTET sendbuf = (X_OCTET) connection.tpalloc("X_OCTET", null,
          sendlen);
      sendbuf.setByteArray(toSend.getBytes());

      Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
          sendbuf, 0);
      fail("Expected TPETIME, got a buffer with rval: "
          + rcvbuf.getRval());
    } catch (ConnectionException e) {
      if (e.getTperrno() != Connection.TPETIME) {
        fail("Expected TPETIME, got: " + e.getTperrno());
      }
    }

    try {
      log.info("send second message");

      String toSend = "test_call_ttl_2";
      int sendlen = toSend.length() + 1;
      X_OCTET sendbuf = (X_OCTET) connection.tpalloc("X_OCTET", null,
          sendlen);
      sendbuf.setByteArray(toSend.getBytes());

      Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
          sendbuf, 0);
      fail("Expected TPETIME, got a buffer with rval: "
          + rcvbuf.getRval());
    } catch (ConnectionException e) {
      if (e.getTperrno() != Connection.TPETIME) {
        fail("Expected TPETIME, got: " + e.getTperrno());
      }
    }

    try {
      log.info("wait 30 second for first message process");
      Thread.sleep(30 * 1000);
      log.info("wait done");
    } catch (Exception e) {
      log.warn("sleep exception " + e);
    }

    String toSend = "counter";
    int sendlen = toSend.length() + 1;
    X_OCTET sendbuf = (X_OCTET) connection
        .tpalloc("X_OCTET", null, sendlen);
    sendbuf.setByteArray(toSend.getBytes());

    Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
        sendbuf, 0);

    assertTrue(rcvbuf != null);
    assertTrue(rcvbuf.getBuffer() != null);
    assertTrue(((X_OCTET) rcvbuf.getBuffer()).getByteArray() != null);
    byte[] received = ((X_OCTET) rcvbuf.getBuffer()).getByteArray();

    log.info("received length is " + received.length);
    String counter = new String(received);
    log.info("get message counter of TTL is " + counter);
    assertTrue(received[0] == '1');
View Full Code Here

  public void test() throws ConnectionException {
    log.info("AbstractBlacktieServiceTestCase::test");
    X_OCTET buffer = (X_OCTET) connection.tpalloc("X_OCTET", null, 4);
    buffer.setByteArray("echo".getBytes());

    Response response = connection.tpcall("EchoService", buffer, 0);
    String responseData = new String(
        ((X_OCTET) response.getBuffer()).getByteArray());
    assertEquals("echo", responseData);
  }
View Full Code Here

    // TODO tx_begin(); /* start global transaction */
    /* issue asynchronous request to DEBIT, while it is processing... */
    cd = connection.tpacall(RunServer.getServiceNameDEBIT(), dptr,
        Connection.TPSIGRSTRT);
    /* ...issue synchronous request to CREDIT */
    Response response = connection.tpcall(RunServer.getServiceNameCREDIT(),
        cptr, Connection.TPSIGRSTRT);
    cptr = (X_C_TYPE) response.getBuffer();
    clen = response.getBuffer().getLen();
    /* retrieve DEBIT�s reply */
    response = connection.tpgetrply(cd, Connection.TPSIGRSTRT);
    dptr = (X_C_TYPE) response.getBuffer();
    dlen = response.getBuffer().getLen();
    if (dptr.getInt("output") == OK && cptr.getInt("output") == OK) {
      // TODO tx_commit(); /* commit global transaction */
    } else {
      // TODO tx_rollback(); /* rollback global transaction */
    }
 
View Full Code Here

        sendbuf, 0);
    assertTrue(cd != -1);

    // RETRIEVE THE RESPONSE
    try {
      Response valToTest = connection.tpgetrply(cd, Connection.TPNOBLOCK);
      fail("Expected exception");
    } catch (ConnectionException e) {
      assertTrue(e.getTperrno() == Connection.TPEBLOCK);
      // DRAIN THE RESPONSE
      Response toTest = connection.tpgetrply(cd, 0);
      assertTrue(TestTPConversation.strcmp(toTest.getBuffer(),
          "test_tpgetrply_TPNOBLOCK") == 0);
    }
  }
View Full Code Here

    int cd = connection.tpacall(server.getServiceNameTPGetRplyTPNOBLOCK(),
        sendbuf, 0);
    assertTrue(cd != -1);

    // RETRIEVE THE RESPONSE
    Response toTest = connection.tpgetrply(cd, 0);
    assertTrue(TestTPConversation.strcmp(toTest.getBuffer(),
        "test_tpgetrply_TPNOBLOCK") == 0);
  }
View Full Code Here

    assertTrue(cd2 != -1);
    assertTrue(cd1 != cd2);

    // RETRIEVE THE RESPONSE
    int cdToGet = cd1;
    Response response = connection.tpgetrply(cdToGet, Connection.TPGETANY);
    assertTrue(response.getCd() == cd2);
    assertTrue(TestTPConversation.strcmp(response.getBuffer(),
        "test_tpgetrply_TPGETANY_two") == 0);
  }
View Full Code Here

    assertTrue(cd2 != -1);
    assertTrue(cd1 != cd2);

    // RETRIEVE THE RESPONSE
    int cdToGet = cd1;
    Response response = connection.tpgetrply(cdToGet, 0);
    assertTrue(response.getCd() == cd1);
    assertTrue(TestTPConversation.strcmp(response.getBuffer(),
        "test_tpgetrply_TPGETANY_one") == 0);
  }
View Full Code Here

    X_OCTET buffer = (X_OCTET) connection.tpalloc("X_OCTET", null,
        args.length);
    buffer.setByteArray(args);

    JABTransaction transaction = startTx();
    Response response = connection.tpcall("TxEchoService", buffer, 0);
    String responseData = new String(
        ((X_OCTET) response.getBuffer()).getByteArray());
    transaction.commit();
    assertEquals("test=test1,tx=true", responseData);
  }
View Full Code Here

TOP

Related Classes of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response

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.