1 7 package org.jboss.remoting.marshall.serializable; 8 9 import junit.framework.TestCase; 10 import org.jboss.remoting.marshal.MarshalFactory; 11 import org.jboss.remoting.marshal.Marshaller; 12 import org.jboss.remoting.marshal.UnMarshaller; 13 import org.jboss.remoting.marshal.serializable.SerializableMarshaller; 14 import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; 15 16 import java.io.ByteArrayInputStream ; 17 import java.io.ByteArrayOutputStream ; 18 import java.io.IOException ; 19 20 23 public class SerializableMarshallingTestCase extends TestCase 24 { 25 private Marshaller marshaller; 26 private UnMarshaller unmarshaller; 27 28 protected void setUp() throws Exception 29 { 30 super.setUp(); 31 marshaller = MarshalFactory.getMarshaller(SerializableMarshaller.DATATYPE); 32 unmarshaller = MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE); 33 } 34 35 public void testMarshalling() throws IOException , ClassNotFoundException 36 { 37 String testData = "This is some test data"; 38 Object param = new String (testData); 39 40 ByteArrayOutputStream output = new ByteArrayOutputStream (); 41 marshaller.write(param, output); 42 byte[] byteArray = new byte[output.size()]; 43 byteArray = output.toByteArray(); 44 ByteArrayInputStream input = new ByteArrayInputStream (byteArray); 45 Object result = unmarshaller.read(input, null); 46 47 System.out.println("Result: " + result); 48 assertEquals(testData, result); 49 } 50 51 protected void tearDown() throws Exception 52 { 53 super.tearDown(); 54 marshaller = null; 55 unmarshaller = null; 56 } 57 58 } 59 | Popular Tags |