use of com.arjuna.webservices11.wsarj.ArjunaContext 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.wsarj.ArjunaContext 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.wsarj.ArjunaContext 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.wsarj.ArjunaContext in project narayana by jbosstm.
the class TwoPCCoordinatorTest method checkDetails.
/**
* check the message details to see that they have the correct to, from and faultto address and message id, a
* none reply to address and an arjuna context containing the correct instannce identifier
* @param details
* @param hasFrom
* @param hasFaultTo
* @param messageId
* @param instanceIdentifier
*/
private void checkDetails(ParticipantDetails details, boolean hasFrom, boolean hasFaultTo, String messageId, InstanceIdentifier instanceIdentifier) {
MAP inMAP = details.getMAP();
ArjunaContext inArjunaContext = details.getArjunaContext();
assertEquals(inMAP.getTo(), TestUtil.participantServiceURI);
assertNotNull(inMAP.getReplyTo());
assertTrue(AddressingHelper.isNoneReplyTo(inMAP));
if (hasFrom) {
assertNotNull(inMAP.getFrom());
assertEquals(inMAP.getFrom().getAddress(), TestUtil.coordinatorServiceURI);
} else {
assertNull(inMAP.getFrom());
}
if (hasFaultTo) {
assertNotNull(inMAP.getFaultTo());
assertEquals(inMAP.getFaultTo().getAddress(), TestUtil.coordinatorServiceURI);
} else {
assertNull(inMAP.getFrom());
}
assertNotNull(inMAP.getMessageID());
assertEquals(inMAP.getMessageID(), messageId);
if (instanceIdentifier == null) {
assertNull(inArjunaContext);
} else {
assertNotNull(inArjunaContext);
assertEquals(instanceIdentifier.getInstanceIdentifier(), inArjunaContext.getInstanceIdentifier().getInstanceIdentifier());
}
}
use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.
the class EnduranceTest method doRegisterRequest.
public void doRegisterRequest(final String messageId) throws Exception {
final String protocolIdentifier = TestUtil.PROTOCOL_IDENTIFIER;
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 = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
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());
assertNotNull(coordinator);
}
Aggregations