use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class CoordinatorTest method testListTransactions.
/*
* Note: TxSupport methods throw exceptions if unexpected status codes are returned.
* use the TxSupport.httpRequest(...) if you want to specify other status codes
*/
// list transactions
@Test
public void testListTransactions() throws IOException {
TxSupport[] txns = { new TxSupport(), new TxSupport() };
int txnCount = new TxSupport().txCount();
for (TxSupport txn : txns) txn.startTx();
// there should be txns.length more transactions
Assert.assertEquals(txnCount + txns.length, txns[0].txCount());
for (TxSupport txn : txns) txn.commitTx();
// the number of transactions should be back to the original number
Assert.assertEquals(txnCount, txns[0].txCount());
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class LoggingRestATResource method headParticipant.
/**
* Returns links to the participant terminator.
*
* @return Link to the participant terminator.
*/
@HEAD
public Response headParticipant(@Context UriInfo uriInfo) {
LOG.info("LoggingRestATResource.headParticipant()");
invocations.add("LoggingRestATResource.headParticipant()");
String serviceURL = uriInfo.getBaseUri() + uriInfo.getPath();
String linkHeader = new TxSupport().makeTwoPhaseAwareParticipantLinkHeader(serviceURL, false, null, null);
return Response.ok().header("Link", linkHeader).build();
}
use of org.jboss.jbossts.star.util.TxSupport in project wildfly by wildfly.
the class CoordinatorTestCase method testTimeoutCleanup.
@Test
public void testTimeoutCleanup() throws InterruptedException {
TxSupport txn = new TxSupport();
int txnCount = txn.txCount();
txn.startTx(1000);
txn.enlistTestResource(getDeploymentUrl() + WorkRestATResource.PATH_SEGMENT, false);
// Let the txn timeout
Thread.sleep(2000);
Assert.assertEquals(txnCount, txn.txCount());
}
use of org.jboss.jbossts.star.util.TxSupport in project wildfly by wildfly.
the class AbstractTestCase method before.
@Before
public void before() {
TxSupport.setTxnMgrUrl(getBaseUrl() + "/rest-at-coordinator/tx/transaction-manager");
txSupport = new TxSupport();
}
use of org.jboss.jbossts.star.util.TxSupport in project narayana by jbosstm.
the class Transaction method beforeCompletion.
@Override
protected boolean beforeCompletion() {
boolean commit = true;
for (String uri : volatileParticipants) {
try {
new TxSupport().httpRequest(new int[] { HttpURLConnection.HTTP_OK }, uri, "PUT", null);
} catch (HttpResponseException e) {
commit = false;
if (log.isDebugEnabled())
log.debugf(e, "volatile participant %s error %s during beforeCompletion", uri, e.getMessage());
}
}
if (!super.beforeCompletion())
commit = false;
// Get a list of the participants before they check-out of the transaction
enlistmentIds = new ArrayList<String>();
getParticipants(enlistmentIds);
return commit;
}
Aggregations