1 package org.sapia.ubik.net.mplex; 2 3 import junit.framework.TestCase; 4 5 import java.io.ByteArrayOutputStream ; 6 import java.io.ObjectOutputStream ; 7 8 9 21 public class ObjectStreamSelectorTest extends TestCase { 22 25 public ObjectStreamSelectorTest(String aName) { 26 super(aName); 27 } 28 29 public void testObjectStream() throws Exception { 30 ByteArrayOutputStream data = new ByteArrayOutputStream (); 31 ObjectOutputStream oos = new ObjectOutputStream (data); 32 oos.writeObject("testObjectStream"); 33 oos.flush(); 34 35 ObjectStreamSelector selector = new ObjectStreamSelector(); 36 assertTrue("Should select the object stream", 37 selector.selectStream(data.toByteArray())); 38 } 39 40 public void testStringStream() throws Exception { 41 ByteArrayOutputStream data = new ByteArrayOutputStream (); 42 data.write("testObjectStream".getBytes()); 43 data.flush(); 44 45 ObjectStreamSelector selector = new ObjectStreamSelector(); 46 assertTrue("Should select the object stream", 47 !selector.selectStream(data.toByteArray())); 48 } 49 } 50 | Popular Tags |