Search in sources :

Example 1 with CompletionInitiatorProcessor

use of com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor in project narayana by jbosstm.

the class CompletionCoordinatorTest method testSendError.

@Test
public void testSendError() throws Exception {
    final String messageId = "123456";
    final String reason = "testSendErrorReason";
    final String instanceIdentifier = "testSendError";
    final W3CEndpointReference completionInitiatorEndpoint = TestUtil.getCompletionInitiatorEndpoint(instanceIdentifier);
    final MAP map = AddressingHelper.createRequestContext(TestUtil.completionInitiatorServiceURI, messageId);
    final SoapFaultType soapFaultType = SoapFaultType.FAULT_SENDER;
    final QName subcode = ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME;
    final SoapFault soapFault = new SoapFault11(soapFaultType, subcode, reason);
    final TestCompletionInitiatorCallback callback = new TestCompletionInitiatorCallback() {

        public void soapFault(final SoapFault soapFault, final MAP map, final ArjunaContext arjunaContext) {
            assertEquals(map.getTo(), TestUtil.completionInitiatorServiceURI);
            assertNull(map.getFrom());
            assertNull(map.getFaultTo());
            assertNotNull(map.getReplyTo());
            assertTrue(AddressingHelper.isNoneReplyTo(map));
            assertNotNull(map.getMessageID());
            assertEquals(map.getMessageID(), messageId);
            assertNotNull(arjunaContext);
            assertEquals(instanceIdentifier, arjunaContext.getInstanceIdentifier().getInstanceIdentifier());
            assertNotNull(soapFault);
            assertEquals(soapFaultType, soapFault.getSoapFaultType());
            assertEquals(subcode, soapFault.getSubcode());
            assertEquals(reason, soapFault.getReason());
        }
    };
    final CompletionInitiatorProcessor initiator = CompletionInitiatorProcessor.getProcessor();
    initiator.registerCallback(instanceIdentifier, callback);
    try {
        CompletionInitiatorClient.getClient().sendSoapFault(completionInitiatorEndpoint, map, soapFault, new InstanceIdentifier("sender"));
        callback.waitUntilTriggered();
    } finally {
        initiator.removeCallback(instanceIdentifier);
    }
    assertTrue(callback.hasTriggered());
    assertFalse(callback.hasFailed());
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SoapFaultType(com.arjuna.webservices.SoapFaultType) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) Test(org.junit.Test)

Example 2 with CompletionInitiatorProcessor

use of com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor in project narayana by jbosstm.

the class CompletionCoordinatorTest method testSendAborted.

@Test
public void testSendAborted() throws Exception {
    final String messageId = "123456";
    final String instanceIdentifier = "testSendAborted";
    final W3CEndpointReference completionInitiatorEndpoint = TestUtil.getCompletionInitiatorEndpoint(instanceIdentifier);
    final MAP map = AddressingHelper.createRequestContext(TestUtil.completionInitiatorServiceURI, messageId);
    final TestCompletionInitiatorCallback callback = new TestCompletionInitiatorCallback() {

        public void aborted(final Notification aborted, final MAP map, final ArjunaContext arjunaContext) {
            assertEquals(map.getTo(), TestUtil.completionInitiatorServiceURI);
            assertNull(map.getFrom());
            assertNotNull(map.getFaultTo());
            assertEquals(map.getFaultTo().getAddress(), TestUtil.completionCoordinatorServiceURI);
            assertNotNull(map.getReplyTo());
            assertTrue(AddressingHelper.isNoneReplyTo(map));
            assertNotNull(map.getMessageID());
            assertEquals(map.getMessageID(), messageId);
            assertNotNull(arjunaContext);
            assertEquals(instanceIdentifier, arjunaContext.getInstanceIdentifier().getInstanceIdentifier());
        }
    };
    final CompletionInitiatorProcessor initiator = CompletionInitiatorProcessor.getProcessor();
    initiator.registerCallback(instanceIdentifier, callback);
    try {
        CompletionInitiatorClient.getClient().sendAborted(completionInitiatorEndpoint, map, new InstanceIdentifier("sender"));
        callback.waitUntilTriggered();
    } finally {
        initiator.removeCallback(instanceIdentifier);
    }
    assertTrue(callback.hasTriggered());
    assertFalse(callback.hasFailed());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification) Test(org.junit.Test)

Example 3 with CompletionInitiatorProcessor

use of com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor in project narayana by jbosstm.

the class CompletionCoordinatorTest method testSendCommitted.

