|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -73,22 +73,26 @@ static void doTest(final Path dir) throws IOException {
|
73 | 73 | private PathMatcher matcher =
|
74 | 74 | dir.getFileSystem().getPathMatcher("glob:f*");
|
75 | 75 | public boolean accept(Path file) {
|
76 |
| - return matcher.matches(file); |
| 76 | + return matcher.matches(file.getFileName()); |
77 | 77 | }
|
78 | 78 | };
|
| 79 | + |
| 80 | + found = false; |
79 | 81 | try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {
|
80 | 82 | for (Path entry: ds) {
|
81 |
| - if (!entry.getFileName().equals(foo)) |
82 |
| - throw new RuntimeException("entry not expected"); |
| 83 | + if (entry.getFileName().equals(foo)) |
| 84 | + found = true; |
83 | 85 | }
|
| 86 | + if (!found) |
| 87 | + throw new RuntimeException(String.format("Error: entry: %s was not found", foo)); |
84 | 88 | }
|
85 | 89 |
|
86 | 90 | // check filtering: z* should not match any files
|
87 | 91 | filter = new DirectoryStream.Filter<Path>() {
|
88 | 92 | private PathMatcher matcher =
|
89 | 93 | dir.getFileSystem().getPathMatcher("glob:z*");
|
90 | 94 | public boolean accept(Path file) {
|
91 |
| - return matcher.matches(file); |
| 95 | + return matcher.matches(file.getFileName()); |
92 | 96 | }
|
93 | 97 | };
|
94 | 98 | try (DirectoryStream<Path> ds = newDirectoryStream(dir, filter)) {
|
|
0 commit comments