Search in sources :

Example 6 with ClientOptions

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

ContentType (javax.mail.internet.ContentType)4 IncomingMessage (org.apache.axis2.transport.testkit.message.IncomingMessage)4 MessageContext (org.apache.axis2.context.MessageContext)3 AxisMessage (org.apache.axis2.transport.testkit.message.AxisMessage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Message (javax.jms.Message)1 MessageConsumer (javax.jms.MessageConsumer)1 Message (javax.mail.Message)1 MimeMessage (javax.mail.internet.MimeMessage)1 QName (javax.xml.namespace.QName)1 Attachments (org.apache.axiom.attachments.Attachments)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 OperationClient (org.apache.axis2.client.OperationClient)1 AxisOperation (org.apache.axis2.description.AxisOperation)1 InOnlyAxisOperation (org.apache.axis2.description.InOnlyAxisOperation)1 MessageReceiver (org.apache.axis2.engine.MessageReceiver)1 MessageContextValidator (org.apache.axis2.transport.testkit.axis2.MessageContextValidator)1 AxisAsyncTestClient (org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient)1 AxisTestEndpoint (org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint)1