]> review.fuel-infra Code Review - packages/trusty/rabbitmq-server.git/blob
16d82dac64072f3fc336b29ca57771313303a4cf
[packages/trusty/rabbitmq-server.git] /
1 // vim:sw=4:et:
2
3 package com.rabbitmq.amqp1_0.tests.proton;
4
5 import junit.framework.Test;
6 import junit.framework.TestCase;
7 import junit.framework.TestSuite;
8
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;
14
15 /**
16  * Unit test for simple App.
17  */
18 public class RoundTripTest
19     extends TestCase
20 {
21     public static final String ADDRESS = "/roundtrip-q";
22     public static final String PAYLOAD = "Payload";
23
24     /**
25      * Create the test case
26      *
27      * @param testName name of the test case
28      */
29     public RoundTripTest(String testName)
30     {
31         super(testName);
32     }
33
34     /**
35      * @return the suite of tests being tested
36      */
37     public static Test suite()
38     {
39         return new TestSuite(RoundTripTest.class);
40     }
41
42     public void test_roundtrip()
43     {
44         String uri = System.getProperty("rmq_broker_uri");
45         assertNotNull(uri);
46         String address = uri + ADDRESS;
47
48         Messenger mng = new MessengerImpl();
49         Message sent_msg, received_msg;
50
51         mng.setTimeout(1000);
52         try {
53             mng.start();
54         } catch (Exception e) {
55             fail();
56         }
57
58         sent_msg = new MessageImpl();
59         sent_msg.setAddress(address);
60         sent_msg.setBody(new AmqpValue(PAYLOAD));
61         mng.put(sent_msg);
62         mng.send();
63
64         mng.subscribe(address);
65         mng.recv();
66         received_msg = mng.get();
67
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());
74
75         mng.stop();
76     }
77 }