Search in sources :

Example 6 with Builder

use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.

the class JMSTransportTest method suite.

public static TestSuite suite() throws Exception {
    ManagedTestSuite suite = new ManagedTestSuite(JMSTransportTest.class);
    // SwA doesn't make sense with text messages
    suite.addExclude("(&(test=AsyncSwA)(client=jms)(jmsType=text))");
    // Don't execute all possible test combinations:
    // * Use a single setup to execute tests with all message types.
    // * Only use a small set of message types for the other setups.
    suite.addExclude("(!(|(&(broker=qpid)(singleCF=false)(cfOnSender=false)(!(|(destType=topic)(replyDestType=topic))))" + "(&(test=AsyncXML)(messageType=SOAP11)(data=ASCII))" + "(&(test=EchoXML)(messageType=POX)(data=ASCII))" + "(test=MinConcurrency)))");
    // SYNAPSE-436:
    suite.addExclude("(&(test=EchoXML)(replyDestType=topic)(endpoint=axis))");
    // Example to run a few use cases.. please leave these commented out - asankha
    // suite.addExclude("(|(test=AsyncXML)(test=MinConcurrency)(destType=topic)(broker=qpid)(destType=topic)(replyDestType=topic)(client=jms)(endpoint=mock)(cfOnSender=true))");
    // suite.addExclude("(|(test=EchoXML)(destType=queue)(broker=qpid)(cfOnSender=true)(singleCF=false)(destType=queue)(client=jms)(endpoint=mock))");
    // suite.addExclude("(|(test=EchoXML)(test=AsyncXML)(test=AsyncSwA)(test=AsyncTextPlain)(test=AsyncBinary)(test=AsyncSOAPLarge)(broker=qpid))");
    TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
    JMSTestEnvironment[] environments = new JMSTestEnvironment[] { new QpidTestEnvironment(), new ActiveMQTestEnvironment() };
    for (boolean singleCF : new boolean[] { false, true }) {
        for (boolean cfOnSender : new boolean[] { false, true }) {
            for (JMSTestEnvironment env : environments) {
                builder.addEnvironment(env, new JMSTransportDescriptionFactory(singleCF, cfOnSender, 1));
            }
        }
    }
    builder.addAsyncChannel(new JMSAsyncChannel(JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT));
    builder.addAsyncChannel(new JMSAsyncChannel(JMSConstants.DESTINATION_TYPE_TOPIC, ContentTypeMode.TRANSPORT));
    builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
    builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new JMSAxisTestClientConfigurator(JMSConstants.JMS_BYTE_MESSAGE));
    builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new JMSAxisTestClientConfigurator(JMSConstants.JMS_TEXT_MESSAGE));
    builder.addByteArrayAsyncTestClient(new JMSAsyncClient<byte[]>(JMSBytesMessageFactory.INSTANCE));
    builder.addStringAsyncTestClient(new JMSAsyncClient<String>(JMSTextMessageFactory.INSTANCE));
    builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
    builder.addRequestResponseChannel(new JMSRequestResponseChannel(JMSConstants.DESTINATION_TYPE_QUEUE, JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT));
    AxisTestClientConfigurator timeoutConfigurator = new AxisTestClientConfigurator() {

        public void setupRequestMessageContext(MessageContext msgContext) throws AxisFault {
            msgContext.setProperty(JMSConstants.JMS_WAIT_REPLY, "5000");
        }
    };
    builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient(), timeoutConfigurator);
    builder.addStringRequestResponseTestClient(new JMSRequestResponseClient<String>(JMSTextMessageFactory.INSTANCE));
    builder.addEchoEndpoint(new MockEchoEndpoint());
    builder.addEchoEndpoint(new AxisEchoEndpoint());
    for (JMSTestEnvironment env : new JMSTestEnvironment[] { new QpidTestEnvironment(), new ActiveMQTestEnvironment() }) {
        suite.addTest(new MinConcurrencyTest(new AsyncChannel[] { new JMSAsyncChannel("endpoint1", JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT), new JMSAsyncChannel("endpoint2", JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT) }, 2, false, env, new JMSTransportDescriptionFactory(false, false, 2)));
    }
    builder.build();
    return suite;
}
Also used : AxisRequestResponseTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient) AxisAsyncEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint) AxisTestClientConfigurator(org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator) AsyncChannel(org.apache.axis2.transport.testkit.channel.AsyncChannel) ManagedTestSuite(org.apache.axis2.transport.testkit.ManagedTestSuite) AxisAsyncTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient) AxisEchoEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint) MinConcurrencyTest(org.apache.axis2.transport.testkit.tests.misc.MinConcurrencyTest) MessageContext(org.apache.axis2.context.MessageContext) TransportTestSuiteBuilder(org.apache.axis2.transport.testkit.TransportTestSuiteBuilder)

Example 7 with Builder

use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.

the class UDPTransportTest method suite.

