--- old/test/java/nio/file/Path/MacPathTest.java 2017-06-07 13:53:33.000000000 +0800 +++ new/test/java/nio/file/Path/MacPathTest.java 2017-06-07 13:53:33.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,29 +21,43 @@ * questions. */ -/* @test +/* + * @test * @bug 7130915 * @summary Tests file path with nfc/nfd forms on MacOSX - * @library ../ - * @build MacPathTest - * @run shell MacPathTest.sh + * @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.*; -import java.nio.file.attribute.*; -import java.text.*; -import java.util.*; -import java.util.regex.*; +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 { - String osname = System.getProperty("os.name"); - if (!osname.contains("OS X") && !osname.contains("Darwin")) + 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; - System.out.printf("sun.jnu.encoding=%s, file.encoding=%s%n", - System.getProperty("file.encoding"), - System.getProperty("sun.jnu.encoding")); + } + + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); + // English test("TestDir_apple", // test dir "dir_macosx", // dir @@ -67,6 +81,8 @@ 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) {