Search in sources :

Example 6 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup 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 Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class MockEchoEndpoint method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(JMSTestEnvironment env, JMSRequestResponseChannel channel) throws Exception {
    Destination destination = channel.getDestination();
    Destination replyDestination = channel.getReplyDestination();
    connection = env.getConnectionFactory().createConnection();
    connection.setExceptionListener(this);
    connection.start();
    replyConnection = env.getConnectionFactory().createConnection();
    replyConnection.setExceptionListener(this);
    final Session replySession = replyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    final MessageProducer producer = replySession.createProducer(replyDestination);
    MessageConsumer consumer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(destination);
    consumer.setMessageListener(new MessageListener() {

        public void onMessage(Message message) {
            try {
                log.info("Message received: ID = " + message.getJMSMessageID());
                Message reply;
                if (message instanceof BytesMessage) {
                    reply = replySession.createBytesMessage();
                    IOUtils.copy(new BytesMessageInputStream((BytesMessage) message), new BytesMessageOutputStream((BytesMessage) reply));
                } else if (message instanceof TextMessage) {
                    reply = replySession.createTextMessage();
                    ((TextMessage) reply).setText(((TextMessage) message).getText());
                } else {
                    // TODO
                    throw new UnsupportedOperationException("Unsupported message type");
                }
                reply.setJMSCorrelationID(message.getJMSMessageID());
                reply.setStringProperty(BaseConstants.CONTENT_TYPE, message.getStringProperty(BaseConstants.CONTENT_TYPE));
                producer.send(reply);
                log.info("Message sent: ID = " + reply.getJMSMessageID());
            } catch (Throwable ex) {
                fireEndpointError(ex);
            }
        }
    });
}
Also used : Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) TextMessage(javax.jms.TextMessage) BytesMessage(javax.jms.BytesMessage) Message(javax.jms.Message) MessageListener(javax.jms.MessageListener) BytesMessage(javax.jms.BytesMessage) BytesMessageOutputStream(org.apache.axis2.transport.jms.iowrappers.BytesMessageOutputStream) MessageProducer(javax.jms.MessageProducer) BytesMessageInputStream(org.apache.axis2.transport.jms.iowrappers.BytesMessageInputStream) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 8 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class JMSRequestResponseClient method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(JMSTestEnvironment env, JMSRequestResponseChannel channel) throws Exception {
    replyDestination = channel.getReplyDestination();
    ConnectionFactory connectionFactory = env.getConnectionFactory();
    replyConnection = connectionFactory.createConnection();
    replyConnection.start();
    replySession = replyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 9 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class JMSTransportDescriptionFactory method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(JMSTestEnvironment env, JNDIEnvironment jndiEnvironment) throws Exception {
    context = jndiEnvironment.getContext();
    ConnectionFactory connectionFactory = env.getConnectionFactory();
    if (singleCF) {
        context.bind(CONNECTION_FACTORY, connectionFactory);
    } else {
        context.bind(QUEUE_CONNECTION_FACTORY, connectionFactory);
        context.bind(TOPIC_CONNECTION_FACTORY, connectionFactory);
    }
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 10 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class ContentTypeRuleTest method setUp.

@Override
public void setUp() throws Exception {
    AxisConfiguration axisCfg = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
    AxisService service = new AxisService();
    InputStream in = ContentTypeRuleTest.class.getResourceAsStream(getName() + ".xml");
    try {
        OMElement element = new StAXOMBuilder(in).getDocumentElement();
        new ServiceBuilder(cfgCtx, service).populateService(element);
    } finally {
        in.close();
    }
    ruleSet = ContentTypeRuleFactory.parse(service.getParameter("test"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) InputStream(java.io.InputStream) AxisService(org.apache.axis2.description.AxisService) OMElement(org.apache.axiom.om.OMElement) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) ServiceBuilder(org.apache.axis2.deployment.ServiceBuilder)

Aggregations

Setup (org.apache.axis2.transport.testkit.tests.Setup)16 ConnectionFactory (javax.jms.ConnectionFactory)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 InetSocketAddress (java.net.InetSocketAddress)2 Destination (javax.jms.Destination)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 AxisService (org.apache.axis2.description.AxisService)2 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)2 Tunnel (org.apache.axis2.transport.testkit.util.tcpmon.Tunnel)2 GreenMail (com.icegreen.greenmail.util.GreenMail)1 ServerSetup (com.icegreen.greenmail.util.ServerSetup)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Properties (java.util.Properties)1 BytesMessage (javax.jms.BytesMessage)1 Message (javax.jms.Message)1