1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 @bug 4035924 4095767 26 @summary General exhaustive test of solaris pathname handling 27 @author Mark Reinhold 28 29 @build General GeneralSolaris 30 @run main GeneralSolaris 31 */ 32 33 import java.io.*; 34 import java.util.*; 35 import java.nio.file.*; 36 import java.nio.file.attribute.*; 37 38 public class GeneralSolaris extends General { 39 checkUnreadable()40 private static void checkUnreadable() throws Exception { 41 Path file = Paths.get(baseDir, "unreadableFile"); 42 Path dir = Paths.get(baseDir, "unreadableDir"); 43 Set<PosixFilePermission> perms = PosixFilePermissions.fromString("---------"); 44 FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); 45 Files.createFile(file, attr); 46 Files.createDirectory(dir, attr); 47 48 String unreadableFile = file.toString(); 49 String unreadableDir = dir.toString(); 50 51 checkSlashes(2, false, unreadableDir, unreadableDir); 52 checkSlashes(2, false, unreadableFile, unreadableFile); 53 54 Files.delete(file); 55 Files.delete(dir); 56 } 57 checkPaths()58 private static void checkPaths() throws Exception { 59 // Make sure that an empty relative path is tested 60 checkNames(1, true, userDir + File.separator, ""); 61 checkNames(3, true, baseDir + File.separator, 62 relative + File.separator); 63 64 checkSlashes(2, true, baseDir, baseDir); 65 } 66 main(String[] args)67 public static void main(String[] args) throws Exception { 68 if (File.separatorChar != '/') { 69 /* This test is only valid on Unix systems */ 70 return; 71 } 72 if (args.length > 0) debug = true; 73 74 initTestData(3); 75 checkUnreadable(); 76 checkPaths(); 77 } 78 } 79