removed lower-level tests now handled by robundle
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/28ecd64d Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/28ecd64d Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/28ecd64d Branch: refs/heads/ucfpackage-robundle Commit: 28ecd64d8cb348500905117b190521c0b738251e Parents: 3300b84 Author: Stian Soiland-Reyes <[email protected]> Authored: Thu Jul 2 15:47:35 2015 +0100 Committer: Stian Soiland-Reyes <[email protected]> Committed: Thu Jul 2 15:47:35 2015 +0100 ---------------------------------------------------------------------- .../scufl2/ucfpackage/TestUCFPackage.java | 218 ------------------- 1 file changed, 218 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/28ecd64d/taverna-scufl2-ucfpackage/src/test/java/org/apache/taverna/scufl2/ucfpackage/TestUCFPackage.java ---------------------------------------------------------------------- diff --git a/taverna-scufl2-ucfpackage/src/test/java/org/apache/taverna/scufl2/ucfpackage/TestUCFPackage.java b/taverna-scufl2-ucfpackage/src/test/java/org/apache/taverna/scufl2/ucfpackage/TestUCFPackage.java index ec5a942..7bf9157 100644 --- a/taverna-scufl2-ucfpackage/src/test/java/org/apache/taverna/scufl2/ucfpackage/TestUCFPackage.java +++ b/taverna-scufl2-ucfpackage/src/test/java/org/apache/taverna/scufl2/ucfpackage/TestUCFPackage.java @@ -130,42 +130,6 @@ public class TestUCFPackage { container.getPackageMediaType()); } - @Test - public void mimeTypePosition() throws Exception { - UCFPackage container = new UCFPackage(); - container.setPackageMediaType(UCFPackage.MIME_EPUB); - assertEquals(UCFPackage.MIME_EPUB, container.getPackageMediaType()); - container.save(tmpFile); - - assertTrue(tmpFile.exists()); - ZipFile zipFile = new ZipFile(tmpFile); - // Must be first entry - ZipEntry mimeEntry = zipFile.entries().nextElement(); - assertEquals("First zip entry is not 'mimetype'", "mimetype", - mimeEntry.getName()); - assertEquals( - "mimetype should be uncompressed, but compressed size mismatch", - mimeEntry.getCompressedSize(), mimeEntry.getSize()); - assertEquals("mimetype should have STORED method", ZipEntry.STORED, - mimeEntry.getMethod()); - assertEquals("Wrong mimetype", UCFPackage.MIME_EPUB, - IOUtils.toString(zipFile.getInputStream(mimeEntry), "ASCII")); - - // Check position 30++ according to - // http://livedocs.adobe.com/navigator/9/Navigator_SDK9_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Navigator_SDK9_HTMLHelp&file=Appx_Packaging.6.1.html#1522568 - byte[] expected = ("mimetype" + UCFPackage.MIME_EPUB + "PK") - .getBytes("ASCII"); - FileInputStream in = new FileInputStream(tmpFile); - byte[] actual = new byte[expected.length]; - try { - assertEquals(MIME_OFFSET, in.skip(MIME_OFFSET)); - assertEquals(expected.length, in.read(actual)); - } finally { - in.close(); - } - assertArrayEquals(expected, actual); - } - @Before public void createTempFile() throws IOException { tmpFile = File.createTempFile("scufl2-test", ".bundle"); @@ -601,188 +565,6 @@ public class TestUCFPackage { assertNull(xpathSelectElement(doc.getRootElement(), "/manifest:manifest/*")); } -// -// @Test -// public void getRootfiles() throws Exception { -// UCFPackage container = new UCFPackage(); -// container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE); -// container.addResource("Hello there", "helloworld.txt", "text/plain"); -// assertTrue("Root files not empty", container.getRootFiles().isEmpty()); -// assertNotSame("Should return copy of rootfiles", -// container.getRootFiles(), container.getRootFiles()); -// } -// -// @Test -// public void setRootfile() throws Exception { -// UCFPackage container = new UCFPackage(); -// container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE); -// container.addResource("Hello there", "helloworld.txt", "text/plain"); -// container.addResource("Soup for everyone", "soup.txt", "text/plain"); -// container.setRootFile("helloworld.txt"); -// -// List<ResourceEntry> rootFiles = container.getRootFiles(); -// -// assertEquals(1, rootFiles.size()); -// ResourceEntry rootFile = rootFiles.get(0); -// assertEquals("helloworld.txt", rootFile.getPath()); -// assertEquals("text/plain", rootFile.getMediaType()); -// } -// -// @Test -// public void setRootfileSaved() throws Exception { -// UCFPackage container = new UCFPackage(); -// container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE); -// container.addResource("Hello there", "helloworld.txt", "text/plain"); -// container.addResource("Soup for everyone", "soup.txt", "text/plain"); -// container.setRootFile("helloworld.txt"); -// container.save(tmpFile); -// -// ZipFile zipFile = new ZipFile(tmpFile); -// ZipEntry manifestEntry = zipFile.getEntry("META-INF/container.xml"); -// InputStream manifestStream = zipFile.getInputStream(manifestEntry); -// -// -// //System.out.println(IOUtils.toString(manifestStream, "UTF-8")); -// /* -//<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -//<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/04/xmlenc#"> -// <rootFiles> -// <rootFile full-path="helloworld.txt" media-type="text/plain"/> -// </rootFiles> -//</container> -// */ -// Document doc = parseXml(manifestStream); -// assertEquals(CONTAINER_NS, doc.getRootElement().getNamespace()); -// assertEquals("", doc.getRootElement().getNamespacePrefix()); -// assertEquals("container", doc.getRootElement().getQualifiedName()); -// assertXpathEquals("helloworld.txt", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile/@full-path"); -// assertXpathEquals("text/plain", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile/@media-type"); -// -// } - - @Test - public void addResourceContainerXml() throws Exception { - UCFPackage container = new UCFPackage(); - container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE); - container.addResource("Hello there", "helloworld.txt", "text/plain"); - container.addResource("Soup for everyone", "soup.txt", "text/plain"); - - container.save(tmpFile); - - ZipFile zipFile = new ZipFile(tmpFile); - ZipEntry manifestEntry = zipFile.getEntry("META-INF/container.xml"); - InputStream manifestStream = zipFile.getInputStream(manifestEntry); - - //System.out.println(IOUtils.toString(manifestStream, "UTF-8")); - /* -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/04/xmlenc#"> - <ex:example xmlns:ex="http://example.com/">first example</ex:example> - <rootFiles> - <rootFile xmlns:ex="http://example.com/" full-path="soup.txt" media-type="text/plain" ex:extraAnnotation="hello"/> - </rootFiles> - <ex:example xmlns:ex="http://example.com/">second example</ex:example> - <ex:example xmlns:ex="http://example.com/">third example</ex:example> -</container> - */ - Document doc = parseXml(manifestStream); - assertEquals(CONTAINER_NS, doc.getRootElement().getNamespace()); - assertEquals("", doc.getRootElement().getNamespacePrefix()); - assertEquals("container", doc.getRootElement().getQualifiedName()); - - assertXpathEquals("first example", doc.getRootElement(), "/c:container/ex:example[1]"); - assertXpathEquals("second example", doc.getRootElement(), "/c:container/ex:example[2]"); - assertXpathEquals("third example", doc.getRootElement(), "/c:container/ex:example[3]"); - - // Check order - Element first = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[1]"); - assertEquals("ex:example", first.getQualifiedName()); -// Element second = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[2]"); -// assertEquals("rootFiles", second.getQualifiedName()); - Element third = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[3]"); - assertEquals("ex:example", third.getQualifiedName()); - Element fourth = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[4]"); - assertEquals("ex:example", fourth.getQualifiedName()); - - - - } - - @Test - public void setRootfileExtendsContainerXml() throws Exception { - UCFPackage container = new UCFPackage(); - container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE); - container.addResource("Hello there", "helloworld.txt", "text/plain"); - container.addResource("<html><body><h1>Yo</h1></body></html>", - "helloworld.html", "text/html"); - - String containerXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" - + "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" xmlns:ex='http://example.com/' xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:ns3=\"http://www.w3.org/2001/04/xmlenc#\">\n" - + " <rootFiles>\n" - + " <rootFile ex:extraAnnotation='hello' media-type=\"text/html\" full-path=\"helloworld.html\"/>\n" - + " </rootFiles>\n" - + " <ex:example>more example</ex:example>\n" - + "</container>\n"; - // Should overwrite setRootFile() - container.addResource(containerXml, "META-INF/container.xml", - "text/xml"); -// assertEquals("helloworld.html", container.getRootFiles().get(0) -// .getPath()); - -// container.setRootFile("helloworld.txt"); -// assertEquals("helloworld.html", container.getRootFiles().get(0) -// .getPath()); -// assertEquals("helloworld.txt", container.getRootFiles().get(1) -// .getPath()); - container.save(tmpFile); -// -// String expectedContainerXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" -// + "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:ns3=\"http://www.w3.org/2001/04/xmlenc#\">\n" -// + " <rootFiles>\n" -// + " <rootFile xmlns:ex=\"http://example.com/\" media-type=\"text/html\" full-path=\"helloworld.html\" ex:extraAnnotation=\"hello\"/>\n" -// + " <rootFile media-type=\"text/plain\" full-path=\"helloworld.txt\"/>\n" -// + " </rootFiles>\n" -// + " <ex:example xmlns:ex=\"http://example.com/\">more example</ex:example>\n" -// + -// "</container>\n"; - - ZipFile zipFile = new ZipFile(tmpFile); - ZipEntry manifestEntry = zipFile.getEntry("META-INF/container.xml"); - InputStream manifestStream = zipFile.getInputStream(manifestEntry); - - //System.out.println(IOUtils.toString(manifestStream, "UTF-8")); - /* -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/04/xmlenc#"> - <rootFiles> - <rootFile xmlns:ex="http://example.com/" full-path="helloworld.html" media-type="text/html" ex:extraAnnotation="hello"/> - <rootFile full-path="helloworld.txt" media-type="text/plain"/> - </rootFiles> - <ex:example xmlns:ex="http://example.com/">more example</ex:example> -</container> - */ - Document doc = parseXml(manifestStream); - assertEquals(CONTAINER_NS, doc.getRootElement().getNamespace()); - assertEquals("", doc.getRootElement().getNamespacePrefix()); - assertEquals("container", doc.getRootElement().getQualifiedName()); - assertXpathEquals("helloworld.html", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@full-path"); - assertXpathEquals("text/html", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@media-type"); - assertXpathEquals("hello", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@ex:extraAnnotation"); - - - assertXpathEquals("helloworld.txt", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[2]/@full-path"); - assertXpathEquals("text/plain", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[2]/@media-type"); - - assertXpathEquals("more example", doc.getRootElement(), "/c:container/ex:example"); - - // Check order - Element first = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[1]"); - assertEquals("rootFiles", first.getQualifiedName()); - Element second = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[2]"); - assertEquals("ex:example", second.getQualifiedName()); - - } -
