/*
* 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.data.tests;
import org.jboss.serial.DataSerializationTest;
import org.jboss.serial.io.JBossObjectInputStream;
import org.jboss.serial.io.JBossObjectOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.lang.reflect.Array;
/**
* $Id: ObjectStreamingArrayTest.java 240 2006-04-25 19:39:51Z csuconic $
*
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
*/
public class ObjectStreamingArrayTest extends DataSerializationTest {
public void executTest(Object dataObject) throws Throwable
{
Object arrayObj[] = (Object[])Array.newInstance(dataObject.getClass(),10);
for (int i=0;i<arrayObj.length;i++)
{
arrayObj[i] = dataObject;
}
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
JBossObjectOutputStream objOut = new JBossObjectOutputStream(byteout);
objOut.writeObject(arrayObj);
objOut.flush();
JBossObjectInputStream objInput = new JBossObjectInputStream(new ByteArrayInputStream(byteout.toByteArray()));
Object newObject[] = (Object[]) objInput.readObject();
for (int i=1;i<newObject.length;i++)
{
assertSame("Should always be the same reference",newObject[0],newObject[i]);
}
assertEquals(dataObject,arrayObj[0]);
}
}