@Test public void testConstructor() throws NoSuchFieldException, IllegalAccessException, URISyntaxException, IOException { Field defaultFS = FileSystem.class.getDeclaredField("defaultFileSystem"); defaultFS.setAccessible(true); Field fsField = FileSystem.class.getDeclaredField("fs"); fsField.setAccessible(true); FileSystem fs = new FileSystem(new URI("sftp: assertFalse((Boolean)defaultFS.get(fs)); assertNotEquals(FileSystems.getDefault(), fsField.get(fs)); fs.close(); fs = new FileSystem(Paths.get("src").toUri()); assertEquals(1, logTester.logs(LoggerLevel.WARN).size()); assertTrue(logTester.logs(LoggerLevel.WARN).get(0).startsWith("Using default FS because of an error: ")); assertTrue((Boolean)defaultFS.get(fs)); assertEquals(FileSystems.getDefault(), fsField.get(fs)); logTester.clear(); FileSystem fs2 = new FileSystem(new URI("file: assertEquals(1, logTester.logs(LoggerLevel.WARN).size()); assertTrue(logTester.logs(LoggerLevel.WARN).get(0).startsWith("FS already exists for URI: ")); assertEquals(fsField.get(fs), fsField.get(fs2)); }
@Override public void close() throws IOException { if (!defaultFileSystem) { fs.close(); } }
FileSystem implements Closeable { @Override public void close() throws IOException { if (!defaultFileSystem) { fs.close(); } } }
FileSystem implements Closeable { @Override public void close() throws IOException { if (!defaultFileSystem) { fs.close(); } } FileSystem(URI uri); }
FileSystem implements Closeable { @Override public void close() throws IOException { if (!defaultFileSystem) { fs.close(); } } FileSystem(URI uri); @Override void close(); Stream<Path> readDirectory(URI uri); }
FileSystem implements Closeable { @Override public void close() throws IOException { if (!defaultFileSystem) { fs.close(); } } FileSystem(URI uri); @Override void close(); Stream<Path> readDirectory(URI uri);  }