Search in sources :

Example 6 with IncomingMessage

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

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