BundleFileSystem extends FileSystem { @Override public Path getPath(String first, String... more) { Path zipPath = getOrigFS().getPath(first, more); return wrap(zipPath); } protected  BundleFileSystem(FileSystem origFS, URI baseURI); @Override void close(); URI getBaseURI(); @Override Iterable<FileStore> getFileStores(); @Override Path getPath(String first, String... more); @Override PathMatcher getPathMatcher(String syntaxAndPattern); @Override Iterable<Path> getRootDirectories(); BundlePath getRootDirectory(); @Override String getSeparator(); Path getSource(); @Override UserPrincipalLookupService getUserPrincipalLookupService(); @Override boolean isOpen(); @Override boolean isReadOnly(); @Override WatchService newWatchService(); @Override BundleFileSystemProvider provider(); @Override Set<String> supportedFileAttributeViews();  }
@Test public void fileAndDirectory() throws Exception { Path folder = fs.getPath("folder"); assertFalse(Files.exists(folder)); Files.createFile(folder); assertTrue(Files.exists(folder)); assertTrue(Files.isRegularFile(folder)); assertFalse(Files.isDirectory(folder)); try { Files.createDirectory(folder); fail("Should have thrown FileAlreadyExistsException"); } catch (FileAlreadyExistsException ex) { } assertFalse(Files.isDirectory(folder)); try { Files.createDirectories(folder); fail("Should have thrown FileAlreadyExistsException"); } catch (FileAlreadyExistsException ex) { } assertFalse(Files.isDirectory(folder)); Path child = folder.resolve("child"); try { Files.createFile(child); fail("Should have thrown NoSuchFileException"); } catch (NoSuchFileException ex) { } assertFalse(Files.exists(child)); assertTrue(Files.isRegularFile(folder)); assertFalse(Files.isDirectory(folder)); assertFalse(Files.isDirectory(child.getParent())); assertFalse(Files.isDirectory(fs.getPath("folder/"))); }
@Test public void directoryAndFile() throws Exception { Path folderSlash = fs.getPath("folder/"); Path folder = fs.getPath("folder"); assertFalse(Files.exists(folderSlash)); Files.createDirectory(folderSlash); assertTrue(Files.exists(folderSlash)); assertFalse(Files.isRegularFile(folderSlash)); assertTrue(Files.isDirectory(folderSlash)); try { Files.createDirectory(folderSlash); fail("Should have thrown FileAlreadyExistsException"); } catch (FileAlreadyExistsException ex) { } try { Files.createFile(folderSlash); fail("Should have thrown IOException"); } catch (IOException ex) { } try { Files.createFile(folder); fail("Should have thrown IOException"); } catch (IOException ex) { } Path child = folderSlash.resolve("child"); Files.createFile(child); assertTrue(Files.exists(folder)); assertTrue(Files.exists(folderSlash)); assertFalse(Files.isRegularFile(folder)); assertFalse(Files.isRegularFile(folderSlash)); assertTrue(Files.isDirectory(folder)); assertTrue(Files.isDirectory(folderSlash)); }