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