TAVERNA-1044: Test combine archive parsing from JWS Online

.. and a suggested fix variant
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 @@
  * 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 @@
 
 
 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.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 @@
 		}
 	}
 
+	@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:stain@apache.org"),
+					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:stain@apache.org"),
+					createdBy.getUri());
+
+			FileTime createdOn = manifest.getCreatedOn();
+			assertEquals(Instant.parse("2018-05-08T07:35:49Z"), createdOn.toInstant());
+		}
+
+	}
+
 }