/** * Verifies that the specified XML file is a valid serialization of the * project. * * @param fileName * the file name */ protected void ensureSerialization(final String fileName) { try { File file = new File(getClass().getResource(fileName).toURI()); XmlFile xmlFile = createXmlFile(file); Object deserialized = xmlFile.read(); FileAnnotation[] files = (FileAnnotation[]) deserialized; JavaProject project = new JavaProject(); project.addAnnotations(files); verifyProject(project); } catch (URISyntaxException exception) { throw new IllegalArgumentException(exception); } catch (IOException exception) { throw new IllegalArgumentException(exception); } } }
/** * Test whether a serialized task is the same object after deserialization. * * @throws Exception Signals a test failure */ @Test public void testObjectIsSameAfterDeserialization() throws Exception { JavaProject original = createOriginal(); // Collection<FileAnnotation> files = original.getAnnotations(); // createXmlFile(new File("/home/hafner/project.ser.xml")).write(files.toArray(new FileAnnotation[files.size()])); ByteArrayOutputStream outputStream = serialize(original); JavaProject copy = deserialize(outputStream.toByteArray()); verifyProject(copy); verifyFirstAnnotation(copy); }
/** * Test whether a serialized task is the same object after deserialization. * * @throws Exception Signals a test failure */ @Test public void testObjectIsSameAfterDeserialization() throws Exception { JavaProject original = createOriginal(); // Collection<FileAnnotation> files = original.getAnnotations(); // createXmlFile(new File("/home/hafner/project.ser.xml")).write(files.toArray(new FileAnnotation[files.size()])); ByteArrayOutputStream outputStream = serialize(original); JavaProject copy = deserialize(outputStream.toByteArray()); verifyProject(copy); verifyFirstAnnotation(copy); }
verifyProject(project); verifyFirstAnnotation(project);
verifyProject(project); verifyFirstAnnotation(project);