ManifestMerger { public File createMergedManifest(File[] manifestFiles, Date creationTime, File productDir, long productSize) throws IOException, TransformerException, PDUStitchingException, ParserConfigurationException { final Document document = mergeManifests(manifestFiles, creationTime, productDir, productSize); final File manifestFile = new File(productDir, "xfdumanifest.xml"); final TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setAttribute("indent-number", 2); final Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http: transformer.setOutputProperty(OutputKeys.STANDALONE, "no"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); final DOMSource domSource = new DOMSource(document); final StringWriter stringWriter = new StringWriter(); final StreamResult streamResult = new StreamResult(stringWriter); transformer.transform(domSource, streamResult); String docAsString = stringWriter.toString(); docAsString = docAsString.replace(" standalone=\"no\"", ""); final FileWriter fileWriter = new FileWriter(manifestFile); fileWriter.write(docAsString); fileWriter.close(); return manifestFile; }  File createMergedManifest(File[] manifestFiles, Date creationTime, File productDir, long productSize);  }
@Test public void testMergeManifests_OneFile() throws IOException, ParserConfigurationException, TransformerException, PDUStitchingException { final File inputManifest = getManifestFile(TestUtils.FIRST_FILE_NAME); final Date now = Calendar.getInstance().getTime(); final File productDir = new File(ManifestMergerTest.class.getResource("").getFile()); final File manifestFile = manifestMerger.createMergedManifest(new File[]{inputManifest}, now, productDir, 5000); assertTrue(manifestFile.exists()); }
@Test public void testMergeManifests_MultipleFiles() throws IOException, ParserConfigurationException, TransformerException, PDUStitchingException { final Date now = Calendar.getInstance().getTime(); final File productDir = new File(ManifestMergerTest.class.getResource("").getFile()); final File manifestFile = manifestMerger.createMergedManifest(getManifestFiles(), now, productDir, 5000); assertTrue(manifestFile.exists()); }