[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-cvs-commits
Subject:    [jboss-cvs] jboss-serialization/tests/org/jboss/serial/data/tests   ...
From:       Clebert Suconic <csuconic () jboss ! com>
Date:       2005-09-30 23:24:15
Message-ID: E1ELUEh-00020Y-Df () committer01 ! frg ! pub ! inap ! atl ! jboss ! com
[Download RAW message or body]

  User: csuconic
  Date: 05/09/30 19:24:15

  Added:       tests/org/jboss/serial/data/tests   SerialTestUtil.java
                        TreeSetTestCase.java
  Log:
  Adding testcase with TreeSet
  
  Revision  Changes    Path
  1.1      date: 2005/09/30 23:24:15;  author: csuconic;  state: \
Exp;jboss-serialization/tests/org/jboss/serial/data/tests/SerialTestUtil.java  
  Index: SerialTestUtil.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package org.jboss.serial.data.tests;
  
  import org.jboss.serial.io.JBossObjectOutputStream;
  import org.jboss.serial.io.JBossObjectInputStream;
  
  import java.io.ByteArrayOutputStream;
  import java.io.ByteArrayInputStream;
  
  /**
   * $Id: SerialTestUtil.java,v 1.1 2005/09/30 23:24:15 csuconic Exp $
   *
   * @author <a href="mailto:tclebert.suconic@jboss.com">Clebert Suconic</a>
   */
  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();
      }
  
      public static Object readObjectIntoJBoss(byte[] byteArray) throws Exception
      {
          ByteArrayInputStream byteInp = new ByteArrayInputStream(byteArray);
          JBossObjectInputStream objInp = new JBossObjectInputStream(byteInp);
          return objInp.readObject();
      }
  }
  
  
  
  1.1      date: 2005/09/30 23:24:15;  author: csuconic;  state: \
Exp;jboss-serialization/tests/org/jboss/serial/data/tests/TreeSetTestCase.java  
  Index: TreeSetTestCase.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package org.jboss.serial.data.tests;
  
  import junit.framework.TestCase;
  
  import java.util.TreeSet;
  
  import org.jboss.serial.data.TestWithBigDecimal;
  
  /**
   * $Id: TreeSetTestCase.java,v 1.1 2005/09/30 23:24:15 csuconic Exp $
   *
   * @author <a href="mailto:tclebert.suconic@jboss.com">Clebert Suconic</a>
   */
  public class TreeSetTestCase extends TestCase {
  
  
      public void testTreeSet() throws Exception
      {
  
          for (int j=0;j<10;j++)
          {
              TreeSet tset = new TreeSet(new TestWithBigDecimal());
  
  
              for (int i=0;i<100;i++)
              {
                  tset.add(TestWithBigDecimal.createTestInstance());
              }
  
  
              byte [] byteOut = SerialTestUtil.saveObjectIntoJBoss(tset);
              TreeSet newTest  = \
(TreeSet)SerialTestUtil.readObjectIntoJBoss(byteOut);  
  
              assertEquals(tset,newTest);
          }
      }
  }
  
  
  


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic