1 37 package net.sourceforge.cruisecontrol; 38 39 import java.io.ByteArrayInputStream ; 40 import java.io.ByteArrayOutputStream ; 41 import java.io.IOException ; 42 import java.io.ObjectOutputStream ; 43 import java.io.ObjectInputStream ; 44 import junit.framework.Test; 45 import junit.framework.TestCase; 46 import junit.framework.TestSuite; 47 48 49 53 public class BuildInfoSummaryTest extends TestCase { 54 public static Test suite() { 55 return new LogFileSetupDecorator(new TestSuite(BuildInfoSummaryTest.class)); 56 } 57 58 public BuildInfoSummaryTest(String testName) { 59 super(testName); 60 } 61 62 public void testSerializable() throws ClassNotFoundException , IOException { 63 ByteArrayOutputStream out = new ByteArrayOutputStream (); 64 ObjectOutputStream serializer = new ObjectOutputStream (out); 65 BuildInfoSummary original = BuildInfo.loadFromDir(LogFileSetupDecorator.LOG_DIR); 66 serializer.writeObject(original); 67 68 ByteArrayInputStream in = new ByteArrayInputStream (out.toByteArray()); 69 ObjectInputStream deserializer = new ObjectInputStream (in); 70 BuildInfoSummary deserialized = (BuildInfoSummary) deserializer.readObject(); 71 72 assertEquals(deserialized.getNumBrokenBuilds(), original.getNumBrokenBuilds()); 73 assertEquals(deserialized.getNumSuccessfulBuilds(), original.getNumSuccessfulBuilds()); 74 assertEquals(deserialized.size(), original.size()); 75 } 76 } 77 | Popular Tags |