RDFXMLWriter implements WorkflowBundleWriter { @Override public void writeBundle(WorkflowBundle wfBundle, File destination, String mediaType) throws WriterException, IOException { UCFPackage ucfPackage = makeUCFPackage(wfBundle); ucfPackage.save(destination); }  static final URITools getUriTools(); static final void setUriTools(URITools uriTools); @Override Set<String> getMediaTypes(); @Override void writeBundle(WorkflowBundle wfBundle, File destination,
			String mediaType); @Override void writeBundle(WorkflowBundle wfBundle, OutputStream output,
			String mediaType); final String WORKFLOW_BUNDLE_VERSION; }
@Test public void awkwardFilenames() throws Exception { workflowBundle.getProfiles().removeByName("tavernaServer"); String funnyName = "Funny_%2f_characters_50%_of the time"; workflowBundle.getMainProfile().setName(funnyName); workflowBundle.getMainWorkflow().setName(funnyName); File bundleFile = tempFile(); bundleIO.writeBundle(workflowBundle, bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); UCFPackage ucfPackage = new UCFPackage(bundleFile); Map<String, ResourceEntry> profiles = ucfPackage.listResources("profile"); assertEquals(2, profiles.size()); assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time.rdf")); assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time/")); Map<String, ResourceEntry> workflows = ucfPackage.listResources("workflow"); assertEquals(1, workflows.size()); assertEquals("Funny_%252f_characters_50%25_of%20the%20time.rdf", workflows.keySet().iterator().next()); WorkflowBundle readBundle = bundleIO.readBundle(bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); assertEquals(funnyName, readBundle.getMainProfile().getName()); assertEquals(funnyName, readBundle.getMainWorkflow().getName()); JsonNode oldJson = workflowBundle.getMainProfile().getConfigurations().getByName("Hello").getJson(); assertTrue(oldJson.get("script").asText().startsWith("hello")); JsonNode newJson = readBundle.getMainProfile().getConfigurations().getByName("Hello").getJson(); assertTrue(newJson.get("script").asText().startsWith("hello")); assertEquals(oldJson, newJson); }
@Test public void writeBundleToFile() throws Exception { File bundleFile = tempFile(); bundleIO.writeBundle(workflowBundle, bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); UCFPackage ucfPackage = new UCFPackage(bundleFile); verifyRootFile(ucfPackage); verifyPackageStructure(ucfPackage); }
@Test public void writeBundleToStream() throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); bundleIO.writeBundle(workflowBundle, outStream, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); outStream.close(); InputStream inStream = new ByteArrayInputStream(outStream.toByteArray()); UCFPackage ucfPackage; try { System.setProperty("org.odftoolkit.odfdom.tmpfile.disable", "true"); ucfPackage = new UCFPackage(inStream); } finally { System.clearProperty("org.odftoolkit.odfdom.tmpfile.disable"); } verifyPackageStructure(ucfPackage); }