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;
14 import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
15 import org.apache.qpid.proton.amqp.Symbol;
18 import java.util.HashMap;
21 * Unit test for simple App.
23 public class MessageAnnotationsTest
26 public static final String ADDRESS = "/message_annotations-q";
27 public static final String PAYLOAD = "Payload";
30 * Create the test case
32 * @param testName name of the test case
34 public MessageAnnotationsTest(String testName)
40 * @return the suite of tests being tested
42 public static Test suite()
44 return new TestSuite(MessageAnnotationsTest.class);
47 public void test_message_annotations()
49 String uri = System.getProperty("rmq_broker_uri");
51 String address = uri + ADDRESS;
53 Messenger mng = new MessengerImpl();
54 Message sent_msg, received_msg;
59 } catch (Exception e) {
63 sent_msg = new MessageImpl();
64 sent_msg.setAddress(address);
65 sent_msg.setBody(new AmqpValue(PAYLOAD));
67 Map<Symbol, Object> map = new HashMap<Symbol, Object>();
68 map.put(Symbol.valueOf("key1"), "value1");
69 map.put(Symbol.valueOf("key2"), "value2");
70 MessageAnnotations annotations = new MessageAnnotations(map);
71 sent_msg.setMessageAnnotations(annotations);
76 mng.subscribe(address);
78 received_msg = mng.get();
80 assertEquals(sent_msg.getSubject(),
81 received_msg.getSubject());
82 assertEquals(sent_msg.getContentType(),
83 received_msg.getContentType());
84 assertEquals(sent_msg.getBody().toString(),
85 received_msg.getBody().toString());
86 assertEquals(sent_msg.getMessageAnnotations().toString(),
87 received_msg.getMessageAnnotations().toString());