01: package org.objectweb.celtix.bus.transports.jms;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.OutputStream;
05:
06: import junit.framework.TestCase;
07:
08: import org.objectweb.celtix.context.GenericMessageContext;
09:
10: public class JMSOutputStreamContextTest extends TestCase {
11:
12: static final String ANOTHER_STRING_STRING = "Another string";
13: static final String HELLO_WORLD_STRING = "Hello World";
14:
15: public JMSOutputStreamContextTest(String arg0) {
16: super (arg0);
17: }
18:
19: public static void main(String[] args) {
20: junit.textui.TestRunner.run(JMSOutputStreamContextTest.class);
21: }
22:
23: public void testJMSOutputStreamContext() throws Exception {
24: JMSOutputStreamContext joc = new JMSOutputStreamContext(
25: new GenericMessageContext());
26:
27: OutputStream os = joc.getOutputStream();
28:
29: assertNotNull(os);
30:
31: os.write(HELLO_WORLD_STRING.getBytes());
32:
33: os = joc.getOutputStream();
34:
35: assertTrue(
36: "Should not change the contents of output buffer : ",
37: HELLO_WORLD_STRING.equals(os.toString()));
38:
39: os = new ByteArrayOutputStream();
40:
41: os.write(ANOTHER_STRING_STRING.getBytes());
42:
43: assertTrue("Should contain old contents. ", HELLO_WORLD_STRING
44: .equals(joc.getOutputStream().toString()));
45:
46: joc.setOutputStream(os);
47:
48: assertTrue("Should contain new contents. ",
49: ANOTHER_STRING_STRING.equals(joc.getOutputStream()
50: .toString()));
51:
52: joc.setOneWay(true);
53:
54: assertTrue(joc.isOneWay());
55:
56: joc.setOneWay(false);
57:
58: assertFalse(joc.isOneWay());
59:
60: joc.setFault(true);
61:
62: assertFalse(joc.isFault());
63: }
64:
65: }
|