@@ -0,0 +1,2027 @@
+/*%0A *                    BioJava development code%0A *%0A * This code may be freely distributed and modified under the%0A * terms of the GNU Lesser General Public Licence.  This should%0A * be distributed with the code.  If you do not have a copy,%0A * see:%0A *%0A *      http://www.gnu.org/copyleft/lesser.html%0A *%0A * Copyright for this code is held jointly by the individual%0A * authors.  These should be listed in @author doc comments.%0A *%0A * For more information on the BioJava project and its aims,%0A * or to join the biojava-l mailing list, visit the home page%0A * at:%0A *%0A *      http://www.biojava.org/%0A *%0A */%0Apackage org.biojava.nbio.structure;%0A%0Aimport org.biojava.nbio.structure.io.PDBFileReader;%0Aimport org.junit.Test;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0A%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * Test the serialization of BioJava structure objects.%0A * %0A * @author Aleix Lafita%0A *%0A */%0Apublic class TestStructureSerialization %7B%0A%0A%09@Test%0A%09public void testSerializeStructure() throws IOException, StructureException, ClassNotFoundException %7B%0A%0A%09%09PDBFileReader reader = new PDBFileReader();%0A%09%09Structure sin = reader.getStructure(%22src/test/resources/2gox.pdb%22);%0A%0A%09%09// Serialize the structure object and keep it in memory%0A%09%09ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A%09%09ObjectOutputStream objectOut = new ObjectOutputStream(baos);%0A%09%09objectOut.writeObject(sin);%0A%09%09objectOut.close();%0A%09%09byte%5B%5D bytes = baos.toByteArray();%0A%09%09%0A%09%09// Deserialize the bytes back into a structure object%0A%09%09ByteArrayInputStream bais = new ByteArrayInputStream(bytes);%0A%09%09ObjectInputStream objectIn = new ObjectInputStream(bais);%0A%09%09Structure sout = (Structure) objectIn.readObject();%0A%09%09objectIn.close();%0A%09%09%0A%09%09// Test some properties of the structures%0A%09%09assertEquals(sin.nrModels(), sout.nrModels());%0A%09%09assertEquals(sin.getChains().size(), sout.getChains().size());%0A%09%09assertEquals(sin.getName(), sout.getName());%0A%09%09%0A%09%7D%0A%7D%0A

Test Structure serialization