@Test
public void testSendCommitted() throws Exception {
    final String messageId = "123456";
    final String instanceIdentifier = "testSendCommitted";
    final W3CEndpointReference completionInitiatorEndpoint = TestUtil.getCompletionInitiatorEndpoint(instanceIdentifier);
    final MAP map = AddressingHelper.createRequestContext(TestUtil.completionInitiatorServiceURI, messageId);
    final TestCompletionInitiatorCallback callback = new TestCompletionInitiatorCallback() {

        public void committed(final Notification committed, final MAP map, final ArjunaContext arjunaContext) {
            assertEquals(map.getTo(), TestUtil.completionInitiatorServiceURI);
            assertNull(map.getFrom());
            assertNotNull(map.getFaultTo());
            assertEquals(map.getFaultTo().getAddress(), TestUtil.completionCoordinatorServiceURI);
            assertNotNull(map.getReplyTo());
            assertTrue(AddressingHelper.isNoneReplyTo(map));
            assertEquals(map.getMessageID(), messageId);
            assertNotNull(arjunaContext);
            assertEquals(instanceIdentifier, arjunaContext.getInstanceIdentifier().getInstanceIdentifier());
        }
    };
    final CompletionInitiatorProcessor initiator = CompletionInitiatorProcessor.getProcessor();
    initiator.registerCallback(instanceIdentifier, callback);
    try {
        CompletionInitiatorClient.getClient().sendCommitted(completionInitiatorEndpoint, map, new InstanceIdentifier("sender"));
        callback.waitUntilTriggered();
    } finally {
        initiator.removeCallback(instanceIdentifier);
    }
    assertTrue(callback.hasTriggered());
    assertFalse(callback.hasFailed());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification) Test(org.junit.Test)

Example 4 with CompletionInitiatorProcessor

use of com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor in project narayana by jbosstm.

the class CompletionStub method commit.

public void commit() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    final CompletionStub.RequestCallback callback = new CompletionStub.RequestCallback();
    final CompletionInitiatorProcessor completionInitiator = CompletionInitiatorProcessor.getProcessor();
    completionInitiator.registerCallback(_id, callback);
    try {
        CompletionCoordinatorClient.getClient().sendCommit(_completionCoordinator, map, new InstanceIdentifier(_id));
        callback.waitUntilTriggered();
    } catch (final Throwable th) {
        th.printStackTrace();
        throw new SystemException();
    } finally {
        completionInitiator.removeCallback(_id);
    }
    if (callback.hasTriggered()) {
        if (callback.receivedCommitted()) {
            return;
        } else if (callback.receivedAborted()) {
            throw new TransactionRolledBackException();
        }
        final SoapFault soapFault = callback.getSoapFault();
        if ((soapFault != null) && ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(soapFault.getSubcode())) {
            throw new UnknownTransactionException();
        }
    }
    throw new SystemException();
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) MAP(org.jboss.ws.api.addressing.MAP)

Example 5 with CompletionInitiatorProcessor

use of com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor in project narayana by jbosstm.

the class CompletionStub method rollback.

public void rollback() throws UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    final CompletionStub.RequestCallback callback = new CompletionStub.RequestCallback();
    final CompletionInitiatorProcessor completionInitiator = CompletionInitiatorProcessor.getProcessor();
    completionInitiator.registerCallback(_id, callback);
    try {
        CompletionCoordinatorClient.getClient().sendRollback(_completionCoordinator, map, new InstanceIdentifier(_id));
        callback.waitUntilTriggered();
    } catch (final Throwable th) {
        th.printStackTrace();
        throw new SystemException();
    } finally {
        completionInitiator.removeCallback(_id);
    }
    if (callback.hasTriggered()) {
        if (callback.receivedAborted()) {
            return;
        }
        final SoapFault soapFault = callback.getSoapFault();
        if ((soapFault != null) && ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(soapFault.getSubcode())) {
            throw new UnknownTransactionException();
        }
    }
    throw new SystemException();
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) MAP(org.jboss.ws.api.addressing.MAP)

Aggregations

InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)5 CompletionInitiatorProcessor (com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor)5 MAP (org.jboss.ws.api.addressing.MAP)5 SoapFault (com.arjuna.webservices.SoapFault)3 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)3 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)3 Test (org.junit.Test)3 SystemException (com.arjuna.wst.SystemException)2 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)2 Notification (org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)2 SoapFaultType (com.arjuna.webservices.SoapFaultType)1 SoapFault11 (com.arjuna.webservices11.SoapFault11)1 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)1 QName (javax.xml.namespace.QName)1