Package org.jboss.serial.regression.jbser74

Source Code of org.jboss.serial.regression.jbser74.TestTWOJVM

/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.serial.regression.jbser74;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.jboss.serial.io.JBossObjectInputStream;
import org.jboss.serial.io.JBossObjectOutputStream;

import junit.framework.TestCase;

public abstract class TestTWOJVM extends TestCase
{
     protected Container getGoodContainer()
  {
    Container container = new Container();
      ConcreteObject a = new ConcreteObject();
      InterfaceObject as[] = new InterfaceObject[] { a };    // this is line which is different between a good container and a bad one
      container.ias = as;
      return container;
  }
 
  protected Container getBadContainer()
  {
    Container container = new Container();
      ConcreteObject a = new ConcreteObject();
      ConcreteObject as[] = new ConcreteObject[] { a };   // this is line which is different between a good container and a bad one
      container.ias = as;
      return container;
  }
 
  public Object read(String fileName) throws Exception
  {
       System.out.println("De-serializing...");    
      
       String tmp= System.getProperty("java.io.tmpdir") + "/";
      
       FileInputStream fis = new FileInputStream(tmp + fileName);
       JBossObjectInputStream ois = new JBossObjectInputStream(fis);
      
       Object data = ois.readObject();   
      
       ois.close();
       fis.close();
      
       return data;

       // no exception... unit test passes
  }
 
  protected void writeContainer(String fileName, Object container) throws Exception
  {
       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
  }


}
TOP

Related Classes of org.jboss.serial.regression.jbser74.TestTWOJVM

TOP
Copyright © 2018 www.massapi.com. 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.