Search in sources :

Example 1 with AsyncChannel

use of org.apache.axis2.transport.testkit.channel.AsyncChannel in project wso2-axis2-transports by wso2.

the class TransportTestSuiteBuilder method build.

private void build(Object[] env) {
    for (ResourceRelation<AsyncChannel> channel : asyncChannels) {
        for (ResourceRelation<AsyncTestClient<XMLMessage>> client : xmlAsyncClients) {
            for (ResourceRelation<AsyncEndpoint<XMLMessage>> endpoint : xmlAsyncEndpoints) {
                Object[] resources = merge(env, channel, client, endpoint);
                for (MessageTestData data : messageTestData) {
                    for (XMLMessage.Type type : XMLMessage.Type.values()) {
                        if (type != XMLMessage.Type.SWA) {
                            suite.addTest(new XMLAsyncMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), type, data, resources));
                        }
                    }
                }
                suite.addTest(new SwATestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
                // Regression test for SYNAPSE-423:
                suite.addTest(new LargeSOAPAsyncMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
            }
        }
        for (ResourceRelation<AsyncTestClient<String>> client : stringAsyncClients) {
            for (ResourceRelation<AsyncEndpoint<String>> endpoint : stringAsyncEndpoints) {
                Object[] resources = merge(env, channel, client, endpoint);
                for (MessageTestData data : messageTestData) {
                    suite.addTest(new TextPlainTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), data, resources));
                }
            }
        }
        for (ResourceRelation<AsyncTestClient<byte[]>> client : byteAsyncClients) {
            for (ResourceRelation<AsyncEndpoint<byte[]>> endpoint : byteAsyncEndpoints) {
                Object[] resources = merge(env, channel, client, endpoint);
                suite.addTest(new BinaryTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), resources));
            }
        }
        for (ResourceRelation<AsyncTestClient<RESTMessage>> client : restAsyncClients) {
            for (ResourceRelation<AsyncEndpoint<RESTMessage>> endpoint : restAsyncEndpoints) {
                Object[] resources = merge(env, channel, client, endpoint);
                suite.addTest(new RESTTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), restTestMessage1, resources));
            // TODO: regression test for SYNAPSE-431
            // addTest(new RESTTestCase(env, channel, client, endpoint, restTestMessage2));
            }
        }
    }
    for (ResourceRelation<RequestResponseChannel> channel : requestResponseChannels) {
        for (ResourceRelation<RequestResponseTestClient<XMLMessage, XMLMessage>> client : xmlRequestResponseClients) {
            for (ResourceRelation<InOutEndpoint> endpoint : echoEndpoints) {
                Object[] resources = merge(env, channel, client, endpoint);
                for (MessageTestData data : messageTestData) {
                    for (XMLMessage.Type type : XMLMessage.Type.values()) {
                        if (type != XMLMessage.Type.SWA) {
                            suite.addTest(new XMLRequestResponseMessageTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), endpoint.getPrimaryResource(), type, data, resources));
                        }
                    }
                }
            }
        }
    }
}
Also used : AsyncEndpoint(org.apache.axis2.transport.testkit.endpoint.AsyncEndpoint) XMLMessage(org.apache.axis2.transport.testkit.message.XMLMessage) InOutEndpoint(org.apache.axis2.transport.testkit.endpoint.InOutEndpoint) AsyncChannel(org.apache.axis2.transport.testkit.channel.AsyncChannel) RequestResponseTestClient(org.apache.axis2.transport.testkit.client.RequestResponseTestClient) BinaryTestCase(org.apache.axis2.transport.testkit.tests.async.BinaryTestCase) RESTTestCase(org.apache.axis2.transport.testkit.tests.async.RESTTestCase) TextPlainTestCase(org.apache.axis2.transport.testkit.tests.async.TextPlainTestCase) LargeSOAPAsyncMessageTestCase(org.apache.axis2.transport.testkit.tests.async.LargeSOAPAsyncMessageTestCase) SwATestCase(org.apache.axis2.transport.testkit.tests.async.SwATestCase) XMLRequestResponseMessageTestCase(org.apache.axis2.transport.testkit.tests.echo.XMLRequestResponseMessageTestCase) AsyncTestClient(org.apache.axis2.transport.testkit.client.AsyncTestClient) RequestResponseChannel(org.apache.axis2.transport.testkit.channel.RequestResponseChannel) XMLAsyncMessageTestCase(org.apache.axis2.transport.testkit.tests.async.XMLAsyncMessageTestCase)

