{
AMQConnection con = (AMQConnection) getConnection("guest", "guest");
AMQTopic topic = new AMQTopic(con, "MyTopic4");
TopicSession session1 = con.createTopicSession(true, AMQSession.AUTO_ACKNOWLEDGE);
TopicPublisher publisher = session1.createPublisher(topic);
MessageConsumer consumer1 = session1.createConsumer(topic);
con.start();
TextMessage tm = session1.createTextMessage("Hello");
publisher.publish(tm);
session1.commit();
tm = (TextMessage) consumer1.receive(10000L);
assertNotNull(tm);
String msgText = tm.getText();
assertEquals("Hello", msgText);
tm = session1.createTextMessage();
msgText = tm.getText();
assertNull(msgText);
publisher.publish(tm);
session1.commit();
tm = (TextMessage) consumer1.receive(10000L);
assertNotNull(tm);
session1.commit();
msgText = tm.getText();
assertNull(msgText);
tm.clearBody();
tm.setText("Now we are not null");
publisher.publish(tm);
session1.commit();
tm = (TextMessage) consumer1.receive(2000);
assertNotNull(tm);
session1.commit();
msgText = tm.getText();
assertEquals("Now we are not null", msgText);
tm = session1.createTextMessage("");
msgText = tm.getText();
assertEquals("Empty string not returned", "", msgText);
publisher.publish(tm);
session1.commit();
tm = (TextMessage) consumer1.receive(2000);
session1.commit();
assertNotNull(tm);
assertEquals("Empty string not returned", "", msgText);