Search in sources :

Example 1 with IncomingMessage

use of org.apache.axis2.transport.testkit.message.IncomingMessage 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()));
}
Also used : ContentType(javax.mail.internet.ContentType) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage)

Example 2 with IncomingMessage

use of org.apache.axis2.transport.testkit.message.IncomingMessage in project wso2-axis2-transports by wso2.

the class AxisRequestResponseTestClient method sendMessage.

public IncomingMessage<AxisMessage> sendMessage(ClientOptions options, ContentType contentType, AxisMessage message) throws Exception {
    MessageContext responseMsgContext = send(options, message, ServiceClient.ANON_OUT_IN_OP, true, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    Assert.assertFalse(responseMsgContext.isServerSide());
    for (MessageContextValidator validator : validators) {
        validator.validate(responseMsgContext, true);
    }
    return new IncomingMessage<AxisMessage>(null, new AxisMessage(responseMsgContext));
}
Also used : IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) MessageContext(org.apache.axis2.context.MessageContext) MessageContextValidator(org.apache.axis2.transport.testkit.axis2.MessageContextValidator) AxisMessage(org.apache.axis2.transport.testkit.message.AxisMessage)

Example 3 with IncomingMessage

use of org.apache.axis2.transport.testkit.message.IncomingMessage 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();
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) Message(javax.jms.Message) ContentType(javax.mail.internet.ContentType) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage)

Example 4 with IncomingMessage

use of org.apache.axis2.transport.testkit.message.IncomingMessage in project wso2-synapse by wso2.

the class VFSRequestResponseClient method sendMessage.

public IncomingMessage<byte[]> sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception {
    send(message);
    File requestFile = getRequestFile();
    if (VFSTestUtils.waitForFileDeletion(requestFile, 5000)) {
        return new IncomingMessage<byte[]>(contentType, VFSTestUtils.readFile(replyFile));
    } else {
        requestFile.delete();
        return null;
    }
}
Also used : IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) File(java.io.File)

Example 5 with IncomingMessage

use of org.apache.axis2.transport.testkit.message.IncomingMessage in project wso2-axis2-transports by wso2.

the class JettyByteArrayAsyncEndpoint method handle.

@Override
protected IncomingMessage<byte[]> handle(HttpRequest request) throws HttpException, IOException {
    byte[] data = IOUtils.toByteArray(request.getInputStream());
    logRequest(request, data);
    ContentType contentType;
    try {
        contentType = new ContentType(request.getContentType());
    } catch (ParseException ex) {
        throw new HttpException(500, "Unparsable Content-Type");
    }
    return new IncomingMessage<byte[]>(contentType, data);
}
Also used : ContentType(javax.mail.internet.ContentType) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) HttpException(org.mortbay.http.HttpException) ParseException(javax.mail.internet.ParseException)

Aggregations

IncomingMessage (org.apache.axis2.transport.testkit.message.IncomingMessage)6 ContentType (javax.mail.internet.ContentType)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 Message (javax.jms.Message)1 MessageConsumer (javax.jms.MessageConsumer)1 Message (javax.mail.Message)1 MimeMessage (javax.mail.internet.MimeMessage)1 ParseException (javax.mail.internet.ParseException)1 MessageContext (org.apache.axis2.context.MessageContext)1 MessageContextValidator (org.apache.axis2.transport.testkit.axis2.MessageContextValidator)1 AxisMessage (org.apache.axis2.transport.testkit.message.AxisMessage)1 HttpException (org.mortbay.http.HttpException)1