1 24 25 package org.objectweb.jtests.jms.conform.message; 26 27 import org.objectweb.jtests.jms.framework.PTPTestCase; 28 import org.objectweb.jtests.jms.framework.TestConfig; 29 import javax.jms.*; 30 import junit.framework.*; 31 32 38 public class MessageBodyTest extends PTPTestCase { 39 40 44 public void testClearBody_2() { 45 try { 46 TextMessage message = senderSession.createTextMessage(); 47 message.setStringProperty("prop", "foo"); 48 message.clearBody(); 49 assertEquals("§3.11.1 Clearing a message's body does not clear its property entries.\n", 50 "foo", message.getStringProperty("prop")); 51 } catch (JMSException e) { 52 fail(e); 53 } 54 } 55 56 59 public void testClearBody_1() { 60 try { 61 TextMessage message = senderSession.createTextMessage(); 62 message.setText("bar"); 63 message.clearBody(); 64 assertEquals("§3 .11.1 the clearBody method of Message resets the value of the message body " + 65 "to the 'empty' initial message value as set by the message type's create " + 66 "method provided by Session.\n", 67 null, message.getText()); 68 } catch (JMSException e) { 69 fail(e); 70 } 71 } 72 73 77 public void testWriteOnReceivedBody() { 78 try { 79 TextMessage message = senderSession.createTextMessage(); 80 message.setText("foo"); 81 sender.send(message); 82 83 Message m = receiver.receive(TestConfig.TIMEOUT); 84 assertTrue("The message should be an instance of TextMessage.\n", 85 m instanceof TextMessage); 86 TextMessage msg = (TextMessage)m; 87 msg.setText("bar"); 88 fail("should raise a MessageNotWriteableException (§3.11.2)"); 89 } catch (MessageNotWriteableException e) { 90 } catch (JMSException e) { 91 fail(e); 92 } 93 } 94 95 98 public static Test suite() { 99 return new TestSuite(MessageBodyTest.class); 100 } 101 102 public MessageBodyTest(String name) { 103 super(name); 104 } 105 } 106 | Popular Tags |