Search in sources :

Example 1 with InteropWaitState

use of com.jboss.transaction.txinterop.interop.states.InteropWaitState in project narayana by jbosstm.

the class ATTestCase method testAT3_1.

/**
 * testAT3_1 - 3.1 Phase2Rollback
 * Coordinator aborts the transaction due to an Aborted vote during the prepare phase.
 * @throws Exception on failure.
 */
public void testAT3_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 = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().phase2Rollback(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.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());
}
Also used : TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Example 2 with InteropWaitState

use of com.jboss.transaction.txinterop.interop.states.InteropWaitState in project narayana by jbosstm.

the class ATTestCase method testAT3_2.

/**
 * testAT3_2 - 3.2 Readonly
 * Tests coordinator committing a transaction with a read only participant.
 * @throws Exception on failure.
 */
public void testAT3_2() throws Exception {
    final String conversationId = getConversationId();
    final InteropWaitState state = new InteropWaitState(AtomicTransactionConstants.WSAT_ACTION_COMMITTED);
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().readonly(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.registerCompletion(context, context.getIdentifier().getValue());
        participant.commit();
        state.waitForCompletion(0);
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Example 3 with InteropWaitState

use of com.jboss.transaction.txinterop.interop.states.InteropWaitState in project narayana by jbosstm.

the class ATTestCase method testAT5_4.

/**
 * testAT5_4 - 5.4 RetryCommit
 * Tests recovery from a communication failure during the commit phase. Transaction commits normally.
 * @throws Exception on failure.
 */
public void testAT5_4() throws Exception {
    final String conversationId = getConversationId();
    final InteropWaitState state = new InteropWaitState(AtomicTransactionConstants.WSAT_ACTION_COMMITTED);
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().retryCommit(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.registerCompletion(context, context.getIdentifier().getValue());
        participant.commit();
        state.waitForCompletion(0);
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Example 4 with InteropWaitState

use of com.jboss.transaction.txinterop.interop.states.InteropWaitState in project narayana by jbosstm.

the class ATTestCase method testAT2_2.

/**
 * testAT2_2 - 2.2 Rollback
 * Participant registers for Durable2PC, initiator rolls back.
 * @throws Exception on failure.
 */
public void testAT2_2() throws Exception {
    final String conversationId = getConversationId();
    final InteropWaitState state = new InteropWaitState(AtomicTransactionConstants.WSAT_ACTION_ABORTED);
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = ATInteropUtil.createCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().rollback(serviceURI, context);
        final CompletionCoordinatorParticipant participant = ATInteropUtil.registerCompletion(context, context.getIdentifier().getValue());
        participant.rollback();
        state.waitForCompletion(0);
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CompletionCoordinatorParticipant(com.arjuna.wst.CompletionCoordinatorParticipant)

Example 5 with InteropWaitState

use of com.jboss.transaction.txinterop.interop.states.InteropWaitState in project narayana by jbosstm.

the class BATestCase method testBA1_6.

/**
 * testBA1_6 - 1.6 CoordinatorCompleteClose
 * The PA successfully completes its work on behalf of the activity and the activity is closed.
 * @throws Exception on failure.
 */
public void testBA1_6() throws Exception {
    final String conversationId = getConversationId();
    final InteropWaitState state = new InteropWaitState(BusinessActivityConstants.WSBA_ACTION_CLOSED);
    ProxyConversation.setConversationState(conversationId, state);
    try {
        final String serviceURI = ProxyURIRewriting.rewriteURI(conversationId, getParticipantURI());
        final CoordinationContextType context = BAInteropUtil.createAtomicOutcomeCoordinationContext(getSourceCoordinatorURI());
        getParticipantStub().coordinatorCompleteClose(serviceURI, context);
        final BusinessActivityTerminator terminator = BAInteropUtil.registerTerminator(context, context.getIdentifier().getValue());
        terminator.complete();
        terminator.close();
        state.waitForCompletion(0);
    } finally {
        ProxyConversation.clearConversationState(conversationId);
    }
    assertTrue("Conversation did not complete successfully", state.isSuccessful());
}
Also used : BusinessActivityTerminator(com.arjuna.wst.BusinessActivityTerminator) InteropWaitState(com.jboss.transaction.txinterop.interop.states.InteropWaitState) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Aggregations

InteropWaitState (com.jboss.transaction.txinterop.interop.states.InteropWaitState)18 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)16 CompletionCoordinatorParticipant (com.arjuna.wst.CompletionCoordinatorParticipant)10 BusinessActivityTerminator (com.arjuna.wst.BusinessActivityTerminator)6 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)2