From e510dae8a5dc8d164bae1ee176fe34312b1b5f7d Mon Sep 17 00:00:00 2001 From: JP Martin Date: Mon, 18 Apr 2016 12:45:02 -0700 Subject: [PATCH] Move gcloud->cloud (issue #877) and update version number --- .../gcloud-java-nio-examples/README.md | 4 +- .../gcloud-java-nio-examples/pom.xml | 4 +- .../nio/examples/ListFilesystems.java | 2 +- gcloud-java-contrib/gcloud-java-nio/pom.xml | 8 +- .../nio/CloudStorageFileSystemProvider.java | 45 +++++---- .../storage/contrib/nio/CloudStoragePath.java | 10 +- ...CloudStoragePseudoDirectoryAttributes.java | 8 +- .../nio/CloudStorageFileAttributesTest.java | 26 ++---- .../CloudStorageFileSystemProviderTest.java | 27 +++--- .../nio/CloudStorageFileSystemTest.java | 2 +- .../contrib/nio/CloudStorageOptionsTest.java | 23 ++--- .../contrib/nio/CloudStoragePathTest.java | 93 +++++++++---------- gcloud-java-examples/pom.xml | 10 +- .../cloud/storage/testing/FakeStorageRpc.java | 5 +- 14 files changed, 120 insertions(+), 147 deletions(-) rename gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/{gcloud => cloud}/nio/examples/ListFilesystems.java (97%) diff --git a/gcloud-java-contrib/gcloud-java-nio-examples/README.md b/gcloud-java-contrib/gcloud-java-nio-examples/README.md index 206ca93759e5..bc9b5060aa76 100644 --- a/gcloud-java-contrib/gcloud-java-nio-examples/README.md +++ b/gcloud-java-contrib/gcloud-java-nio-examples/README.md @@ -22,12 +22,12 @@ To run this example: 4. Run the sample with: ``` - java -cp gcloud-java-contrib/gcloud-java-nio/target/gcloud-java-nio-0.1.6-SNAPSHOT-shaded.jar:gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.1.6-SNAPSHOT.jar com.google.gcloud.nio.examples.ListFilesystems + java -cp gcloud-java-contrib/gcloud-java-nio/target/gcloud-java-nio-0.2.1-SNAPSHOT-shaded.jar:gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.2.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems ``` Notice that it lists gcs, which it wouldn't if you ran it without the nio jar: ``` - java -cp gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.1.6-SNAPSHOT.jar com.google.gcloud.nio.examples.ListFilesystems + java -cp gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.2.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems ``` The sample doesn't have anything about GCS in it. It gets that ability from the nio jar that diff --git a/gcloud-java-contrib/gcloud-java-nio-examples/pom.xml b/gcloud-java-contrib/gcloud-java-nio-examples/pom.xml index cea1f7b4be5a..cb674a04d9ba 100644 --- a/gcloud-java-contrib/gcloud-java-nio-examples/pom.xml +++ b/gcloud-java-contrib/gcloud-java-nio-examples/pom.xml @@ -9,9 +9,9 @@ Demonstrates how to use the gcloud-java-nio jar to add GCS functionality to legacy code. - com.google.gcloud + com.google.cloud gcloud-java-contrib - 0.1.6-SNAPSHOT + 0.2.1-SNAPSHOT nio diff --git a/gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/gcloud/nio/examples/ListFilesystems.java b/gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/cloud/nio/examples/ListFilesystems.java similarity index 97% rename from gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/gcloud/nio/examples/ListFilesystems.java rename to gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/cloud/nio/examples/ListFilesystems.java index 5e92768d1cf6..b03dc13763d1 100644 --- a/gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/gcloud/nio/examples/ListFilesystems.java +++ b/gcloud-java-contrib/gcloud-java-nio-examples/src/main/java/com/google/cloud/nio/examples/ListFilesystems.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.nio.examples; +package com.google.cloud.nio.examples; import java.io.IOException; import java.net.URI; diff --git a/gcloud-java-contrib/gcloud-java-nio/pom.xml b/gcloud-java-contrib/gcloud-java-nio/pom.xml index f366b86c33b0..3c988e768bbc 100644 --- a/gcloud-java-contrib/gcloud-java-nio/pom.xml +++ b/gcloud-java-contrib/gcloud-java-nio/pom.xml @@ -102,18 +102,18 @@ com - shaded.gcloud-nio.com + shaded.cloud-nio.com - com.google.gcloud.** + com.google.cloud.** org - shaded.gcloud-nio.org + shaded.cloud-nio.org google - shaded.gcloud-nio.google + shaded.cloud-nio.google diff --git a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java index ad590bbc5f41..b9a226b7875a 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java @@ -16,10 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkBucket; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkPath; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.stripPathFromUri; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; @@ -71,6 +67,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; + import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -173,20 +170,20 @@ && isNullOrEmpty(uri.getFragment()) && isNullOrEmpty(uri.getUserInfo()), "GCS FileSystem URIs mustn't have: port, userinfo, path, query, or fragment: %s", uri); - checkBucket(uri.getHost()); + CloudStorageUtil.checkBucket(uri.getHost()); return new CloudStorageFileSystem(this, uri.getHost(), CloudStorageConfiguration.fromMap(env)); } @Override public CloudStoragePath getPath(URI uri) { - return CloudStoragePath.getPath(getFileSystem(stripPathFromUri(uri)), uri.getPath()); + return CloudStoragePath.getPath(getFileSystem(CloudStorageUtil.stripPathFromUri(uri)), uri.getPath()); } @Override public SeekableByteChannel newByteChannel( Path path, Set options, FileAttribute... attrs) throws IOException { checkNotNull(path); - checkNotNullArray(attrs); + CloudStorageUtil.checkNotNullArray(attrs); if (options.contains(StandardOpenOption.WRITE)) { // TODO: Make our OpenOptions implement FileAttribute. Also remove buffer option. return newWriteChannel(path, options); @@ -222,7 +219,7 @@ private SeekableByteChannel newReadChannel(Path path, Set throw new UnsupportedOperationException(option.toString()); } } - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) { throw new CloudStoragePseudoDirectoryException(cloudPath); } @@ -232,7 +229,7 @@ private SeekableByteChannel newReadChannel(Path path, Set private SeekableByteChannel newWriteChannel(Path path, Set options) throws IOException { - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) { throw new CloudStoragePseudoDirectoryException(cloudPath); } @@ -306,7 +303,7 @@ private SeekableByteChannel newWriteChannel(Path path, Set @Override public InputStream newInputStream(Path path, OpenOption... options) throws IOException { InputStream result = super.newInputStream(path, options); - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); int blockSize = cloudPath.getFileSystem().config().blockSize(); for (OpenOption option : options) { if (option instanceof OptionBlockSize) { @@ -318,7 +315,7 @@ public InputStream newInputStream(Path path, OpenOption... options) throws IOExc @Override public boolean deleteIfExists(Path path) throws IOException { - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) { throw new CloudStoragePseudoDirectoryException(cloudPath); } @@ -327,7 +324,7 @@ public boolean deleteIfExists(Path path) throws IOException { @Override public void delete(Path path) throws IOException { - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (!deleteIfExists(cloudPath)) { throw new NoSuchFileException(cloudPath.toString()); } @@ -356,7 +353,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep boolean setContentEncoding = false; boolean setContentDisposition = false; - CloudStoragePath toPath = checkPath(target); + CloudStoragePath toPath = CloudStorageUtil.checkPath(target); BlobInfo.Builder tgtInfoBuilder = BlobInfo.builder(toPath.getBlobId()).contentType(""); int blockSize = -1; @@ -397,7 +394,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep } } - CloudStoragePath fromPath = checkPath(source); + CloudStoragePath fromPath = CloudStorageUtil.checkPath(source); blockSize = blockSize != -1 @@ -465,7 +462,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep @Override public boolean isSameFile(Path path, Path path2) { - return checkPath(path).equals(checkPath(path2)); + return CloudStorageUtil.checkPath(path).equals(CloudStorageUtil.checkPath(path2)); } /** @@ -473,7 +470,7 @@ public boolean isSameFile(Path path, Path path2) { */ @Override public boolean isHidden(Path path) { - checkPath(path); + CloudStorageUtil.checkPath(path); return false; } @@ -489,7 +486,7 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException { throw new UnsupportedOperationException(mode.toString()); } } - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) { return; } @@ -503,11 +500,11 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException { public A readAttributes( Path path, Class type, LinkOption... options) throws IOException { checkNotNull(type); - checkNotNullArray(options); + CloudStorageUtil.checkNotNullArray(options); if (type != CloudStorageFileAttributes.class && type != BasicFileAttributes.class) { throw new UnsupportedOperationException(type.getSimpleName()); } - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) { @SuppressWarnings("unchecked") A result = (A) new CloudStoragePseudoDirectoryAttributes(cloudPath); @@ -538,11 +535,11 @@ public Map readAttributes(Path path, String attributes, LinkOpti public V getFileAttributeView( Path path, Class type, LinkOption... options) { checkNotNull(type); - checkNotNullArray(options); + CloudStorageUtil.checkNotNullArray(options); if (type != CloudStorageFileAttributeView.class && type != BasicFileAttributeView.class) { throw new UnsupportedOperationException(type.getSimpleName()); } - CloudStoragePath cloudPath = checkPath(path); + CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path); @SuppressWarnings("unchecked") V result = (V) new CloudStorageFileAttributeView(storage, cloudPath); return result; @@ -553,13 +550,13 @@ public V getFileAttributeView( */ @Override public void createDirectory(Path dir, FileAttribute... attrs) { - checkPath(dir); - checkNotNullArray(attrs); + CloudStorageUtil.checkPath(dir); + CloudStorageUtil.checkNotNullArray(attrs); } @Override public DirectoryStream newDirectoryStream(Path dir, final Filter filter) { - final CloudStoragePath cloudPath = checkPath(dir); + final CloudStoragePath cloudPath = CloudStorageUtil.checkPath(dir); checkNotNull(filter); String prefix = cloudPath.toString(); final Iterator blobIterator = storage.list(cloudPath.bucket(), Storage.BlobListOption.prefix(prefix), Storage.BlobListOption.fields()).iterateAll(); diff --git a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePath.java b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePath.java index b44984e2be6a..3f954efd3bee 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePath.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePath.java @@ -16,8 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray; -import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkPath; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -125,7 +123,7 @@ public CloudStoragePath toAbsolutePath() { */ @Override public CloudStoragePath toRealPath(LinkOption... options) { - checkNotNullArray(options); + CloudStorageUtil.checkNotNullArray(options); return newPath(toRealPathInternal(true)); } @@ -155,7 +153,7 @@ public CloudStoragePath normalize() { @Override public CloudStoragePath resolve(Path object) { - return newPath(path.resolve(checkPath(object).path)); + return newPath(path.resolve(CloudStorageUtil.checkPath(object).path)); } @Override @@ -165,7 +163,7 @@ public CloudStoragePath resolve(String other) { @Override public CloudStoragePath resolveSibling(Path other) { - return newPath(path.resolveSibling(checkPath(other).path)); + return newPath(path.resolveSibling(CloudStorageUtil.checkPath(other).path)); } @Override @@ -175,7 +173,7 @@ public CloudStoragePath resolveSibling(String other) { @Override public CloudStoragePath relativize(Path object) { - return newPath(path.relativize(checkPath(object).path)); + return newPath(path.relativize(CloudStorageUtil.checkPath(object).path)); } @Nullable diff --git a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePseudoDirectoryAttributes.java b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePseudoDirectoryAttributes.java index b034eab0e8a1..a7a8c7293688 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePseudoDirectoryAttributes.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStoragePseudoDirectoryAttributes.java @@ -16,8 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN; - import com.google.cloud.storage.Acl; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; @@ -68,17 +66,17 @@ public long size() { @Override public FileTime lastModifiedTime() { - return FILE_TIME_UNKNOWN; + return CloudStorageFileSystem.FILE_TIME_UNKNOWN; } @Override public FileTime creationTime() { - return FILE_TIME_UNKNOWN; + return CloudStorageFileSystem.FILE_TIME_UNKNOWN; } @Override public FileTime lastAccessTime() { - return FILE_TIME_UNKNOWN; + return CloudStorageFileSystem.FILE_TIME_UNKNOWN; } @Override diff --git a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileAttributesTest.java b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileAttributesTest.java index 2d8be2c2dc2d..4b64e96da3cb 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileAttributesTest.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileAttributesTest.java @@ -16,12 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withAcl; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withCacheControl; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentDisposition; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentEncoding; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withMimeType; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withUserMetadata; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; @@ -61,14 +55,14 @@ public void before() { @Test public void testCacheControl() throws IOException { - Files.write(path, HAPPY, withCacheControl("potato")); + Files.write(path, HAPPY, CloudStorageOptions.withCacheControl("potato")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).cacheControl().get()) .isEqualTo("potato"); } @Test public void testMimeType() throws IOException { - Files.write(path, HAPPY, withMimeType("text/potato")); + Files.write(path, HAPPY, CloudStorageOptions.withMimeType("text/potato")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).mimeType().get()) .isEqualTo("text/potato"); } @@ -76,14 +70,14 @@ public void testMimeType() throws IOException { @Test public void testAcl() throws IOException { Acl acl = Acl.of(new Acl.User("serf@example.com"), Acl.Role.READER); - Files.write(path, HAPPY, withAcl(acl)); + Files.write(path, HAPPY, CloudStorageOptions.withAcl(acl)); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).acl().get()) .contains(acl); } @Test public void testContentDisposition() throws IOException { - Files.write(path, HAPPY, withContentDisposition("crash call")); + Files.write(path, HAPPY, CloudStorageOptions.withContentDisposition("crash call")); assertThat( Files.readAttributes(path, CloudStorageFileAttributes.class).contentDisposition().get()) .isEqualTo("crash call"); @@ -91,14 +85,14 @@ public void testContentDisposition() throws IOException { @Test public void testContentEncoding() throws IOException { - Files.write(path, HAPPY, withContentEncoding("my content encoding")); + Files.write(path, HAPPY, CloudStorageOptions.withContentEncoding("my content encoding")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).contentEncoding().get()) .isEqualTo("my content encoding"); } @Test public void testUserMetadata() throws IOException { - Files.write(path, HAPPY, withUserMetadata("green", "bean")); + Files.write(path, HAPPY, CloudStorageOptions.withUserMetadata("green", "bean")); assertThat( Files.readAttributes(path, CloudStorageFileAttributes.class) .userMetadata() @@ -141,10 +135,10 @@ public void testIsSymbolicLink() throws IOException { @Test public void testEquals_equalsTester() throws IOException { - Files.write(path, HAPPY, withMimeType("text/plain")); + Files.write(path, HAPPY, CloudStorageOptions.withMimeType("text/plain")); CloudStorageFileAttributes a1 = Files.readAttributes(path, CloudStorageFileAttributes.class); CloudStorageFileAttributes a2 = Files.readAttributes(path, CloudStorageFileAttributes.class); - Files.write(path, HAPPY, withMimeType("text/potato")); + Files.write(path, HAPPY, CloudStorageOptions.withMimeType("text/potato")); CloudStorageFileAttributes b1 = Files.readAttributes(path, CloudStorageFileAttributes.class); CloudStorageFileAttributes b2 = Files.readAttributes(path, CloudStorageFileAttributes.class); new EqualsTester().addEqualityGroup(a1, a2).addEqualityGroup(b1, b2).testEquals(); @@ -152,9 +146,9 @@ public void testEquals_equalsTester() throws IOException { @Test public void testFilekey() throws IOException { - Files.write(path, HAPPY, withMimeType("text/plain")); + Files.write(path, HAPPY, CloudStorageOptions.withMimeType("text/plain")); Path path2 = Paths.get(URI.create("gs://bucket/anotherrandompath")); - Files.write(path2, HAPPY, withMimeType("text/plain")); + Files.write(path2, HAPPY, CloudStorageOptions.withMimeType("text/plain")); // diff files cannot have same filekey CloudStorageFileAttributes a1 = Files.readAttributes(path, CloudStorageFileAttributes.class); diff --git a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java index 9340070c9bf8..e1dfe7bceebd 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java @@ -17,11 +17,6 @@ package com.google.cloud.storage.contrib.nio; import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withCacheControl; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentDisposition; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentEncoding; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withMimeType; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withUserMetadata; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; @@ -565,11 +560,11 @@ public void testCopy_withCopyAttributes_preservesAttributes() throws IOException Files.write( source, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), - withMimeType("text/lolcat"), - withCacheControl("public; max-age=666"), - withContentEncoding("foobar"), - withContentDisposition("my-content-disposition"), - withUserMetadata("answer", "42")); + CloudStorageOptions.withMimeType("text/lolcat"), + CloudStorageOptions.withCacheControl("public; max-age=666"), + CloudStorageOptions.withContentEncoding("foobar"), + CloudStorageOptions.withContentDisposition("my-content-disposition"), + CloudStorageOptions.withUserMetadata("answer", "42")); Files.copy(source, target, COPY_ATTRIBUTES); CloudStorageFileAttributes attributes = @@ -589,9 +584,9 @@ public void testCopy_withoutOptions_doesntPreservesAttributes() throws IOExcepti Files.write( source, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), - withMimeType("text/lolcat"), - withCacheControl("public; max-age=666"), - withUserMetadata("answer", "42")); + CloudStorageOptions.withMimeType("text/lolcat"), + CloudStorageOptions.withCacheControl("public; max-age=666"), + CloudStorageOptions.withUserMetadata("answer", "42")); Files.copy(source, target); CloudStorageFileAttributes attributes = @@ -611,10 +606,10 @@ public void testCopy_overwriteAttributes() throws IOException { Files.write( source, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), - withMimeType("text/lolcat"), - withCacheControl("public; max-age=666")); + CloudStorageOptions.withMimeType("text/lolcat"), + CloudStorageOptions.withCacheControl("public; max-age=666")); Files.copy(source, target1, COPY_ATTRIBUTES); - Files.copy(source, target2, COPY_ATTRIBUTES, withMimeType("text/palfun")); + Files.copy(source, target2, COPY_ATTRIBUTES, CloudStorageOptions.withMimeType("text/palfun")); CloudStorageFileAttributes attributes = Files.readAttributes(target1, CloudStorageFileAttributes.class); diff --git a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java index 49e8d5cee4eb..bfb3a5bc7be9 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java @@ -19,9 +19,9 @@ import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; +import com.google.cloud.storage.testing.LocalGcsHelper; import com.google.common.testing.EqualsTester; import com.google.common.testing.NullPointerTester; -import com.google.cloud.storage.testing.LocalGcsHelper; import org.junit.Before; import org.junit.Test; diff --git a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageOptionsTest.java b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageOptionsTest.java index 7d14193066aa..ddf5b46f0c17 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageOptionsTest.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageOptionsTest.java @@ -16,13 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withAcl; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withCacheControl; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentDisposition; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withContentEncoding; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withMimeType; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withUserMetadata; -import static com.google.cloud.storage.contrib.nio.CloudStorageOptions.withoutCaching; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; @@ -55,7 +48,7 @@ public void before() { @Test public void testWithoutCaching() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withoutCaching()); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withoutCaching()); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).cacheControl().get()) .isEqualTo("no-cache"); } @@ -63,7 +56,7 @@ public void testWithoutCaching() throws IOException { @Test public void testCacheControl() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withCacheControl("potato")); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withCacheControl("potato")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).cacheControl().get()) .isEqualTo("potato"); } @@ -72,7 +65,7 @@ public void testCacheControl() throws IOException { public void testWithAcl() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); Acl acl = Acl.of(new Acl.User("king@example.com"), Acl.Role.OWNER); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withAcl(acl)); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withAcl(acl)); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).acl().get()) .contains(acl); } @@ -80,7 +73,7 @@ public void testWithAcl() throws IOException { @Test public void testWithContentDisposition() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withContentDisposition("bubbly fun")); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withContentDisposition("bubbly fun")); assertThat( Files.readAttributes(path, CloudStorageFileAttributes.class).contentDisposition().get()) .isEqualTo("bubbly fun"); @@ -89,7 +82,7 @@ public void testWithContentDisposition() throws IOException { @Test public void testWithContentEncoding() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withContentEncoding("gzip")); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withContentEncoding("gzip")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).contentEncoding().get()) .isEqualTo("gzip"); } @@ -100,8 +93,8 @@ public void testWithUserMetadata() throws IOException { Files.write( path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), - withUserMetadata("nolo", "contendere"), - withUserMetadata("eternal", "sadness")); + CloudStorageOptions.withUserMetadata("nolo", "contendere"), + CloudStorageOptions.withUserMetadata("eternal", "sadness")); assertThat( Files.readAttributes(path, CloudStorageFileAttributes.class).userMetadata().get("nolo")) .isEqualTo("contendere"); @@ -115,7 +108,7 @@ public void testWithUserMetadata() throws IOException { @Test public void testWithMimeType_string() throws IOException { Path path = Paths.get(URI.create("gs://bucket/path")); - Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), withMimeType("text/plain")); + Files.write(path, "(✿◕ ‿◕ )ノ".getBytes(UTF_8), CloudStorageOptions.withMimeType("text/plain")); assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).mimeType().get()) .isEqualTo("text/plain"); } diff --git a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStoragePathTest.java b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStoragePathTest.java index 62fc011f7b18..852aca4d07a2 100644 --- a/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStoragePathTest.java +++ b/gcloud-java-contrib/gcloud-java-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStoragePathTest.java @@ -16,7 +16,6 @@ package com.google.cloud.storage.contrib.nio; -import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.storage.testing.LocalGcsHelper; @@ -53,7 +52,7 @@ public void before() { @Test public void testCreate_neverRemoveExtraSlashes() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("lol//cat").toString()).isEqualTo("lol//cat"); assertThat((Object) fs.getPath("lol//cat")).isEqualTo(fs.getPath("lol//cat")); } @@ -61,7 +60,7 @@ public void testCreate_neverRemoveExtraSlashes() { @Test public void testCreate_preservesTrailingSlash() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("lol/cat/").toString()).isEqualTo("lol/cat/"); assertThat((Object) fs.getPath("lol/cat/")).isEqualTo(fs.getPath("lol/cat/")); } @@ -69,7 +68,7 @@ public void testCreate_preservesTrailingSlash() { @Test public void testGetGcsFilename_empty_notAllowed() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); fs.getPath("").getBlobId(); } @@ -77,21 +76,21 @@ public void testGetGcsFilename_empty_notAllowed() { @Test public void testGetGcsFilename_stripsPrefixSlash() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi").getBlobId().name()).isEqualTo("hi"); } } @Test public void testGetGcsFilename_overrideStripPrefixSlash_doesntStripPrefixSlash() { - try (CloudStorageFileSystem fs = forBucket("doodle", stripPrefixSlash(false))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", stripPrefixSlash(false))) { assertThat(fs.getPath("/hi").getBlobId().name()).isEqualTo("/hi"); } } @Test public void testGetGcsFilename_extraSlashes_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); fs.getPath("a//b").getBlobId().name(); } @@ -99,14 +98,14 @@ public void testGetGcsFilename_extraSlashes_throwsIae() { @Test public void testGetGcsFilename_overridepermitEmptyPathComponents() { - try (CloudStorageFileSystem fs = forBucket("doodle", permitEmptyPathComponents(true))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", permitEmptyPathComponents(true))) { assertThat(fs.getPath("a//b").getBlobId().name()).isEqualTo("a//b"); } } @Test public void testGetGcsFilename_freaksOutOnExtraSlashesAndDotDirs() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); fs.getPath("a//b/..").getBlobId().name(); } @@ -114,7 +113,7 @@ public void testGetGcsFilename_freaksOutOnExtraSlashesAndDotDirs() { @Test public void testNameCount() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("").getNameCount()).isEqualTo(1); assertThat(fs.getPath("/").getNameCount()).isEqualTo(0); assertThat(fs.getPath("/hi/").getNameCount()).isEqualTo(1); @@ -125,7 +124,7 @@ public void testNameCount() { @Test public void testGetName() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("").getName(0).toString()).isEqualTo(""); assertThat(fs.getPath("/hi").getName(0).toString()).isEqualTo("hi"); assertThat(fs.getPath("hi/there").getName(1).toString()).isEqualTo("there"); @@ -134,7 +133,7 @@ public void testGetName() { @Test public void testGetName_negative_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); fs.getPath("angel").getName(-1); } @@ -142,7 +141,7 @@ public void testGetName_negative_throwsIae() { @Test public void testGetName_overflow_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); fs.getPath("angel").getName(1); } @@ -150,7 +149,7 @@ public void testGetName_overflow_throwsIae() { @Test public void testIterator() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(Iterables.get(fs.getPath("/dog/mog"), 0).toString()).isEqualTo("dog"); assertThat(Iterables.get(fs.getPath("/dog/mog"), 1).toString()).isEqualTo("mog"); assertThat(Iterables.size(fs.getPath("/"))).isEqualTo(0); @@ -161,7 +160,7 @@ public void testIterator() { @Test public void testNormalize() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/").normalize().toString()).isEqualTo("/"); assertThat(fs.getPath("a/x/../b/x/..").normalize().toString()).isEqualTo("a/b/"); assertThat(fs.getPath("/x/x/../../♡").normalize().toString()).isEqualTo("/♡"); @@ -171,7 +170,7 @@ public void testNormalize() { @Test public void testNormalize_dot_becomesBlank() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("").normalize().toString()).isEqualTo(""); assertThat(fs.getPath(".").normalize().toString()).isEqualTo(""); } @@ -179,14 +178,14 @@ public void testNormalize_dot_becomesBlank() { @Test public void testNormalize_trailingSlash_isPreserved() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("o/").normalize().toString()).isEqualTo("o/"); } } @Test public void testNormalize_doubleDot_becomesBlank() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("..").normalize().toString()).isEqualTo(""); assertThat(fs.getPath("../..").normalize().toString()).isEqualTo(""); } @@ -194,14 +193,14 @@ public void testNormalize_doubleDot_becomesBlank() { @Test public void testNormalize_extraSlashes_getRemoved() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("//life///b/good//").normalize().toString()).isEqualTo("/life/b/good/"); } } @Test public void testToRealPath_hasDotDir_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { fs.getPath("a/hi./b").toRealPath(); fs.getPath("a/.hi/b").toRealPath(); thrown.expect(IllegalArgumentException.class); @@ -212,7 +211,7 @@ public void testToRealPath_hasDotDir_throwsIae() { @Test public void testToRealPath_hasDotDotDir_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { fs.getPath("a/hi../b").toRealPath(); fs.getPath("a/..hi/b").toRealPath(); thrown.expect(IllegalArgumentException.class); @@ -223,7 +222,7 @@ public void testToRealPath_hasDotDotDir_throwsIae() { @Test public void testToRealPath_extraSlashes_throwsIae() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("extra slashes"); fs.getPath("a//b").toRealPath(); @@ -232,7 +231,7 @@ public void testToRealPath_extraSlashes_throwsIae() { @Test public void testToRealPath_overridePermitEmptyPathComponents_extraSlashes_slashesRemain() { - try (CloudStorageFileSystem fs = forBucket("doodle", permitEmptyPathComponents(true))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", permitEmptyPathComponents(true))) { assertThat(fs.getPath("/life///b/./good/").toRealPath().toString()) .isEqualTo("life///b/./good/"); } @@ -240,7 +239,7 @@ public void testToRealPath_overridePermitEmptyPathComponents_extraSlashes_slashe @Test public void testToRealPath_permitEmptyPathComponents_doesNotNormalize() { - try (CloudStorageFileSystem fs = forBucket("doodle", permitEmptyPathComponents(true))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", permitEmptyPathComponents(true))) { assertThat(fs.getPath("a").toRealPath().toString()).isEqualTo("a"); assertThat(fs.getPath("a//b").toRealPath().toString()).isEqualTo("a//b"); assertThat(fs.getPath("a//./b//..").toRealPath().toString()).isEqualTo("a//./b//.."); @@ -249,14 +248,14 @@ public void testToRealPath_permitEmptyPathComponents_doesNotNormalize() { @Test public void testToRealPath_withWorkingDirectory_makesAbsolute() { - try (CloudStorageFileSystem fs = forBucket("doodle", workingDirectory("/lol"))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", workingDirectory("/lol"))) { assertThat(fs.getPath("a").toRealPath().toString()).isEqualTo("lol/a"); } } @Test public void testToRealPath_disableStripPrefixSlash_makesPathAbsolute() { - try (CloudStorageFileSystem fs = forBucket("doodle", stripPrefixSlash(false))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", stripPrefixSlash(false))) { assertThat(fs.getPath("a").toRealPath().toString()).isEqualTo("/a"); assertThat(fs.getPath("/a").toRealPath().toString()).isEqualTo("/a"); } @@ -264,21 +263,21 @@ public void testToRealPath_disableStripPrefixSlash_makesPathAbsolute() { @Test public void testToRealPath_trailingSlash_getsPreserved() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("a/b/").toRealPath().toString()).isEqualTo("a/b/"); } } @Test public void testNormalize_empty_returnsEmpty() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("").normalize().toString()).isEqualTo(""); } } @Test public void testNormalize_preserveTrailingSlash() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("a/b/../c/").normalize().toString()).isEqualTo("a/c/"); assertThat(fs.getPath("a/b/./c/").normalize().toString()).isEqualTo("a/b/c/"); } @@ -286,7 +285,7 @@ public void testNormalize_preserveTrailingSlash() { @Test public void testGetParent_preserveTrailingSlash() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("a/b/c").getParent().toString()).isEqualTo("a/b/"); assertThat(fs.getPath("a/b/c/").getParent().toString()).isEqualTo("a/b/"); assertThat((Object) fs.getPath("").getParent()).isNull(); @@ -298,7 +297,7 @@ public void testGetParent_preserveTrailingSlash() { @Test public void testGetRoot() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hello").getRoot().toString()).isEqualTo("/"); assertThat((Object) fs.getPath("hello").getRoot()).isNull(); } @@ -306,7 +305,7 @@ public void testGetRoot() { @Test public void testRelativize() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat( fs.getPath("/foo/bar/lol/cat").relativize(fs.getPath("/foo/a/b/../../c")).toString()) .isEqualTo("../../../a/b/../../c"); @@ -315,7 +314,7 @@ public void testRelativize() { @Test public void testRelativize_providerMismatch() { - try (CloudStorageFileSystem gcs = forBucket("doodle")) { + try (CloudStorageFileSystem gcs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(ProviderMismatchException.class); gcs.getPath("/etc").relativize(FileSystems.getDefault().getPath("/dog")); } @@ -324,7 +323,7 @@ public void testRelativize_providerMismatch() { @Test @SuppressWarnings("ReturnValueIgnored") // testing that an Exception is thrown public void testRelativize_providerMismatch2() { - try (CloudStorageFileSystem gcs = forBucket("doodle")) { + try (CloudStorageFileSystem gcs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(ProviderMismatchException.class); gcs.getPath("/dog").relativize(FileSystems.getDefault().getPath("/etc")); } @@ -332,7 +331,7 @@ public void testRelativize_providerMismatch2() { @Test public void testResolve() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi").resolve("there").toString()).isEqualTo("/hi/there"); assertThat(fs.getPath("hi").resolve("there").toString()).isEqualTo("hi/there"); } @@ -340,7 +339,7 @@ public void testResolve() { @Test public void testResolve_providerMismatch() { - try (CloudStorageFileSystem gcs = forBucket("doodle")) { + try (CloudStorageFileSystem gcs = CloudStorageFileSystem.forBucket("doodle")) { thrown.expect(ProviderMismatchException.class); gcs.getPath("etc").resolve(FileSystems.getDefault().getPath("/dog")); } @@ -348,7 +347,7 @@ public void testResolve_providerMismatch() { @Test public void testIsAbsolute() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi").isAbsolute()).isTrue(); assertThat(fs.getPath("hi").isAbsolute()).isFalse(); } @@ -356,7 +355,7 @@ public void testIsAbsolute() { @Test public void testToAbsolutePath() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat((Object) fs.getPath("/hi").toAbsolutePath()).isEqualTo(fs.getPath("/hi")); assertThat((Object) fs.getPath("hi").toAbsolutePath()).isEqualTo(fs.getPath("/hi")); } @@ -364,14 +363,14 @@ public void testToAbsolutePath() { @Test public void testToAbsolutePath_withWorkingDirectory() { - try (CloudStorageFileSystem fs = forBucket("doodle", workingDirectory("/lol"))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", workingDirectory("/lol"))) { assertThat(fs.getPath("a").toAbsolutePath().toString()).isEqualTo("/lol/a"); } } @Test public void testGetFileName() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi/there").getFileName().toString()).isEqualTo("there"); assertThat(fs.getPath("military/fashion/show").getFileName().toString()).isEqualTo("show"); } @@ -379,7 +378,7 @@ public void testGetFileName() { @Test public void testCompareTo() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi/there").compareTo(fs.getPath("/hi/there"))).isEqualTo(0); assertThat(fs.getPath("/hi/there").compareTo(fs.getPath("/hi/therf"))).isEqualTo(-1); assertThat(fs.getPath("/hi/there").compareTo(fs.getPath("/hi/therd"))).isEqualTo(1); @@ -388,7 +387,7 @@ public void testCompareTo() { @Test public void testStartsWith() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi/there").startsWith(fs.getPath("/hi/there"))).isTrue(); assertThat(fs.getPath("/hi/there").startsWith(fs.getPath("/hi/therf"))).isFalse(); assertThat(fs.getPath("/hi/there").startsWith(fs.getPath("/hi"))).isTrue(); @@ -401,7 +400,7 @@ public void testStartsWith() { @Test public void testEndsWith() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { assertThat(fs.getPath("/hi/there").endsWith(fs.getPath("there"))).isTrue(); assertThat(fs.getPath("/hi/there").endsWith(fs.getPath("therf"))).isFalse(); assertThat(fs.getPath("/hi/there").endsWith(fs.getPath("/blag/therf"))).isFalse(); @@ -442,7 +441,7 @@ public void testRelativize_willWorkWithRecursiveCopy() throws IOException { @Test public void testToFile_unsupported() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { Path path = fs.getPath("/lol"); thrown.expect(UnsupportedOperationException.class); path.toFile(); @@ -451,7 +450,7 @@ public void testToFile_unsupported() { @Test public void testEquals() { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { new EqualsTester() // These are obviously equal. .addEqualityGroup(fs.getPath("/hello/cat"), fs.getPath("/hello/cat")) @@ -467,7 +466,7 @@ public void testEquals() { @Test public void testEquals_currentDirectoryIsTakenIntoConsideration() { - try (CloudStorageFileSystem fs = forBucket("doodle", workingDirectory("/hello"))) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle", workingDirectory("/hello"))) { new EqualsTester() .addEqualityGroup(fs.getPath("cat"), fs.getPath("/hello/cat")) .addEqualityGroup(fs.getPath(""), fs.getPath("/hello")) @@ -477,7 +476,7 @@ public void testEquals_currentDirectoryIsTakenIntoConsideration() { @Test public void testNullness() throws NoSuchMethodException, SecurityException { - try (CloudStorageFileSystem fs = forBucket("doodle")) { + try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket("doodle")) { NullPointerTester tester = new NullPointerTester(); tester.ignore(CloudStoragePath.class.getMethod("equals", Object.class)); tester.setDefault(Path.class, fs.getPath("sup")); diff --git a/gcloud-java-examples/pom.xml b/gcloud-java-examples/pom.xml index cc2aa1a8d423..c9a16bee21d6 100644 --- a/gcloud-java-examples/pom.xml +++ b/gcloud-java-examples/pom.xml @@ -52,25 +52,25 @@ - com.google.gcloud.examples.bigquery.BigQueryExample + com.google.cloud.examples.bigquery.BigQueryExample BigQueryExample - com.google.gcloud.examples.datastore.DatastoreExample + com.google.cloud.examples.datastore.DatastoreExample DatastoreExample - com.google.gcloud.examples.nio.Stat + com.google.cloud.examples.nio.Stat Stat - com.google.gcloud.examples.resourcemanager.ResourceManagerExample + com.google.cloud.examples.resourcemanager.ResourceManagerExample ResourceManagerExample - com.google.gcloud.examples.storage.StorageExample + com.google.cloud.examples.storage.StorageExample StorageExample diff --git a/gcloud-java-storage/src/main/java/com/google/cloud/storage/testing/FakeStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/cloud/storage/testing/FakeStorageRpc.java index 9d1ee654e070..3b372d33a09a 100644 --- a/gcloud-java-storage/src/main/java/com/google/cloud/storage/testing/FakeStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/cloud/storage/testing/FakeStorageRpc.java @@ -18,11 +18,10 @@ import com.google.api.services.storage.model.Bucket; import com.google.api.services.storage.model.StorageObject; -import com.google.cloud.storage.StorageBatch; -import com.google.cloud.storage.spi.RpcBatch; -import com.google.cloud.storage.spi.StorageRpc; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; +import com.google.cloud.storage.spi.RpcBatch; +import com.google.cloud.storage.spi.StorageRpc; import java.io.IOException; import java.io.InputStream;