use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class AddressingOutHandlerTest method testDuplicateHeaders.
public void testDuplicateHeaders() throws Exception {
// this will check whether we can add to epr, if there is one already.
EndpointReference eprOne = new EndpointReference("http://whatever.org");
EndpointReference duplicateEpr = new EndpointReference("http://whatever.duplicate.org");
RelatesTo reply = new RelatesTo("urn:id");
ConfigurationContext cfgCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
msgCtxt = cfgCtx.createMessageContext();
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
msgCtxt.setEnvelope(defaultEnvelope);
msgCtxt.addRelatesTo(reply);
msgCtxt.setTo(eprOne);
msgCtxt.setWSAAction("http://www.actions.org/action");
outHandler.invoke(msgCtxt);
// now the soap message within the msgCtxt must have a to header.
// lets invoke twice and see
msgCtxt.setTo(duplicateEpr);
outHandler.invoke(msgCtxt);
assertEquals("http://whatever.org", defaultEnvelope.getHeader().getFirstChildWithName(Final.QNAME_WSA_TO).getText());
Iterator<OMElement> iterator = defaultEnvelope.getHeader().getChildrenWithName(Final.QNAME_WSA_RELATES_TO);
int i = 0;
while (iterator.hasNext()) {
iterator.next();
i++;
}
assertEquals("Reply should be added twice.", 2, i);
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class AddressingSubmissionInHandlerTest method testMessageWithOmittedReplyTo.
public void testMessageWithOmittedReplyTo() throws Exception {
try {
Options options = testMessageWithOmittedHeaders("noReplyTo");
EndpointReference epr = options.getReplyTo();
String address = epr.getAddress();
assertEquals("The address of the ReplyTo endpoint reference is not the none URI.", AddressingConstants.Final.WSA_NONE_URI, address);
} catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown due to a missing ReplyTo header.");
}
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class AddressingSubmissionInHandlerTest method testMessageWithOmittedFaultTo.
public void testMessageWithOmittedFaultTo() throws Exception {
try {
Options options = testMessageWithOmittedHeaders("noFaultTo");
EndpointReference epr = options.getFaultTo();
assertNull("The FaultTo endpoint reference is not null.", epr);
} catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown due to a missing FaultTo header.");
}
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class EnginePausingTest method testFlowComplete.
public void testFlowComplete() throws Exception {
mc.setTo(new EndpointReference("/axis2/services/NullService"));
mc.setWSAAction("DummyOp");
// Fault on Handler #5
mc.setProperty(FAULT_IDX, new Integer(5));
try {
AxisEngine.receive(mc);
} catch (AxisFault axisFault) {
// Expected this fault.
assertEquals(4, executedHandlers.size());
return;
}
fail("Expected fault did not occur");
}
use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.
the class EnginePausingTest method testReceive.
public void testReceive() throws Exception {
mc.setTo(new EndpointReference("/axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisEngine.receive(mc);
assertEquals(14, executedHandlers.size());
for (int i = 0; i < 14; i++) {
assertEquals(((Integer) executedHandlers.get(i)).intValue(), i + 1);
}
AxisEngine.resume(mc);
assertEquals(27, executedHandlers.size());
for (int i = 15; i < 27; i++) {
assertEquals(((Integer) executedHandlers.get(i)).intValue(), i + 1);
}
}
Aggregations