01: package org.mockejb.jms.test;
02:
03: import java.io.Serializable;
04: import javax.jms.*;
05:
06: import org.mockejb.jms.MessageUtility;
07: import org.mockejb.jms.ObjectMessageImpl;
08:
09: /**
10: * Tests <code>ObjectMessageImpl</code>
11: *
12: * @author Dimitar Gospodinov
13: */
14: public class ObjectMessageImplTest extends MessageTester {
15:
16: private ObjectMessage msg;
17:
18: public ObjectMessageImplTest(String name) {
19: super (name);
20: }
21:
22: protected void setUp() throws Exception {
23: msg = new ObjectMessageImpl();
24: message = msg;
25: super .setUp();
26: }
27:
28: protected void tearDown() throws Exception {
29: msg = null;
30: }
31:
32: public void testObjectMessage() throws JMSException {
33:
34: assertNull(msg.getObject());
35:
36: Object o = new Integer(12345);
37:
38: msg.setObject((Serializable) o);
39: assertNotSame(msg.getObject(), o);
40: assertEquals(msg.getObject(), o);
41:
42: ObjectMessage msg1 = new ObjectMessageImpl(msg);
43: assertNotSame(msg.getObject(), msg1.getObject());
44: assertEquals(msg.getObject(), msg1.getObject());
45:
46: assertTrue(MessageUtility.compare(msg, msg1));
47:
48: msg.clearBody();
49: assertNull(msg.getObject());
50: assertFalse(MessageUtility.compare(msg, msg1));
51: msg1.clearBody();
52: assertTrue(MessageUtility.compare(msg, msg1));
53:
54: checkMessageAttributes(msg1);
55: checkMessageAttributes();
56:
57: msg = new ObjectMessageImpl((Serializable) o);
58: assertNotSame(msg.getObject(), o);
59: assertEquals(msg.getObject(), o);
60: }
61:
62: }
|