Skip to content

Commit

Permalink
fixup! addressed comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
peihe committed Feb 3, 2017
1 parent 57a9463 commit 3d6952e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -101,6 +101,7 @@
<beamSurefireArgline />

<!-- If updating dependencies, please update any relevant javadoc offlineLinks -->
<apache.commons.lang.version>3.5</apache.commons.lang.version>
<apex.kryo.version>2.24.0</apex.kryo.version>
<avro.version>1.8.1</avro.version>
<bigquery.version>v2-rev295-1.22.0</bigquery.version>
Expand Down Expand Up @@ -452,6 +453,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.lang.version}</version>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
Expand Down
1 change: 0 additions & 1 deletion sdks/java/core/pom.xml
Expand Up @@ -374,7 +374,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>

<dependency>
Expand Down
Expand Up @@ -46,6 +46,19 @@ public interface ResourceId {
* <p>This {@code ResourceId} should represents a directory.
*
* <p>It is up to each file system to resolve in their own way.
*
* <p>Resolving special characters:
* <ul>
* <li>{@code resourceId.resolve("..", StandardResolveOptions.RESOLVE_DIRECTORY)} returns
* the parent directory of this {@code ResourceId}.
* <li>{@code resourceId.resolve("{@literal *}", StandardResolveOptions.RESOLVE_FILE)} returns
* a {@code ResourceId} which matches all files in this {@code ResourceId}.
* <li>{@code resourceId.resolve("{@literal *}", StandardResolveOptions.RESOLVE_DIRECTORY)}
* returns a {@code ResourceId} which matches all directories in this {@code ResourceId}.
* </ul>
*
* @throws IllegalArgumentException if other contains illegal characters or is an illegal name.
* It is recommended that callers use common characters, such as [_a-zA-Z0-9-], in {@code other}.
*/
ResourceId resolve(String other, ResolveOptions resolveOptions);

Expand Down
Expand Up @@ -440,7 +440,7 @@ public Path resolveSibling(Path other) {
}

@Override
public GcsPath resolveSibling(String other) {
public Path resolveSibling(String other) {
if (getNameCount() < 2) {
throw new UnsupportedOperationException("Can't resolve the sibling of a root path: " + this);
}
Expand Down
Expand Up @@ -76,8 +76,7 @@ public void testResolveHandleBadInputs() throws Exception {
@Test
public void testResolveInvalidInputs() throws Exception {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(
"The resolved file: [tmp/] should not end with '/'.");
thrown.expectMessage("The resolved file: [tmp/] should not end with '/'.");
toResourceIdentifier("gs://my_bucket/").resolve("tmp/", StandardResolveOptions.RESOLVE_FILE);
}

Expand All @@ -93,15 +92,27 @@ public void testResolveInvalidNotDirectory() throws Exception {

@Test
public void testGetCurrentDirectory() throws Exception {
// Tests for local files without the scheme.
// Tests gcs paths.
assertEquals(
toResourceIdentifier("gs://my_bucket/tmp dir/"),
toResourceIdentifier("gs://my_bucket/tmp dir/").getCurrentDirectory());

// Tests path with unicode
// Tests path with unicode.
assertEquals(
toResourceIdentifier("gs://my_bucket/输出 目录/"),
toResourceIdentifier("gs://my_bucket/输出 目录/文件01.txt").getCurrentDirectory());

// Tests bucket with no ending '/'.
assertEquals(
toResourceIdentifier("gs://my_bucket/"),
toResourceIdentifier("gs://my_bucket").getCurrentDirectory());
}

@Test
public void testInvalidGcsPath() throws Exception {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid GCS URI: gs://");
toResourceIdentifier("gs://");
}

@Test
Expand Down

0 comments on commit 3d6952e

Please sign in to comment.