Skip to content

Commit 136f464

Browse files
---
yaml --- r: 7735 b: refs/heads/tswast-patch-1 c: f495c23 h: refs/heads/master i: 7733: 15e7a4e 7731: c5aa45d 7727: 7fb6608
1 parent 1e99eb4 commit 136f464

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
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: d4d494d5bd51fee0134fb42cc9b82a5586b717dd
60+
refs/heads/tswast-patch-1: f495c23cd8e6c74d13ca91767e05f8412fb84837
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/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
/**

branches/tswast-patch-1/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)