public static TestSuite suite() throws Exception {
    ManagedTestSuite suite = new ManagedTestSuite(UDPTransportTest.class);
    // For the moment, we can only do SOAP 1.1 (see TODO item on UDPChannel)
    suite.addExclude("(|(messageType=SOAP12)(messageType=POX)(test=AsyncTextPlain)(test=AsyncBinary))");
    // Who would want to do SwA over UDP?
    suite.addExclude("(test=AsyncSwA)");
    // Obviously, UDP will not support large SOAP messages
    suite.addExclude("(test=AsyncSOAPLarge)");
    TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
    builder.addAsyncChannel(new UDPChannel());
    builder.addRequestResponseChannel(new UDPChannel());
    builder.addEnvironment(new SimpleTransportDescriptionFactory("udp", UDPListener.class, UDPSender.class));
    builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
    builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
    builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient());
    builder.addEchoEndpoint(new AxisEchoEndpoint());
    builder.build();
    return suite;
}
Also used : AxisRequestResponseTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient) AxisAsyncEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint) AxisAsyncTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient) AxisEchoEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint) SimpleTransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.SimpleTransportDescriptionFactory) ManagedTestSuite(org.apache.axis2.transport.testkit.ManagedTestSuite) TransportTestSuiteBuilder(org.apache.axis2.transport.testkit.TransportTestSuiteBuilder)

Example 8 with Builder

use of org.apache.axis2.builder.Builder in project wso2-axis2-transports by wso2.

the class RabbitMQUtils method setSoapEnvelop.

private static void setSoapEnvelop(MessageContext msgContext, byte[] body, String contentType) throws AxisFault {
    Builder builder = getBuilder(msgContext, contentType);
    OMElement documentElement = builder.processDocument(new ByteArrayInputStream(body), contentType, msgContext);
    msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SOAPBuilder(org.apache.axis2.builder.SOAPBuilder) Builder(org.apache.axis2.builder.Builder) OMElement(org.apache.axiom.om.OMElement)

Example 9 with Builder

use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.

the class JsonStreamingBuilderTest method testProcessDocumentNoJsonPayload.

public void testProcessDocumentNoJsonPayload() throws AxisFault {
    String defaultEnvelope = "<?xml version='1.0' encoding='utf-8'?>" + "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" + "<soapenv:Body />" + "</soapenv:Envelope>";
    MessageContext messageContext = Util.newMessageContext();
    messageContext.setTo(new EndpointReference("http://localhost:8000"));
    Builder jsonBuilder = Util.newJsonStreamBuilder();
    OMElement element = jsonBuilder.processDocument(null, "application/json", messageContext);
    assertEquals("Default envelope expected", defaultEnvelope, element.toString());
}
Also used : Builder(org.apache.axis2.builder.Builder) OMElement(org.apache.axiom.om.OMElement) MessageContext(org.apache.axis2.context.MessageContext) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 10 with Builder

use of org.apache.axis2.builder.Builder in project wso2-synapse by wso2.

the class JsonStreamingBuilderTest method testInvalidJson.

/**
 * Test for the RuntimeException thrown when the json payload is invalid.
 */
public void testInvalidJson() {
    String invalidJson = "{\n" + "\"account_number\":\"1234567890\",\n" + "\"routing_number\":\"09100001\n" + "\"image_type\":\"COMMERCIAL_DEPOSIT\"\n" + "}";
    try {
        MessageContext message = Util.newMessageContext();
        InputStream inputStream = Util.newInputStream(invalidJson.getBytes());
        Builder jsonBuilder = Util.newJsonStreamBuilder();
        OMElement element = jsonBuilder.processDocument(inputStream, "application/json", message);
        message.getEnvelope().getBody().addChild(element);
    } catch (Exception e) {
        assertTrue("Not a RuntimeException instance", e instanceof RuntimeException);
    }
}
Also used : InputStream(java.io.InputStream) Builder(org.apache.axis2.builder.Builder) OMElement(org.apache.axiom.om.OMElement) MessageContext(org.apache.axis2.context.MessageContext)

Aggregations

OMElement (org.apache.axiom.om.OMElement)24 MessageContext (org.apache.axis2.context.MessageContext)15 Builder (org.apache.axis2.builder.Builder)13 AxisFault (org.apache.axis2.AxisFault)11 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 SOAPBuilder (org.apache.axis2.builder.SOAPBuilder)8 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 EndpointReference (org.apache.axis2.addressing.EndpointReference)5 ContentType (javax.mail.internet.ContentType)4 ParseException (javax.mail.internet.ParseException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 Parameter (org.apache.axis2.description.Parameter)4 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)4 MessageFormatter (org.apache.axis2.transport.MessageFormatter)4 ManagedTestSuite (org.apache.axis2.transport.testkit.ManagedTestSuite)4 TransportTestSuiteBuilder (org.apache.axis2.transport.testkit.TransportTestSuiteBuilder)4 AxisAsyncTestClient (org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient)4