Example 2 with AsyncChannel

use of org.apache.axis2.transport.testkit.channel.AsyncChannel 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 3 with AsyncChannel

use of org.apache.axis2.transport.testkit.channel.AsyncChannel in project wso2-axis2-transports by wso2.

the class HttpTransportTestSuiteBuilder method build.

public void build() {
    TransportTestSuiteBuilder builder = new TransportTestSuiteBuilder(suite);
    builder.addEnvironment(tdf);
    HttpChannel channel = new HttpChannel();
    builder.addAsyncChannel(channel);
    builder.addByteArrayAsyncTestClient(new JavaNetClient());
    if (axisTestClientConfigurators.isEmpty()) {
        builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
    } else {
        for (AxisTestClientConfigurator configurator : axisTestClientConfigurators) {
            builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), configurator);
        }
    }
    builder.addRESTAsyncTestClient(new JavaNetRESTClient());
    builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
    builder.addByteArrayAsyncEndpoint(new JettyByteArrayAsyncEndpoint());
    builder.addRESTAsyncEndpoint(new JettyRESTAsyncEndpoint());
    builder.addRequestResponseChannel(channel);
    builder.addAxisRequestResponseTestClient(new AxisRequestResponseTestClient());
    builder.addEchoEndpoint(new AxisEchoEndpoint());
    builder.addEchoEndpoint(new JettyEchoEndpoint());
    builder.build();
    suite.addTest(new MinConcurrencyTest(new AsyncChannel[] { new HttpChannel(), new HttpChannel() }, 2, false, tdf));
}
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) 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) TransportTestSuiteBuilder(org.apache.axis2.transport.testkit.TransportTestSuiteBuilder)

Example 4 with AsyncChannel

use of org.apache.axis2.transport.testkit.channel.AsyncChannel in project wso2-axis2-transports by wso2.

the class MinConcurrencyTest method runTest.

