Skip to content

Commit fcbaa84

Browse files
---
yaml --- r: 5287 b: refs/heads/master c: f495c23 h: refs/heads/master i: 5285: e09ea4f 5283: 66e362a 5279: 30712a1
1 parent 1800fb7 commit fcbaa84

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d4d494d5bd51fee0134fb42cc9b82a5586b717dd
2+
refs/heads/master: f495c23cd8e6c74d13ca91767e05f8412fb84837
33
refs/heads/travis: dae77e558b884bc1b165155482d76c8e40b0fca4
44
refs/heads/gh-pages: 229631582f8957646f81e92ae5a326504f48ee5b
55
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

trunk/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.net.URISyntaxException;
2828
import java.nio.file.FileStore;
2929
import java.nio.file.FileSystem;
30+
import java.nio.file.FileSystems;
3031
import java.nio.file.Path;
3132
import java.nio.file.PathMatcher;
3233
import java.nio.file.WatchService;
@@ -210,13 +211,9 @@ public Set<String> supportedFileAttributeViews() {
210211
return SUPPORTED_VIEWS;
211212
}
212213

213-
/**
214-
* Throws {@link UnsupportedOperationException} because this feature hasn't been implemented yet.
215-
*/
216214
@Override
217215
public PathMatcher getPathMatcher(String syntaxAndPattern) {
218-
// TODO(#813): Implement me.
219-
throw new UnsupportedOperationException();
216+
return FileSystems.getDefault().getPathMatcher(syntaxAndPattern);
220217
}
221218

222219
/**

trunk/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.file.FileSystems;
3535
import java.nio.file.Files;
3636
import java.nio.file.Path;
37+
import java.nio.file.PathMatcher;
3738
import java.nio.file.Paths;
3839
import java.util.ArrayList;
3940
import java.util.List;
@@ -159,4 +160,27 @@ public void testListFiles() throws IOException {
159160
assertThat(got).containsExactlyElementsIn(goodPaths);
160161
}
161162
}
163+
164+
@Test
165+
public void testMatcher() throws IOException {
166+
try (FileSystem fs = CloudStorageFileSystem.forBucket("bucket")) {
167+
String pattern1 = "glob:*.java";
168+
PathMatcher javaFileMatcher = fs.getPathMatcher(pattern1);
169+
assertMatches(fs, javaFileMatcher, "a.java", true);
170+
assertMatches(fs, javaFileMatcher, "a.text", false);
171+
assertMatches(fs, javaFileMatcher, "folder/c.java", true);
172+
assertMatches(fs, javaFileMatcher, "d", false);
173+
174+
String pattern2 = "glob:*.{java,text}";
175+
PathMatcher javaAndTextFileMatcher = fs.getPathMatcher(pattern2);
176+
assertMatches(fs, javaAndTextFileMatcher, "a.java", true);
177+
assertMatches(fs, javaAndTextFileMatcher, "a.text", true);
178+
assertMatches(fs, javaAndTextFileMatcher, "folder/c.java", true);
179+
assertMatches(fs, javaAndTextFileMatcher, "d", false);
180+
}
181+
}
182+
183+
private void assertMatches(FileSystem fs, PathMatcher matcher, String toMatch, boolean expected) {
184+
assertThat(matcher.matches(fs.getPath(toMatch).getFileName())).isEqualTo(expected);
185+
}
162186
}

0 commit comments

Comments
 (0)