TAVERNA-1044: Test combine archive parsing from JWS Online

.. and a suggested fix variant


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/e33a636e
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/e33a636e
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/e33a636e

Branch: refs/heads/master
Commit: e33a636ed2d3dfe01df8fb01bafe39fde50f2d76
Parents: 72899c6
Author: Stian Soiland-Reyes <[email protected]>
Authored: Thu May 10 11:20:44 2018 +0100
Committer: Stian Soiland-Reyes <[email protected]>
Committed: Thu May 10 11:20:44 2018 +0100

----------------------------------------------------------------------
 .../manifest/combine/TestCombineManifest.java   | 95 +++++++++++++++++++-
 1 file changed, 93 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/e33a636e/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/combine/TestCombineManifest.java
----------------------------------------------------------------------
diff --git 
a/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/combine/TestCombineManifest.java
 
b/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/combine/TestCombineManifest.java
index 7fc54ed..4ac0dfa 100644
--- 
a/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/combine/TestCombineManifest.java
+++ 
b/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/combine/TestCombineManifest.java
@@ -8,9 +8,9 @@ package org.apache.taverna.robundle.manifest.combine;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,6 +21,8 @@ package org.apache.taverna.robundle.manifest.combine;
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.InputStream;
@@ -28,6 +30,8 @@ import java.net.URI;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
+import java.time.Instant;
 
 import org.apache.taverna.robundle.Bundle;
 import org.apache.taverna.robundle.Bundles;
@@ -152,4 +156,91 @@ public class TestCombineManifest {
                }
        }
 
+       @Test
+       public void convertJWSOnlineBroken() throws Exception {
+               Path file = Files.createTempFile("jwsonline-broken", ".omex");
+               try (InputStream src = getClass().getResourceAsStream(
+                               "/combine/jwsonline-broken-date.sedx")) {
+                       Files.copy(src, file, 
StandardCopyOption.REPLACE_EXISTING);
+               }
+               System.out.println(file);
+               try (Bundle bundle = Bundles.openBundle(file)) {
+                       Manifest manifest = bundle.getManifest();
+
+                       Path sedml = 
bundle.getPath("/sedml/testtavernalanguage-user.sedml");
+                       assertTrue(Files.isRegularFile(sedml));
+                       PathMetadata sedMlAggr = manifest.getAggregation(sedml);
+                       
assertEquals(URI.create("http://identifiers.org/combine.specifications/sed-ml.level-1.version-3";),
+                                       sedMlAggr.getConformsTo());
+
+                       Path metadataXml = bundle.getPath("/metadata.rdf");
+                       assertTrue(Files.isRegularFile(metadataXml));
+                       PathMetadata metadataAggr = 
manifest.getAggregation(metadataXml);
+                       
assertEquals(URI.create("http://identifiers.org/combine.specifications/omex-metadata";),
+                                       metadataAggr.getConformsTo());
+
+                       Path manifestXml = 
bundle.getRoot().resolve("manifest.xml");
+                       assertTrue("manifest.xml not listed in " + 
manifest.getManifest(),
+                                       
manifest.getManifest().contains(manifestXml));
+
+                       // TAVERNA-1044: Can we still parse dcterms:rreator 
even if there
+                       // is an RDF/XML syntactic error elsewhere?
+                       Agent createdBy = manifest.getCreatedBy();
+                       assertNotNull("Did not parse dcterms:creator", 
createdBy);
+                       assertEquals(URI.create("mbox:[email protected]"),
+                                       createdBy.getUri());
+
+                       /**
+                        * TAVERNA-1044 - invalid RDF/XML from JWS Online means 
we can't parse
+                        * dcterms:created correctly
+                        */
+                       //FileTime createdOn = manifest.getCreatedOn();
+                       //assertEquals(Instant.parse("2018-05-08T07:35:49Z"), 
createdOn.toInstant());
+                       
+               }
+
+       }
+
+
+       @Test
+       public void convertJWSOnlineFixed() throws Exception {
+               Path file = Files.createTempFile("jwsonline-fixed", ".omex");
+               try (InputStream src = getClass().getResourceAsStream(
+                               "/combine/jwsonline-fixed-date.sedx")) {
+                       Files.copy(src, file, 
StandardCopyOption.REPLACE_EXISTING);
+               }
+               System.out.println(file);
+               try (Bundle bundle = Bundles.openBundle(file)) {
+                       Manifest manifest = bundle.getManifest();
+                       Path manifestXml = 
bundle.getRoot().resolve("manifest.xml");
+                       assertTrue("manifest.xml not listed in " + 
manifest.getManifest(),
+                                       
manifest.getManifest().contains(manifestXml));
+
+
+                       Path sedml = 
bundle.getPath("/sedml/testtavernalanguage-user.sedml");
+                       assertTrue(Files.isRegularFile(sedml));
+                       PathMetadata sedMlAggr = manifest.getAggregation(sedml);
+                       
assertEquals(URI.create("http://identifiers.org/combine.specifications/sed-ml.level-1.version-3";),
+                                       sedMlAggr.getConformsTo());
+
+                       Path metadataXml = bundle.getPath("/metadata.rdf");
+                       assertTrue(Files.isRegularFile(metadataXml));
+                       PathMetadata metadataAggr = 
manifest.getAggregation(metadataXml);
+                       
assertEquals(URI.create("http://identifiers.org/combine.specifications/omex-metadata";),
+                                       metadataAggr.getConformsTo());
+
+
+                       // Metadata about the COMBINE archive itself, aka the 
RO,
+                       // correctly parsed from metadata.rdf
+                       Agent createdBy = manifest.getCreatedBy();
+                       assertNotNull("Did not parse dcterms:creator", 
createdBy);
+                       assertEquals(URI.create("mbox:[email protected]"),
+                                       createdBy.getUri());
+
+                       FileTime createdOn = manifest.getCreatedOn();
+                       assertEquals(Instant.parse("2018-05-08T07:35:49Z"), 
createdOn.toInstant());
+               }
+
+       }
+
 }

Reply via email to