Path: blob/master/test/jdk/java/io/pathNames/GeneralSolaris.java
41149 views
/*1* Copyright (c) 2013, 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*/2223/* @test24@bug 4035924 409576725@summary General exhaustive test of solaris pathname handling26@author Mark Reinhold2728@build General GeneralSolaris29@run main GeneralSolaris30*/3132import java.io.*;33import java.util.*;34import java.nio.file.*;35import java.nio.file.attribute.*;3637public class GeneralSolaris extends General {3839private static void checkUnreadable() throws Exception {40Path file = Paths.get(baseDir, "unreadableFile");41Path dir = Paths.get(baseDir, "unreadableDir");42Set<PosixFilePermission> perms = PosixFilePermissions.fromString("---------");43FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);44Files.createFile(file, attr);45Files.createDirectory(dir, attr);4647String unreadableFile = file.toString();48String unreadableDir = dir.toString();4950checkSlashes(2, false, unreadableDir, unreadableDir);51checkSlashes(2, false, unreadableFile, unreadableFile);5253Files.delete(file);54Files.delete(dir);55}5657private static void checkPaths() throws Exception {58// Make sure that an empty relative path is tested59checkNames(1, true, userDir + File.separator, "");60checkNames(3, true, baseDir + File.separator,61relative + File.separator);6263checkSlashes(2, true, baseDir, baseDir);64}6566public static void main(String[] args) throws Exception {67if (File.separatorChar != '/') {68/* This test is only valid on Unix systems */69return;70}71if (args.length > 0) debug = true;7273initTestData(3);74checkUnreadable();75checkPaths();76}77}787980