Search in sources :

Example 1 with InvalidStateException

use of com.arjuna.wsc.InvalidStateException in project narayana by jbosstm.

the class EnduranceTest method doRegisterError.

public void doRegisterError(final String messageId, int count) throws Exception {
    final String protocolIdentifier;
    final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
    final CoordinationContextType coordinationContext = new CoordinationContextType();
    CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
    coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE);
    coordinationContext.setIdentifier(identifierInstance);
    identifierInstance.setValue("identifier");
    coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue()));
    W3CEndpointReference coordinator = null;
    switch(count) {
        case 0:
            protocolIdentifier = TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidProtocolException ipe) {
            }
            if (coordinator != null) {
                fail("expected invalid protocol exception");
            }
            break;
        case 1:
            protocolIdentifier = TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidStateException ise) {
            }
            if (coordinator != null) {
                fail("expected invalid state exception");
            }
            break;
        case 3:
            protocolIdentifier = TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
        default:
            protocolIdentifier = TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
    }
    final RegisterDetails details = testRegistrationCoordinatorProcessor.getRegisterDetails(messageId, 10000);
    final RegisterType requestRegister = details.getRegister();
    final MAP requestMap = details.getMAP();
    final ArjunaContext requestArjunaContext = details.getArjunaContext();
    assertEquals(requestMap.getTo(), TestUtil11.registrationCoordinatorService);
    assertEquals(requestMap.getMessageID(), messageId);
    assertNotNull(requestArjunaContext);
    assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue());
    ;
    assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier());
    assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) RegisterDetails(com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails) InvalidStateException(com.arjuna.wsc.InvalidStateException) CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Example 2 with InvalidStateException

use of com.arjuna.wsc.InvalidStateException in project narayana by jbosstm.

the class UserTransactionStandaloneImple method enlistCompletionParticipants.

/*
	 * enlist the client for the completiopn protocol so it can commit or ro0ll back the transaction
	 */
private final void enlistCompletionParticipants() throws WrongStateException, UnknownTransactionException, SystemException {
    TransactionManagerImple tm = (TransactionManagerImple) TransactionManager.getTransactionManager();
    final TxContextImple currentTx = (TxContextImple) tm.currentTransaction();
    if (currentTx == null)
        throw new UnknownTransactionException();
    final String id = currentTx.identifier();
    W3CEndpointReference completionCoordinator = null;
    try {
        completionCoordinator = tm.registerParticipant(null, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION_RPC);
    } catch (InvalidProtocolException ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    } catch (InvalidStateException ex) {
        throw new WrongStateException();
    } catch (CannotRegisterException ex) {
        // cause could actually be no activity or already registered
        throw new UnknownTransactionException();
    }
    _completionCoordinators.put(id, completionCoordinator);
}
Also used : UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) WrongStateException(com.arjuna.wst.WrongStateException) InvalidStateException(com.arjuna.wsc.InvalidStateException) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Aggregations

CannotRegisterException (com.arjuna.wsc.CannotRegisterException)2 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)2 InvalidStateException (com.arjuna.wsc.InvalidStateException)2 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)2 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)1 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)1 RegisterDetails (com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails)1 SystemException (com.arjuna.wst.SystemException)1 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)1 WrongStateException (com.arjuna.wst.WrongStateException)1 MAP (org.jboss.ws.api.addressing.MAP)1 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)1 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)1 RegisterType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType)1