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

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


    log.info("TestSpecExampleOne::test_specexampleone");
    long dlen = 0;
    long clen = 0; /* contains a character array named input and an */
    int cd; /* integer named output. */
    /* allocate typed buffers */
    X_C_TYPE dptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
    X_C_TYPE cptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
    /* populate typed buffers with input data */
    dptr.setByteArray("input", "debit account 123 by 50".getBytes());
    cptr.setByteArray("input", "credit account 456 by 50".getBytes());
    // 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


  public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("debit_credit_svc");
    short rval;
    /* extract request typed buffer */
    X_C_TYPE dc_ptr = (X_C_TYPE) svcinfo.getBuffer();
    /*
     * Depending on service name used to invoke this routine, perform either
     * debit or credit work.
     */
    if (!svcinfo.getName().equals("DEBIT")) {
      /*
       * Parse input data and perform debit as part of global transaction.
       */
    } else {
      /*
       * Parse input data and perform credit as part of global
       * transaction.
       */
    }
    // TODO MAKE TWO TESTS
    if (dc_ptr.getInt("failTest") == 0) {
      rval = Connection.TPSUCCESS;
      dc_ptr.setInt("output", TestSpecExampleOne.OK);
    } else {
      rval = Connection.TPFAIL; /* global transaction will not commit */
      dc_ptr.setInt("output", TestSpecExampleOne.NOT_OK);
    }
    /* send reply and return from service routine */
    return new Response(rval, 0, dc_ptr, 0);
  }
View Full Code Here

  public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("inquiry_svc");
    short rval;
    /* extract initial typed buffer sent as part of tpconnect() */
    X_C_TYPE ptr = (X_C_TYPE) svcinfo.getBuffer();

    /*
     * Parse input string, ptr->input, and retrieve records. Return 10
     * records at a time to client. Records are placed in ptr->output, an
     * array of account records.
     */
    for (int i = 0; i < 5; i++) {
      /* gather from DBMS next 10 records into ptr->output array */
      svcinfo.getSession().tpsend(ptr, Connection.TPSIGRSTRT);
    }
    // TODO DO OK AND FAIL
    if (ptr.getInt("failTest") == 0) {
      rval = Connection.TPSUCCESS;
    } else {
      rval = Connection.TPFAIL; /* global transaction will not commit */
    }
    /* terminate service routine, send no data, and */
 
View Full Code Here

  }

  // 9.1.3
  public void test_tpalloc_x_c_type() throws ConnectionException {
    log.info("test_tpalloc_x_c_type");
    X_C_TYPE aptr;
    aptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "acct_info", 0);
    m_allocated = aptr;

    // ASSIGN SOME VALUES
    aptr.setLong("acct_no", 12345678);
    aptr.setByteArray("name",
        "12345678901234567890123456789012345678901234567890".getBytes());
    double[] balances = new double[2];
    balances[0] = 0;
    balances[1] = 0;
    aptr.setDoubleArray("balances", balances);

    // CHECK THE ASSIGNATIONS
    assertTrue(aptr.getLong("acct_no") == 12345678);
    assertTrue(Arrays
        .equals(aptr.getByteArray("name"),
            "12345678901234567890123456789012345678901234567890"
                .getBytes()));
    assertTrue(aptr.getByteArray("address") == null);
    assertTrue(aptr.getDoubleArray("balances")[0] == 0);
    assertTrue(aptr.getDoubleArray("balances")[1] == 0);
  }
View Full Code Here

  public void test_tpcall_x_c_type() throws ConnectionException {
    log.info("TestTPCall::test_tpcall_x_c_type");
    server.tpadvertisetpcallXCType();

    X_C_TYPE aptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "acct_info",
        0);

    aptr.setLong("acct_no", 12345678);
    aptr.setByteArray("name", "TOM".getBytes());

    float[] foo = new float[2];
    foo[0] = 1.1F;
    foo[1] = 2.2F;
    aptr.setFloatArray("foo", foo);

    double[] balances = new double[2];
    balances[0] = 1.1;
    balances[1] = 2.2;
    aptr.setDoubleArray("balances", balances);

    Response rcvbuf = connection.tpcall(
        RunServer.getServiceNametpcallXCType(), aptr,
        Connection.TPNOCHANGE);
    assertTrue(rcvbuf.getRcode() == 23);
