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