1 package org.objectweb.celtix.bus.transports.jms; 2 3 import java.io.ByteArrayOutputStream ; 4 import java.io.OutputStream ; 5 6 import junit.framework.TestCase; 7 8 import org.objectweb.celtix.context.GenericMessageContext; 9 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 = 25 new JMSOutputStreamContext(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("Should not change the contents of output buffer : ", 36 HELLO_WORLD_STRING.equals(os.toString())); 37 38 os = new ByteArrayOutputStream (); 39 40 os.write(ANOTHER_STRING_STRING.getBytes()); 41 42 assertTrue("Should contain old contents. ", 43 HELLO_WORLD_STRING.equals(joc.getOutputStream().toString())); 44 45 joc.setOutputStream(os); 46 47 assertTrue("Should contain new contents. ", 48 ANOTHER_STRING_STRING.equals(joc.getOutputStream().toString())); 49 50 joc.setOneWay(true); 51 52 assertTrue(joc.isOneWay()); 53 54 joc.setOneWay(false); 55 56 assertFalse(joc.isOneWay()); 57 58 joc.setFault(true); 59 60 assertFalse(joc.isFault()); 61 } 62 63 } 64 | Popular Tags |