Bundles { public static Bundle openBundle(InputStream in) throws IOException { Path path = temporaryBundle(); copy(in, path); Bundle bundle = openBundle(path); bundle.setDeleteOnClose(true); return bundle; }  static void closeAndSaveBundle(Bundle bundle, Path destination); static Path closeBundle(Bundle bundle); static void copyRecursively(final Path source,
			final Path destination, final CopyOption... copyOptions); static Bundle createBundle(); static Bundle createBundle(Path path); static void deleteRecursively(Path p); static Path getAnnotations(Bundle bundle); static Path getManifestPath(Bundle bundle); static String getMimeType(Bundle bundle); static URI getReference(Path path); static String getStringValue(Path path); static boolean isMissing(Path item); static boolean isReference(Path path); static boolean isValue(Path path); static Bundle openBundle(InputStream in); static Bundle openBundle(Path zip); static Bundle openBundle(URL url); static Bundle openBundleReadOnly(Path zip); static void safeCopy(Path source, Path destination); static void safeMove(Path source, Path destination); static void setMimeType(Bundle bundle, String mimetype); static Path setReference(Path path, URI ref); static void setStringValue(Path path, String string); static Path uriToBundlePath(Bundle bundle, URI uri);  }
@Test public void openBundleInputStream() throws Exception { try (InputStream stream = getClass().getResourceAsStream( "/workflowrun.bundle.zip")) { assertNotNull(stream); try (Bundle b = Bundles.openBundle(stream)) { checkWorkflowrunBundle(b); } } }
@Test public void openBundleURL() throws Exception { Path temp = Files.createTempFile("workflowrun", ".bundle.zip"); try (InputStream stream = getClass().getResourceAsStream( "/workflowrun.bundle.zip")) { Files.copy(stream, temp, StandardCopyOption.REPLACE_EXISTING); } URL url = temp.toUri().toURL(); try (Bundle b = Bundles.openBundle(url)) { checkWorkflowrunBundle(b); } }
@Test public void openBundleURLNonFile() throws Exception { final URL url = getClass().getResource("/workflowrun.bundle.zip"); assertNotNull(url); URLStreamHandler handler = new URLStreamHandler() { @Override protected URLConnection openConnection(URL u) throws IOException { return url.openConnection(); } }; URL testUrl = new URL("test", "test", 0, "test", handler); try (Bundle b = Bundles.openBundle(testUrl)) { checkWorkflowrunBundle(b); } }