@Override
protected void runTest() throws Throwable {
    int endpointCount = channels.length;
    int expectedConcurrency = endpointCount * messages;
    final MessageReceiver messageReceiver = new MessageReceiver() {

        public void receive(MessageContext msgContext) throws AxisFault {
            synchronized (concurrencyReachedLock) {
                concurrencyReached++;
                concurrencyReachedLock.notifyAll();
            }
            try {
                synchronized (shutdownAwaitLock) {
                    shutdownAwaitLock.wait();
                }
            } catch (InterruptedException ex) {
            }
        }
    };
    TestResourceSet[] clientResourceSets = new TestResourceSet[endpointCount];
    TestResourceSet[] endpointResourceSets = new TestResourceSet[endpointCount];
    try {
        for (int i = 0; i < endpointCount; i++) {
            TestResourceSet clientResourceSet = new TestResourceSet(getResourceSet());
            AsyncChannel channel = channels[i];
            clientResourceSet.addResource(channel);
            AxisAsyncTestClient client = new AxisAsyncTestClient(false);
            clientResourceSet.addResource(client);
            clientResourceSet.setUp();
            clientResourceSets[i] = clientResourceSet;
            TestResourceSet endpointResourceSet = new TestResourceSet(clientResourceSet);
            endpointResourceSet.addResource(new AxisTestEndpoint() {

                @Override
                protected AxisOperation createOperation() {
                    AxisOperation operation = new InOnlyAxisOperation(new QName("in"));
                    operation.setMessageReceiver(messageReceiver);
                    return operation;
                }

                @Override
                protected void onTransportError(Throwable ex) {
                // TODO Auto-generated method stub
                }
            });
            if (!preloadMessages) {
                endpointResourceSet.setUp();
                endpointResourceSets[i] = endpointResourceSet;
            }
            for (int j = 0; j < messages; j++) {
                ClientOptions options = new ClientOptions(client, new ContentType(SOAP11Constants.SOAP_11_CONTENT_TYPE), "UTF-8");
                AxisMessage message = new AxisMessage();
                message.setMessageType(SOAP11Constants.SOAP_11_CONTENT_TYPE);
                SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
                SOAPEnvelope envelope = factory.getDefaultEnvelope();
                message.setEnvelope(envelope);
                client.sendMessage(options, new ContentType(message.getMessageType()), message);
            }
            if (preloadMessages) {
                endpointResourceSet.setUp();
                endpointResourceSets[i] = endpointResourceSet;
            }
        }
        long startTime = System.currentTimeMillis();
        while (concurrencyReached < expectedConcurrency && System.currentTimeMillis() < (startTime + 5000)) {
            synchronized (concurrencyReachedLock) {
                concurrencyReachedLock.wait(5000);
            }
        }
        synchronized (shutdownAwaitLock) {
            shutdownAwaitLock.notifyAll();
        }
        if (concurrencyReached < expectedConcurrency) {
            fail("Concurrency reached is " + concurrencyReached + ", but expected " + expectedConcurrency);
        }
    } finally {
        for (int i = 0; i < endpointCount; i++) {
            if (endpointResourceSets[i] != null) {
                endpointResourceSets[i].tearDown();
            }
            if (clientResourceSets[i] != null) {
                clientResourceSets[i].tearDown();
            }
        }
    }
}
Also used : ClientOptions(org.apache.axis2.transport.testkit.client.ClientOptions) InOnlyAxisOperation(org.apache.axis2.description.InOnlyAxisOperation) AxisOperation(org.apache.axis2.description.AxisOperation) ContentType(javax.mail.internet.ContentType) QName(javax.xml.namespace.QName) AsyncChannel(org.apache.axis2.transport.testkit.channel.AsyncChannel) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) AxisTestEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint) SOAPFactory(org.apache.axiom.soap.SOAPFactory) InOnlyAxisOperation(org.apache.axis2.description.InOnlyAxisOperation) MessageReceiver(org.apache.axis2.engine.MessageReceiver) AxisTestEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint) AxisAsyncTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient) MessageContext(org.apache.axis2.context.MessageContext) TestResourceSet(org.apache.axis2.transport.testkit.tests.TestResourceSet) AxisMessage(org.apache.axis2.transport.testkit.message.AxisMessage)

Aggregations

AsyncChannel (org.apache.axis2.transport.testkit.channel.AsyncChannel)4 AxisAsyncTestClient (org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient)3 MessageContext (org.apache.axis2.context.MessageContext)2 TransportTestSuiteBuilder (org.apache.axis2.transport.testkit.TransportTestSuiteBuilder)2 AxisRequestResponseTestClient (org.apache.axis2.transport.testkit.axis2.client.AxisRequestResponseTestClient)2 AxisTestClientConfigurator (org.apache.axis2.transport.testkit.axis2.client.AxisTestClientConfigurator)2 AxisAsyncEndpoint (org.apache.axis2.transport.testkit.axis2.endpoint.AxisAsyncEndpoint)2 AxisEchoEndpoint (org.apache.axis2.transport.testkit.axis2.endpoint.AxisEchoEndpoint)2 MinConcurrencyTest (org.apache.axis2.transport.testkit.tests.misc.MinConcurrencyTest)2 ContentType (javax.mail.internet.ContentType)1 QName (javax.xml.namespace.QName)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 AxisOperation (org.apache.axis2.description.AxisOperation)1 InOnlyAxisOperation (org.apache.axis2.description.InOnlyAxisOperation)1 MessageReceiver (org.apache.axis2.engine.MessageReceiver)1 ManagedTestSuite (org.apache.axis2.transport.testkit.ManagedTestSuite)1 AxisTestEndpoint (org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint)1 RequestResponseChannel (org.apache.axis2.transport.testkit.channel.RequestResponseChannel)1 AsyncTestClient (org.apache.axis2.transport.testkit.client.AsyncTestClient)1