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());
}
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());
}
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());
}
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();
}
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();
}
Aggregations