< prev index next >

test/java/nio/file/Path/MacPathTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 19,51 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* @test * @bug 7130915 * @summary Tests file path with nfc/nfd forms on MacOSX ! * @library ../ ! * @build MacPathTest ! * @run shell MacPathTest.sh */ ! import java.nio.file.*; ! import java.nio.file.attribute.*; ! import java.text.*; ! import java.util.*; ! import java.util.regex.*; public class MacPathTest { public static void main(String args[]) throws Throwable { ! String osname = System.getProperty("os.name"); ! if (!osname.contains("OS X") && !osname.contains("Darwin")) return; ! System.out.printf("sun.jnu.encoding=%s, file.encoding=%s%n", ! System.getProperty("file.encoding"), ! System.getProperty("sun.jnu.encoding")); // English test("TestDir_apple", // test dir "dir_macosx", // dir "file_macosx"); // file --- 19,65 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* ! * @test * @bug 7130915 * @summary Tests file path with nfc/nfd forms on MacOSX ! * @requires (os.family == "mac") ! * @library /java/nio/file ! * @run main/othervm -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 MacPathTest */ ! import java.nio.file.DirectoryStream; ! import java.nio.file.Files; ! import java.nio.file.Path; ! import java.nio.file.Paths; ! import java.nio.file.attribute.PosixFilePermission; ! import java.text.Normalizer; ! import java.util.Locale; ! import java.util.Set; ! import java.util.regex.Pattern; public class MacPathTest { + private static final String JNU_ENCODING = System.getProperty("sun.jnu.encoding"); + private static final String FILE_ENCODING = System.getProperty("file.encoding"); public static void main(String args[]) throws Throwable { ! if (!(FILE_ENCODING.equals("UTF-8") && JNU_ENCODING.equals("UTF-8"))) { ! System.out.println("Warning: This test requires UTF-8, current encoding:" ! + " sun.jnu.encoding = " + JNU_ENCODING + "," ! + " file.encoding = " + FILE_ENCODING + "\n" ! + "Test skipped.\n" ! + "\nRun test with:\n" ! + "java -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 MacPathTest"); return; ! } ! ! Locale defaultLocale = Locale.getDefault(); ! Locale.setDefault(Locale.US); ! // English test("TestDir_apple", // test dir "dir_macosx", // dir "file_macosx"); // file
*** 65,74 **** --- 79,90 ---- // Korean syblla test("TestDir_\uac00\uac01\uac02", "dir_\uac20\uac21\uac22", "file_\uacc0\uacc1\uacc2"); + + Locale.setDefault(defaultLocale); //restore } private static boolean equal(Object x, Object y) { return x == null ? y == null : x.equals(y); }
< prev index next >