View Full Code Here

    log.info("TestSpecExampleOne::test_specexampleone");
    long dlen = 0;
    long clen = 0; /* contains a character array named input and an */
    int cd; /* integer named output. */
    /* allocate typed buffers */
    X_C_TYPE dptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
    X_C_TYPE cptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
    /* populate typed buffers with input data */
    dptr.setByteArray("input", "debit account 123 by 50".getBytes());
    cptr.setByteArray("input", "credit account 456 by 50".getBytes());
    // 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

      .getLogger(TPCallXCTypeService.class);

  public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("test_tpcall_x_c_type_service");
    boolean ok = false;
    X_C_TYPE aptr = (X_C_TYPE) svcinfo.getBuffer();

    byte[] receivedName = new byte[3];
    byte[] charArray = aptr.getByteArray("name");
    System.arraycopy(charArray, 0, receivedName, 0, 3);
    byte[] expectedName = "TOM".getBytes();
    long accountNumber = aptr.getLong("acct_no");

    float fooOne = aptr.getFloatArray("foo")[0];
    float fooTwo = aptr.getFloatArray("foo")[1];

    double balanceOne = aptr.getDoubleArray("balances")[0];
    double balanceTwo = aptr.getDoubleArray("balances")[1];
    if (accountNumber == 12345678
        && Arrays.equals(receivedName, expectedName) && fooOne == 1.1F
        && fooTwo == 2.2F && balanceOne == 1.1 && balanceTwo == 2.2) {
      ok = true;
    }
View Full Code Here

  }

  // 9.1.3
  public void test_tpalloc_x_c_type() throws ConnectionException {
    log.info("test_tpalloc_x_c_type");
    X_C_TYPE aptr;
    aptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "acct_info", 0);
    m_allocated = aptr;

    // ASSIGN SOME VALUES
    aptr.setLong("acct_no", 12345678);
    aptr.setByteArray("name",
        "12345678901234567890123456789012345678901234567890".getBytes());
    double[] balances = new double[2];
    balances[0] = 0;
    balances[1] = 0;
    aptr.setDoubleArray("balances", balances);

    // CHECK THE ASSIGNATIONS
    assertTrue(aptr.getLong("acct_no") == 12345678);
    assertTrue(Arrays
        .equals(aptr.getByteArray("name"),
            "12345678901234567890123456789012345678901234567890"
                .getBytes()));
    assertTrue(aptr.getByteArray("address") == null);
    assertTrue(aptr.getDoubleArray("balances")[0] == 0);
    assertTrue(aptr.getDoubleArray("balances")[1] == 0);
  }
View Full Code Here

  public void test_tpcall_x_c_type() throws ConnectionException {
    log.info("TestTPCall::test_tpcall_x_c_type");
    server.tpadvertisetpcallXCType();

    X_C_TYPE aptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "acct_info",
        0);

    aptr.setLong("acct_no", 12345678);
    aptr.setByteArray("name", "TOM".getBytes());

    float[] foo = new float[2];
    foo[0] = 1.1F;
    foo[1] = 2.2F;
    aptr.setFloatArray("foo", foo);

    double[] balances = new double[2];
    balances[0] = 1.1;
    balances[1] = 2.2;
    aptr.setDoubleArray("balances", balances);

    Response rcvbuf = connection.tpcall(
        RunServer.getServiceNametpcallXCType(), aptr,
        Connection.TPNOCHANGE);
    assertTrue(rcvbuf.getRcode() == 23);
View Full Code Here

TOP

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

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.