test/java/nio/file/PathMatcher/Basic.java
Print this page
rev 11561 : 8073445: (fs) FileSystem.getPathMatcher(...) should check syntax component without regard to case
Summary: Change String equals() to equalsIgnoreCase() where needed.
Reviewed-by: alanb
*** 1,7 ****
/*
! * Copyright (c) 2008, 2009, 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, 2015, 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.
*** 20,30 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! * @bug 4313887 6866397
* @summary Unit test for java.nio.file.PathMatcher
*/
import java.nio.file.*;
import java.util.regex.PatternSyntaxException;
--- 20,30 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! * @bug 4313887 6866397 8073445
* @summary Unit test for java.nio.file.PathMatcher
*/
import java.nio.file.*;
import java.util.regex.PatternSyntaxException;
*** 171,180 ****
--- 171,220 ----
failures++;
} catch (UnsupportedOperationException e) {
System.out.println(" OKAY");
}
+ // GLOB_SYNTAX case sensitivity of getPathMatcher: should not throw UOE
+ Path foobar = Paths.get("/foo", "bar");
+ try {
+ PathMatcher pmGlob =
+ FileSystems.getDefault().getPathMatcher("glob:java");
+ pmGlob = FileSystems.getDefault().getPathMatcher("Glob:java");
+ pmGlob = FileSystems.getDefault().getPathMatcher("GLOB:java");
+ // next three lines to avoid unused variable complaints about
+ // 'pmGlob' and any possibility of things eventually being
+ // optimized out
+ if (pmGlob.matches(Paths.get("/foo", "bar"))) {
+ System.out.println("pmGlob matches foobar!");
+ }
+ System.out.println("Test GLOB_SYNTAX case sensitivity OKAY");
+ } catch (UnsupportedOperationException e) {
+ System.err.println("getPathMatcher GLOB_SYNTAX case sensitivity");
+ e.printStackTrace();
+ failures++;
+ }
+
+ // REGEX_SYNTAX case sensitivity of getPathMatcher: should not throw UOE
+ try {
+ PathMatcher pmRegex =
+ FileSystems.getDefault().getPathMatcher("regex:java");
+ pmRegex = FileSystems.getDefault().getPathMatcher("Regex:java");
+ pmRegex = FileSystems.getDefault().getPathMatcher("RegEx:java");
+ pmRegex = FileSystems.getDefault().getPathMatcher("REGEX:java");
+ // next three lines to avoid unused variable complaints about
+ // 'pmRegex' and any possibility of things eventually being
+ // optimized out
+ if (pmRegex.matches(Paths.get("/foo", "bar"))) {
+ System.out.println("pmRegex matches foobar!");
+ }
+ System.out.println("Test REGEX_SYNTAX case sensitivity OKAY");
+ } catch (UnsupportedOperationException e) {
+ System.err.println("getPathMatcher REGEX_SYNTAX case sensitivity");
+ e.printStackTrace();
+ failures++;
+ }
+
if (failures > 0)
throw new RuntimeException(failures +
" sub-test(s) failed - see log for details");
}
}