Path: blob/master/test/jdk/java/nio/file/spi/m/p/Main.java
41161 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package p;2425import java.io.File;26import java.nio.file.FileSystem;27import java.nio.file.FileSystems;28import java.nio.file.Files;29import java.nio.file.Path;3031/**32* Launched by SetDefaultProvider to test startup with the default file system33* provider overridden.34*/3536public class Main {37public static void main(String[] args) throws Exception {38FileSystem fs = FileSystems.getDefault();39if (fs.getClass().getModule() == Object.class.getModule())40throw new RuntimeException("FileSystemProvider not overridden");4142// exercise the file system43Path dir = Files.createTempDirectory("tmp");44if (dir.getFileSystem() != fs)45throw new RuntimeException("'dir' not in default file system");46System.out.println("created: " + dir);4748Path foo = Files.createFile(dir.resolve("foo"));49if (foo.getFileSystem() != fs)50throw new RuntimeException("'foo' not in default file system");51System.out.println("created: " + foo);5253// exercise interop with java.io.File54File file = foo.toFile();55Path path = file.toPath();56if (path.getFileSystem() != fs)57throw new RuntimeException("'path' not in default file system");58if (!path.equals(foo))59throw new RuntimeException(path + " not equal to " + foo);60}61}626364