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));
}
}
}
}
}
}
}
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;
}
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));
}
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();
}
}
}
}
Aggregations