Search in sources :

Example 76 with EndpointReference

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);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) RelatesTo(org.apache.axis2.addressing.RelatesTo) SOAPFactory(org.apache.axiom.soap.SOAPFactory) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 77 with EndpointReference

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.");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 78 with EndpointReference

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.");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 79 with EndpointReference

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");
}
Also used : AxisFault(org.apache.axis2.AxisFault) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 80 with EndpointReference

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);
    }
}
Also used : AxisEndpoint(org.apache.axis2.description.AxisEndpoint) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)261 Options (org.apache.axis2.client.Options)99 OMElement (org.apache.axiom.om.OMElement)67 AxisFault (org.apache.axis2.AxisFault)66 MessageContext (org.apache.axis2.context.MessageContext)58 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 ServiceClient (org.apache.axis2.client.ServiceClient)54 QName (javax.xml.namespace.QName)40 ArrayList (java.util.ArrayList)37 AxisService (org.apache.axis2.description.AxisService)28 Map (java.util.Map)25 MessageContext (org.apache.synapse.MessageContext)25 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 Test (org.junit.Test)20 IOException (java.io.IOException)19 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)18 RelatesTo (org.apache.axis2.addressing.RelatesTo)18 URL (java.net.URL)17 SOAPFactory (org.apache.axiom.soap.SOAPFactory)17 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)17