use of com.arjuna.wst.TransactionRolledBackException in project narayana by jbosstm.
the class Sc007TestCase method test3_1.
/**
* test3_1 - 3.1 Phase2Rollback
* Coordinator aborts the transaction due to an Aborted vote during the prepare phase.
* @throws Exception on failure.
*/
public void test3_1() throws Exception {
final String conversationId = getConversationId();
final InteropWaitState state = new InteropWaitState(AtomicTransactionConstants.WSAT_ACTION_ABORTED, 2);
ProxyConversation.setConversationState(conversationId, state);
try {
final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
final CoordinationContextType context = InteropUtil.createCoordinationContext(getSourceCoordinatorURI());
getParticipantStub().phase2Rollback(serviceURI, context);
final CompletionCoordinatorParticipant participant = InteropUtil.registerCompletion(context, context.getIdentifier().getValue());
participant.commit();
fail("Transaction rollback expected");
} catch (final TransactionRolledBackException trbe) {
state.waitForCompletion(0);
} finally {
ProxyConversation.clearConversationState(conversationId);
}
assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
use of com.arjuna.wst.TransactionRolledBackException in project narayana by jbosstm.
the class Sc007TestCase method test3_8.
/**
* test3_8 - 3.8 RetryPreparedAbort
* Tests recovery from a communication failure during the prepare phase. Transaction times out.
* @throws Exception on failure.
*/
public void test3_8() throws Exception {
final String conversationId = getConversationId();
final Sc007RetryPreparedAbortState state = new Sc007RetryPreparedAbortState();
ProxyConversation.setConversationState(conversationId, state);
try {
final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
final CoordinationContextType context = InteropUtil.createCoordinationContext(getSourceCoordinatorURI());
getParticipantStub().retryPreparedAbort(serviceURI, context);
final CompletionCoordinatorParticipant participant = InteropUtil.registerCompletion(context, context.getIdentifier().getValue());
participant.commit();
fail("Transaction rollback expected");
} catch (final TransactionRolledBackException trbe) {
state.waitForCompletion(getTestTimeout());
} finally {
ProxyConversation.clearConversationState(conversationId);
}
assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
use of com.arjuna.wst.TransactionRolledBackException in project narayana by jbosstm.
the class Sc007TestCase method test3_10.
/**
* test3_10 - 3.10 PreparedAfterTimeout
* Tests recovery from a communication failure during the prepare phase. Transaction times out. Two participants, volatile and durable.
* @throws Exception on failure.
*/
public void test3_10() throws Exception {
final String conversationId = getConversationId();
final Sc007PreparedAfterTimeoutState state = new Sc007PreparedAfterTimeoutState();
ProxyConversation.setConversationState(conversationId, state);
try {
final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
final CoordinationContextType context = InteropUtil.createCoordinationContext(getSourceCoordinatorURI());
getParticipantStub().preparedAfterTimeout(serviceURI, context);
final CompletionCoordinatorParticipant participant = InteropUtil.registerCompletion(context, context.getIdentifier().getValue());
participant.commit();
fail("Transaction rollback expected");
} catch (final TransactionRolledBackException trbe) {
state.waitForCompletion(getTestTimeout());
} finally {
ProxyConversation.clearConversationState(conversationId);
}
assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
use of com.arjuna.wst.TransactionRolledBackException in project narayana by jbosstm.
the class MultiParticipantPrepareAndCommitTest method run.
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
String serviceURL1;
serviceURL1 = System.getProperty(XTSServiceTest.SERVICE_URL1_KEY);
if (serviceURL1 == null) {
serviceURL1 = "http://localhost:8080/xtstest/xtsservicetest1";
}
addDefaultBinding("service1", serviceURL1);
UserTransaction tx = UserTransactionFactory.userTransaction();
try {
tx.begin();
} catch (WrongStateException e) {
exception = e;
} catch (SystemException e) {
exception = e;
}
if (exception != null) {
error("txbegin failure " + exception);
return;
}
List<String> commands = new ArrayList<String>();
List<String> results = new ArrayList<String>();
commands.add("block");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistDurable");
commands.add("prepare");
commands.add("commit");
commands.add("next");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistDurable");
commands.add("prepare");
commands.add("commit");
commands.add("next");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistDurable");
commands.add("prepare");
commands.add("commit");
commands.add("endblock");
try {
processCommands(commands, results);
} catch (Exception e) {
exception = e;
}
if (exception != null) {
error("test failure " + exception);
return;
}
try {
tx.commit();
} catch (TransactionRolledBackException e) {
exception = e;
} catch (UnknownTransactionException e) {
exception = e;
} catch (SystemException e) {
exception = e;
} catch (WrongStateException e) {
exception = e;
}
if (exception != null) {
error("commit failure " + exception);
}
message("completed");
isSuccessful = (exception == null);
}
use of com.arjuna.wst.TransactionRolledBackException in project narayana by jbosstm.
the class MultiParticipantCoordinatorCompletionParticipantCloseAndExitTest method run.
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
String serviceURL1;
serviceURL1 = System.getProperty(XTSServiceTest.SERVICE_URL1_KEY);
if (serviceURL1 == null) {
serviceURL1 = "http://localhost:8080/xtstest/xtsservicetest1";
}
addDefaultBinding("service1", serviceURL1);
UserBusinessActivity ba = UserBusinessActivityFactory.userBusinessActivity();
try {
ba.begin();
} catch (WrongStateException e) {
exception = e;
} catch (SystemException e) {
exception = e;
}
if (exception != null) {
error("txbegin failure " + exception);
return;
}
List<String> resultsList;
String participantId;
List<String> commands = new ArrayList<String>();
List<String> results = new ArrayList<String>();
commands.add("block");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistCoordinatorCompletion");
commands.add("bindings");
commands.add("bind");
commands.add("P1");
commands.add("0");
commands.add("next");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistCoordinatorCompletion");
commands.add("complete");
commands.add("close");
commands.add("next");
commands.add("serve");
commands.add("{service1}");
commands.add("enlistCoordinatorCompletion");
commands.add("complete");
commands.add("close");
commands.add("next");
commands.add("serve");
commands.add("{service1}");
commands.add("exit");
commands.add("{P1}");
commands.add("endblock");
try {
processCommands(commands, results);
} catch (Exception e) {
exception = e;
}
if (exception != null) {
error("test failure " + exception);
return;
}
try {
ba.close();
} catch (TransactionRolledBackException e) {
exception = e;
} catch (UnknownTransactionException e) {
exception = e;
} catch (SystemException e) {
exception = e;
} catch (WrongStateException e) {
exception = e;
}
if (exception != null) {
error("commit failure " + exception);
}
message("completed");
isSuccessful = (exception == null);
}
Aggregations