use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.
the class RequestResponseTestClientAdapter method sendMessage.
public IncomingMessage<O> sendMessage(ClientOptions options, ContentType contentType, M message) throws Exception {
IncomingMessage<P> response = target.sendMessage(options, encoder.getContentType(options, contentType), encoder.encode(options, message));
ContentType responseContentType = response.getContentType();
return new IncomingMessage<O>(responseContentType, decoder.decode(responseContentType, response.getData()));
}
use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.
the class JMSRequestResponseClient method sendMessage.
public IncomingMessage<T> sendMessage(ClientOptions options, ContentType contentType, T message) throws Exception {
String correlationId = doSendMessage(options, contentType, message);
MessageConsumer consumer = replySession.createConsumer(replyDestination, "JMSCorrelationID = '" + correlationId + "'");
try {
Message replyMessage = consumer.receive(8000);
return new IncomingMessage<T>(new ContentType(replyMessage.getStringProperty("Content-Type")), jmsMessageFactory.parseMessage(replyMessage));
} finally {
consumer.close();
}
}
use of org.apache.axis2.transport.testkit.client.ClientOptions in project carbon-business-process by wso2.
the class AxisServiceUtils method getOperationClient.
private static OperationClient getOperationClient(ServiceInvocationContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(), partnerMessageContext.getPort(), clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
anonymousService.getParent().addParameter("hiddenService", "true");
ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
// get a reference to the DYNAMIC operation of the Anonymous Axis2 service
AxisOperation axisAnonymousOperation = anonymousService.getOperation(partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP : ServiceClient.ANON_OUT_ONLY_OP);
Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
clientOptions.setExceptionToBeThrownOnSOAPFault(false);
/* This value doesn't overrideend point config. */
clientOptions.setTimeOutInMilliSeconds(60000);
return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
use of org.apache.axis2.transport.testkit.client.ClientOptions 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();
}
}
}
}
use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.
the class MailRequestResponseClient method sendMessage.
public IncomingMessage<byte[]> sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception {
String msgId = sendMessage(contentType, message);
Message reply = waitForReply(msgId);
Assert.assertNotNull("No response received", reply);
Assert.assertEquals(channel.getSender().getAddress(), ((InternetAddress) reply.getRecipients(Message.RecipientType.TO)[0]).getAddress());
Assert.assertEquals(channel.getRecipient().getAddress(), ((InternetAddress) reply.getFrom()[0]).getAddress());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
reply.getDataHandler().writeTo(baos);
return new IncomingMessage<byte[]>(new ContentType(reply.getContentType()), baos.toByteArray());
}
Aggregations