3 package com.rabbitmq.amqp1_0.tests.proton;
5 import junit.framework.Test;
6 import junit.framework.TestCase;
7 import junit.framework.TestSuite;
9 import org.apache.qpid.proton.message.Message;
10 import org.apache.qpid.proton.message.impl.MessageImpl;
11 import org.apache.qpid.proton.messenger.Messenger;
12 import org.apache.qpid.proton.messenger.impl.MessengerImpl;
13 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
16 * Unit test for simple App.
18 public class RoundTripTest
21 public static final String ADDRESS = "/roundtrip-q";
22 public static final String PAYLOAD = "Payload";
25 * Create the test case
27 * @param testName name of the test case
29 public RoundTripTest(String testName)
35 * @return the suite of tests being tested
37 public static Test suite()
39 return new TestSuite(RoundTripTest.class);
42 public void test_roundtrip()
44 String uri = System.getProperty("rmq_broker_uri");
46 String address = uri + ADDRESS;
48 Messenger mng = new MessengerImpl();
49 Message sent_msg, received_msg;
54 } catch (Exception e) {
58 sent_msg = new MessageImpl();
59 sent_msg.setAddress(address);
60 sent_msg.setBody(new AmqpValue(PAYLOAD));
64 mng.subscribe(address);
66 received_msg = mng.get();
68 assertEquals(sent_msg.getSubject(),
69 received_msg.getSubject());
70 assertEquals(sent_msg.getContentType(),
71 received_msg.getContentType());
72 assertEquals(sent_msg.getBody().toString(),
73 received_msg.getBody().toString());