Bundles { public static Bundle createBundle() throws IOException { BundleFileSystem fs = newFileSystemFromTemporary(); return new Bundle(fs.getRootDirectory(), true); }  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 closeDeleteTemp() throws Exception { Bundle bundle = Bundles.createBundle(); assertTrue(Files.exists(bundle.getSource())); assertTrue(bundle.getFileSystem().isOpen()); assertTrue(bundle.isDeleteOnClose()); bundle.close(); assertFalse(Files.exists(bundle.getSource())); assertFalse(bundle.getFileSystem().isOpen()); }
@Test public void closeNotDelete() throws Exception { Path path = Files.createTempFile("bundle", ".zip"); Bundle bundle = Bundles.createBundle(path); assertFalse(bundle.isDeleteOnClose()); assertTrue(Files.exists(bundle.getSource())); assertTrue(bundle.getFileSystem().isOpen()); bundle.close(); assertTrue(Files.exists(bundle.getSource())); assertFalse(bundle.getFileSystem().isOpen()); }
@Test public void createBundle() throws Exception { Path source = null; try (Bundle bundle = Bundles.createBundle()) { assertTrue(Files.isDirectory(bundle.getRoot())); source = bundle.getSource(); assertTrue(Files.exists(source)); } assertFalse(Files.exists(source)); }
@Test public void createBundlePath() throws Exception { Path source = Files.createTempFile("test", ".zip"); source.toFile().deleteOnExit(); Files.delete(source); try (Bundle bundle = Bundles.createBundle(source)) { assertTrue(Files.isDirectory(bundle.getRoot())); assertEquals(source, bundle.getSource()); assertTrue(Files.exists(source)); } assertTrue(Files.exists(source)); }
@Test public void createBundlePathExists() throws Exception { Path source = Files.createTempFile("test", ".zip"); source.toFile().deleteOnExit(); assertTrue(Files.exists(source)); try (Bundle bundle = Bundles.createBundle(source)) { } assertTrue(Files.exists(source)); }
@Test(expected = IOException.class) public void createBundleExistsAsDirFails() throws Exception { Path source = Files.createTempDirectory("test"); source.toFile().deleteOnExit(); try (Bundle bundle = Bundles.createBundle(source)) { } }