Package org.jboss.serial.io

Examples of org.jboss.serial.io.JBossObjectOutputStream


    public void testJBossSerialization() throws Exception
    {
        Object obj = new TestClassReferenceTest();
        ByteArrayOutputStream byteout = new ByteArrayOutputStream();
        JBossObjectOutputStream out = new JBossObjectOutputStream (byteout);
        out.writeObject(obj);
        out.flush();
        JBossObjectInputStream inp = new JBossObjectInputStream (new ByteArrayInputStream(byteout.toByteArray()));
        Object obj2 = inp.readObject();
        assertTrue(obj!=obj2);
        assertEquals(obj,obj2);
    }
View Full Code Here


        assertEquals(6,proxy.doSomething());


        ByteArrayOutputStream byteout = new ByteArrayOutputStream();
        JBossObjectOutputStream out = new JBossObjectOutputStream (byteout);
        out.writeObject(proxy);
        out.flush();
        JBossObjectInputStream inp = new JBossObjectInputStream (new ByteArrayInputStream(byteout.toByteArray()));
        InterfaceForProxy proxy2 = (InterfaceForProxy)inp.readObject();
        assertEquals(6,proxy2.doSomething());
    }
View Full Code Here

*/
public class SafeToReuseTestCase extends TestCase {

    public void testReuseOnCloning() throws Exception
    {
        JBossObjectOutputStream out = new JBossObjectOutputStream(null);

        SafeCloningRepository safeToReuse = new SafeCloningRepository(new SafeClone()
        {
            public boolean isSafeToReuse(Object obj) {
                return (obj instanceof ChildObject);
            }
        });

        RootObject first = new RootObject();
        RootObject second = (RootObject)out.smartClone(first,safeToReuse);

        assertTrue(first!=second);
        assertEquals(first,second);
        assertEquals(first.child,second.child);
        assertTrue(first.child==second.child);
View Full Code Here

       System.out.println("Serializing...");

       String tmp= System.getProperty("java.io.tmpdir") + "/";

       FileOutputStream fos = new FileOutputStream(tmp + fileName);
       JBossObjectOutputStream oos = new JBossObjectOutputStream(fos);
      
       oos.writeObject(container);
      
       oos.close();
       fos.close();

       // no exception... unit test passes
  }
View Full Code Here

  }
 
  public void testJBoss() throws Exception
  {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    JBossObjectOutputStream objOut = new JBossObjectOutputStream(byteOut);
    TestReadResolveNull objNull = TestReadResolveNull.createTestInstance();
    objOut.writeObject(objNull);
    objOut.close();
    ObjectInputStream input = new JBossObjectInputStream(new ByteArrayInputStream(byteOut.toByteArray()));
    Object obj = input.readObject();
    assertNull(obj);
   
    System.out.println("obj=" + obj);
View Full Code Here

  }
 
  public void testJBossOnClassReferences() throws Exception
  {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    ObjectOutputStream objOut = new JBossObjectOutputStream(byteOut);
    TestReferences obj1 = new TestReferences();
    objOut.writeObject(obj1);
    objOut.close();
    ObjectInputStream input = new JBossObjectInputStream(new ByteArrayInputStream(byteOut.toByteArray()));
    Object obj2 = input.readObject();
   
    System.out.println("obj2=" + obj2);
   
View Full Code Here

                    ObjectInput containerInput = new JBossObjectInputStream(bufStream);
                    TestProxy objRead = (TestProxy)containerInput.readObject();
                    int result = objRead.getProxy().doSomething();

                    BufferedOutputStream bufOut = new BufferedOutputStream(socket.getOutputStream());
                    JBossObjectOutputStream objOut = new JBossObjectOutputStream(bufOut);

                     objOut.writeObject(new Integer(result));
                     objOut.flush();


                 }
                 catch(SocketException e)
                 {
View Full Code Here

public class SerialTestUtil {

    public static byte[] saveObjectIntoJBoss(Object obj) throws Exception
    {
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        JBossObjectOutputStream objOut = new JBossObjectOutputStream(byteOut);
        objOut.writeObject(obj);;

        return byteOut.toByteArray();
    }
View Full Code Here

  protected void writeContainer(String fileName, Object container) throws Exception
  {
       System.out.println("Serializing...");

       FileOutputStream fos = new FileOutputStream(fileName);
       JBossObjectOutputStream oos = new JBossObjectOutputStream(fos);
      
       oos.writeObject(container);
      
       oos.close();
       fos.close();

       // no exception... unit test passes
  }
View Full Code Here

/*    */   public byte[] serializeToByte(Object target)
/*    */     throws Exception
/*    */   {
/* 50 */     ByteArrayOutputStream baos = new ByteArrayOutputStream();
/* 51 */     OutputStream oos = new ObjectOutputStream(baos);
/* 52 */     JBossObjectOutputStream jbos = new JBossObjectOutputStream(oos);
/* 53 */     jbos.writeObject(target);
/* 54 */     jbos.close();
/*    */
/* 56 */     return baos.toByteArray();
/*    */   }
View Full Code Here

TOP

Related Classes of org.jboss.serial.io.JBossObjectOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.