http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/GetObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/GetObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/GetObjectOptions.java deleted file mode 100644 index 5fd9b0f..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/GetObjectOptions.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.GetOptions; - -/** - * Allows to optionally specify generation, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, - * ifMetagenerationNotMatch and projection, in addition to the values in {@link GetOptions}. - */ -public class GetObjectOptions extends GetOptions { - - public GetObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - this.queryParameters.put("ifGenerationMatch", checkNotNull(ifGenerationMatch, "ifGenerationMatch") + ""); - return this; - } - - public GetObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - this.queryParameters.put("ifGenerationNotMatch", checkNotNull(ifGenerationNotMatch, "ifGenerationNotMatch") + ""); - return this; - } - - public GetObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - this.queryParameters.put("ifMetagenerationMatch", checkNotNull(ifMetagenerationMatch, "ifMetagenerationMatch") - + ""); - return this; - } - - public GetObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - this.queryParameters.put("ifMetagenerationNotMatch", - checkNotNull(ifMetagenerationNotMatch, "ifMetagenerationNotMatch") + ""); - return this; - } - - public GetObjectOptions generation(Long generation) { - this.queryParameters.put("generation", checkNotNull(generation, "generation").toString()); - return this; - } - - public GetObjectOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public GetObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - return new GetObjectOptions().ifGenerationMatch(ifGenerationMatch); - } - - public GetObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - return new GetObjectOptions().ifGenerationNotMatch(ifGenerationNotMatch); - } - - public GetObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - return new GetObjectOptions().ifMetagenerationMatch(ifMetagenerationMatch); - } - - public GetObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - return new GetObjectOptions().ifMetagenerationNotMatch(ifMetagenerationNotMatch); - } - - public GetObjectOptions generation(Long generation) { - return new GetObjectOptions().generation(generation); - } - - public GetObjectOptions projection(Projection projection) { - return new GetObjectOptions().projection(projection); - } - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertBucketOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertBucketOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertBucketOptions.java deleted file mode 100644 index da3ce30..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertBucketOptions.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.PredefinedAcl; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Allows to optionally specify predefinedAcl and projection which used in Bucket - * - * @see <a href="https://developers.google.com/storage/docs/json_api/v1/buckets/insert"/> - */ -public class InsertBucketOptions extends BaseHttpRequestOptions { - - public InsertBucketOptions predefinedAcl(PredefinedAcl predefinedAcl) { - this.queryParameters.put("predefinedAcl", checkNotNull(predefinedAcl, "predefinedAcl").toString()); - return this; - } - - public InsertBucketOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public InsertBucketOptions predefinedAcl(PredefinedAcl predefinedAcl) { - return new InsertBucketOptions().predefinedAcl(predefinedAcl); - } - - public InsertBucketOptions projection(Projection projection) { - return new InsertBucketOptions().projection(projection); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertObjectOptions.java deleted file mode 100644 index e9af93c..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/InsertObjectOptions.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.PredefinedAcl; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Allows to optionally specify ifMetagenerationMatch,ifMetagenerationNotMatch and projection which used in Bucket - */ -public class InsertObjectOptions extends BaseHttpRequestOptions { - - public InsertObjectOptions contentEncoding(String contentEncoding) { - this.queryParameters.put("contentEncoding", checkNotNull(contentEncoding, "contentEncoding") + ""); - return this; - } - - public InsertObjectOptions name(String name) { - this.queryParameters.put("name", checkNotNull(name, "name") + ""); - return this; - } - - public InsertObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - this.queryParameters.put("ifGenerationMatch", checkNotNull(ifGenerationMatch, "ifGenerationMatch") + ""); - return this; - } - - public InsertObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - this.queryParameters.put("ifGenerationNotMatch", checkNotNull(ifGenerationNotMatch, "ifGenerationNotMatch") + ""); - return this; - } - - public InsertObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - this.queryParameters.put("ifMetagenerationMatch", checkNotNull(ifMetagenerationMatch, "ifMetagenerationMatch") - + ""); - return this; - } - - public InsertObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - this.queryParameters.put("ifMetagenerationNotMatch", - checkNotNull(ifMetagenerationNotMatch, "ifMetagenerationNotMatch") + ""); - return this; - } - - public InsertObjectOptions generation(Long generation) { - this.queryParameters.put("generation", checkNotNull(generation, "generation").toString()); - return this; - } - - public InsertObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - this.queryParameters.put("predefinedAcl", checkNotNull(predefinedAcl, "predefinedAcl").toString()); - return this; - } - - public InsertObjectOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public InsertObjectOptions contentEncoding(String contentEncoding) { - return new InsertObjectOptions().contentEncoding(contentEncoding); - } - - public InsertObjectOptions name(String name) { - return new InsertObjectOptions().name(name); - } - - public InsertObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - return new InsertObjectOptions().ifGenerationMatch(ifGenerationMatch); - } - - public InsertObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - return new InsertObjectOptions().ifGenerationNotMatch(ifGenerationNotMatch); - } - - public InsertObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - return new InsertObjectOptions().ifMetagenerationMatch(ifMetagenerationMatch); - } - - public InsertObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - return new InsertObjectOptions().ifMetagenerationNotMatch(ifMetagenerationNotMatch); - } - - public InsertObjectOptions generation(Long generation) { - return new InsertObjectOptions().generation(generation); - } - - public InsertObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - return new InsertObjectOptions().predefinedAcl(predefinedAcl); - } - - public UpdateObjectOptions projection(Projection projection) { - return new UpdateObjectOptions().projection(projection); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListObjectOptions.java deleted file mode 100644 index 8f5710a..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListObjectOptions.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class ListObjectOptions extends BaseHttpRequestOptions { - - public ListObjectOptions delimiter(String delimiter) { - this.queryParameters.put("delimiter", checkNotNull(delimiter, "delimiter")); - return this; - } - - public ListObjectOptions prefix(String prefix) { - this.queryParameters.put("prefix", checkNotNull(prefix, "delimeter")); - return this; - } - - public ListObjectOptions versions(Boolean versions) { - this.queryParameters.put("versions", checkNotNull(versions, "versions") + ""); - return this; - } - - public ListObjectOptions pageToken(String pageToken) { - this.queryParameters.put("pageToken", checkNotNull(pageToken, "pageToken")); - return this; - } - - public ListObjectOptions maxResults(Integer maxResults) { - this.queryParameters.put("maxResults", checkNotNull(maxResults, "maxResults") + ""); - return this; - } - - public ListObjectOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public ListObjectOptions delimiter(String delimiter) { - return new ListObjectOptions().delimiter(delimiter); - } - - public ListObjectOptions prefix(String prefix) { - return new ListObjectOptions().prefix(prefix); - } - - public ListObjectOptions versions(Boolean versions) { - return new ListObjectOptions().versions(versions); - } - - public ListObjectOptions pageToken(String pageToken) { - return new ListObjectOptions().pageToken(pageToken); - } - - public ListObjectOptions maxResults(Integer maxResults) { - return new ListObjectOptions().maxResults(maxResults); - } - - public ListObjectOptions projection(Projection projection) { - return new ListObjectOptions().projection(projection); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListOptions.java deleted file mode 100644 index 87aadb9..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/ListOptions.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; - -public class ListOptions extends org.jclouds.googlecloud.options.ListOptions { - - public ListOptions pageToken(String pageToken) { - this.queryParameters.put("pageToken", checkNotNull(pageToken, "pageToken")); - return this; - } - - @Override public ListOptions maxResults(Integer maxResults) { - return (ListOptions) super.maxResults(maxResults); - } - - public ListOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public ListOptions pageToken(String pageToken) { - return new ListOptions().pageToken(pageToken); - } - - public ListOptions maxResults(Integer maxResults) { - return new ListOptions().maxResults(maxResults); - } - - public ListOptions projection(Projection projection) { - return new ListOptions().projection(projection); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/RewriteObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/RewriteObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/RewriteObjectOptions.java deleted file mode 100644 index 0e93546..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/RewriteObjectOptions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.PredefinedAcl; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Allows to optionally specify ifMetagenerationMatch,ifMetagenerationNotMatch and projection which used in Bucket - */ -public class RewriteObjectOptions extends BaseHttpRequestOptions { - - // TODO(broudy): Refactor these redundant options out of every options class. - - public RewriteObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - this.queryParameters.put("ifGenerationMatch", checkNotNull(ifGenerationMatch, "ifGenerationMatch") + ""); - return this; - } - - public RewriteObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - this.queryParameters.put("ifGenerationNotMatch", checkNotNull(ifGenerationNotMatch, "ifGenerationNotMatch") + ""); - return this; - } - - public RewriteObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - this.queryParameters.put("ifMetagenerationMatch", checkNotNull(ifMetagenerationMatch, "ifMetagenerationMatch") - + ""); - return this; - } - - public RewriteObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - this.queryParameters.put("ifMetagenerationNotMatch", - checkNotNull(ifMetagenerationNotMatch, "ifMetagenerationNotMatch") + ""); - return this; - } - public RewriteObjectOptions ifSourceGenerationMatch(Long ifSourceGenerationMatch) { - this.queryParameters.put("ifSourceGenerationMatch", checkNotNull(ifSourceGenerationMatch, "ifSourceGenerationMatch") + ""); - return this; - } - - public RewriteObjectOptions ifSourceGenerationNotMatch(Long ifSourceGenerationNotMatch) { - this.queryParameters.put("ifSourceGenerationNotMatch", checkNotNull(ifSourceGenerationNotMatch, "ifSourceGenerationNotMatch") + ""); - return this; - } - - public RewriteObjectOptions ifSourceMetagenerationMatch(Long ifSourceMetagenerationMatch) { - this.queryParameters.put("ifSourceMetagenerationMatch", checkNotNull(ifSourceMetagenerationMatch, "ifSourceMetagenerationMatch") - + ""); - return this; - } - - public RewriteObjectOptions ifSourceMetagenerationNotMatch(Long ifSourceMetagenerationNotMatch) { - this.queryParameters.put("ifSourceMetagenerationNotMatch", - checkNotNull(ifSourceMetagenerationNotMatch, "ifSourceMetagenerationNotMatch") + ""); - return this; - } - - public RewriteObjectOptions sourceGeneration(Long sourceGeneration) { - this.queryParameters.put("sourceGeneration", checkNotNull(sourceGeneration, "sourceGeneration") + ""); - return this; - } - - public RewriteObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - this.queryParameters.put("predefinedAcl", checkNotNull(predefinedAcl, "predefinedAcl").toString()); - return this; - } - - public RewriteObjectOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public RewriteObjectOptions rewriteToken(String rewriteToken) { - this.queryParameters.put("rewriteToken", checkNotNull(rewriteToken, "rewriteToken").toString()); - return this; - } - - public RewriteObjectOptions maxBytesRewrittenPerCall(Long maxBytesRewrittenPerCall) { - this.queryParameters.put("maxBytesRewrittenPerCall", - checkNotNull(maxBytesRewrittenPerCall, "maxBytesRewrittenPerCall").toString()); - return this; - } - - public static class Builder { - - public RewriteObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - return new RewriteObjectOptions().ifGenerationMatch(ifGenerationMatch); - } - - public RewriteObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - return new RewriteObjectOptions().ifGenerationNotMatch(ifGenerationNotMatch); - } - - public RewriteObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - return new RewriteObjectOptions().ifMetagenerationMatch(ifMetagenerationMatch); - } - - public RewriteObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - return new RewriteObjectOptions().ifMetagenerationNotMatch(ifMetagenerationNotMatch); - } - - public RewriteObjectOptions ifSourceGenerationMatch(Long ifSourceGenerationMatch) { - return new RewriteObjectOptions().ifSourceGenerationMatch(ifSourceGenerationMatch); - } - - public RewriteObjectOptions ifSourceGenerationNotMatch(Long ifSourceGenerationNotMatch) { - return new RewriteObjectOptions().ifSourceGenerationNotMatch(ifSourceGenerationNotMatch); - } - - public RewriteObjectOptions ifSourceMetagenerationMatch(Long ifSourceMetagenerationMatch) { - return new RewriteObjectOptions().ifSourceMetagenerationMatch(ifSourceMetagenerationMatch); - } - - public RewriteObjectOptions ifSourceMetagenerationNotMatch(Long ifSourceMetagenerationNotMatch) { - return new RewriteObjectOptions().ifSourceMetagenerationNotMatch(ifSourceMetagenerationNotMatch); - } - - public RewriteObjectOptions sourceGeneration(Long sourceGeneration) { - return new RewriteObjectOptions().sourceGeneration(sourceGeneration); - } - - public RewriteObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - return new RewriteObjectOptions().predefinedAcl(predefinedAcl); - } - - public RewriteObjectOptions projection(Projection projection) { - return new RewriteObjectOptions().projection(projection); - } - - public RewriteObjectOptions rewriteToken(String rewriteToken) { - return new RewriteObjectOptions().rewriteToken(rewriteToken); - } - - public RewriteObjectOptions maxBytesRewrittenPerCall(Long maxBytesRewrittenPerCall) { - return new RewriteObjectOptions().maxBytesRewrittenPerCall(maxBytesRewrittenPerCall); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateBucketOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateBucketOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateBucketOptions.java deleted file mode 100644 index f5d0804..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateBucketOptions.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.PredefinedAcl; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Allows to optionally specify ifMetagenerationMatch,ifMetagenerationNotMatch and projection which used in Bucket - */ -public class UpdateBucketOptions extends BaseHttpRequestOptions { - - public UpdateBucketOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - this.queryParameters.put("ifMetagenerationMatch", checkNotNull(ifMetagenerationMatch, "ifMetagenerationMatch") - + ""); - return this; - } - - public UpdateBucketOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - this.queryParameters.put("ifMetagenerationNotMatch", - checkNotNull(ifMetagenerationNotMatch, "ifMetagenerationNotMatch") + ""); - return this; - } - - public UpdateBucketOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public UpdateBucketOptions predefinedAcl(PredefinedAcl predefinedAcl) { - this.queryParameters.put("predefinedAcl", checkNotNull(predefinedAcl, "predefinedAcl").toString()); - return this; - } - - public static class Builder { - - public UpdateBucketOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - return new UpdateBucketOptions().ifMetagenerationMatch(ifMetagenerationMatch); - } - - public UpdateBucketOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - return new UpdateBucketOptions().ifMetagenerationNotMatch(ifMetagenerationNotMatch); - } - - public UpdateBucketOptions projection(Projection projection) { - return new UpdateBucketOptions().projection(projection); - } - - public UpdateBucketOptions predefinedAcl(PredefinedAcl predefinedAcl) { - return new UpdateBucketOptions().predefinedAcl(predefinedAcl); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateObjectOptions.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateObjectOptions.java deleted file mode 100644 index 1fca761..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/options/UpdateObjectOptions.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.PredefinedAcl; -import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Allows to optionally specify ifMetagenerationMatch,ifMetagenerationNotMatch and projection which used in Bucket - */ -public class UpdateObjectOptions extends BaseHttpRequestOptions { - - public UpdateObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - this.queryParameters.put("ifGenerationMatch", checkNotNull(ifGenerationMatch, "ifGenerationMatch") - + ""); - return this; - } - - public UpdateObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - this.queryParameters.put("ifGenerationNotMatch", - checkNotNull(ifGenerationNotMatch, "ifGenerationNotMatch") + ""); - return this; - } - - public UpdateObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - this.queryParameters.put("ifMetagenerationMatch", checkNotNull(ifMetagenerationMatch, "ifMetagenerationMatch") - + ""); - return this; - } - - public UpdateObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - this.queryParameters.put("ifMetagenerationNotMatch", - checkNotNull(ifMetagenerationNotMatch, "ifMetagenerationNotMatch") + ""); - return this; - } - - public UpdateObjectOptions generation(Long generation) { - this.queryParameters.put("generation", checkNotNull(generation, "generation").toString()); - return this; - } - - public UpdateObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - this.queryParameters.put("predefinedAcl", checkNotNull(predefinedAcl, "predefinedAcl").toString()); - return this; - } - - - public UpdateObjectOptions projection(Projection projection) { - this.queryParameters.put("projection", checkNotNull(projection, "projection").toString()); - return this; - } - - public static class Builder { - - public UpdateObjectOptions ifGenerationMatch(Long ifGenerationMatch) { - return new UpdateObjectOptions().ifGenerationMatch(ifGenerationMatch); - } - - public UpdateObjectOptions ifGenerationNotMatch(Long ifGenerationNotMatch) { - return new UpdateObjectOptions().ifGenerationNotMatch(ifGenerationNotMatch); - } - - public UpdateObjectOptions ifMetagenerationMatch(Long ifMetagenerationMatch) { - return new UpdateObjectOptions().ifMetagenerationMatch(ifMetagenerationMatch); - } - - public UpdateObjectOptions ifMetagenerationNotMatch(Long ifMetagenerationNotMatch) { - return new UpdateObjectOptions().ifMetagenerationNotMatch(ifMetagenerationNotMatch); - } - - public UpdateObjectOptions generation(Long generation) { - return new UpdateObjectOptions().generation(generation); - } - - public UpdateObjectOptions predefinedAcl(PredefinedAcl predefinedAcl) { - return new UpdateObjectOptions().predefinedAcl(predefinedAcl); - } - - public UpdateBucketOptions projection(Projection projection) { - return new UpdateBucketOptions().projection(projection); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToPayloadEnclosing.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToPayloadEnclosing.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToPayloadEnclosing.java deleted file mode 100644 index 8eceede..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToPayloadEnclosing.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.parser; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.internal.PayloadEnclosingImpl; - -import com.google.common.base.Function; - -public class ParseToPayloadEnclosing implements Function<HttpResponse, PayloadEnclosingImpl> { - - @Override - public PayloadEnclosingImpl apply(HttpResponse response) { - PayloadEnclosingImpl impl = new PayloadEnclosingImpl(); - impl.setPayload(response.getPayload()); - - return impl; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToResumableUpload.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToResumableUpload.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToResumableUpload.java deleted file mode 100644 index bfeca99..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/parser/ParseToResumableUpload.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.parser; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.regex.Pattern; - -import org.jclouds.googlecloudstorage.domain.ResumableUpload; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; - -public class ParseToResumableUpload implements Function<HttpResponse, ResumableUpload> { - - @Override - public ResumableUpload apply(HttpResponse response) { - - String contentLength = response.getFirstHeaderOrNull("Content-Length"); - String sessionUri = response.getFirstHeaderOrNull("Location"); - String uploadId = null; - if (sessionUri != null) { - uploadId = getUploadId(sessionUri); - } - String range = response.getFirstHeaderOrNull("Range"); - Long upperLimit = null; - Long lowerLimit = null; - if (range != null) { - upperLimit = getUpperLimitFromRange(range); - lowerLimit = getLowerLimitFromRange(range); - if (lowerLimit != null && upperLimit != null) { - checkArgument(lowerLimit < upperLimit, "lower range must less than upper range, was: %s - %s", lowerLimit, - upperLimit); - } - } - - return ResumableUpload.create(response.getStatusCode(), uploadId, contentLength, upperLimit, lowerLimit); - } - - // Return the Id of the Upload - private String getUploadId(String sessionUri) { - // TODO: better way to parse query parameters? - return Splitter.on(Pattern.compile("\\&")).trimResults().omitEmptyStrings().withKeyValueSeparator("=") - .split(sessionUri).get("upload_id"); - } - - private long getUpperLimitFromRange(String range) { - String upperLimit = range.split("-")[1]; - return Long.parseLong(upperLimit); - } - - private long getLowerLimitFromRange(String range) { - String removeByte = range.split("=")[1]; - String lowerLimit = removeByte.split("-")[0]; - return Long.parseLong(lowerLimit); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/reference/GoogleCloudStorageConstants.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/reference/GoogleCloudStorageConstants.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/reference/GoogleCloudStorageConstants.java deleted file mode 100644 index 299a249..0000000 --- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/reference/GoogleCloudStorageConstants.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.reference; - -import com.google.common.annotations.Beta; - -public final class GoogleCloudStorageConstants { - - private GoogleCloudStorageConstants() { - } - - /** - * The total time, in msecs, to wait for an operation to complete. - */ - @Beta - public static final String OPERATION_COMPLETE_TIMEOUT = "jclouds.google-cloud-storage.operation-complete-timeout"; - - /** - * The interval, in msecs, between calls to check whether an operation has completed. - */ - @Beta - public static final String OPERATION_COMPLETE_INTERVAL = "jclouds.google-cloud-storage.operation-complete-interval"; -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadataTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadataTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadataTest.java deleted file mode 100644 index 2ddc1c2..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadataTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * Tests that GoogleComputeProviderMetadata is properly registered in ServiceLoader - * <p/> - * <pre> - * META-INF/services/org.jclouds.providers.ProviderMetadata - * </pre> - */ -@Test(groups = "unit", testName = "GoogleCloudStorageProviderMetadataTest") -public class GoogleCloudStorageProviderMetadataTest extends BaseProviderMetadataTest { - public GoogleCloudStorageProviderMetadataTest() { - super(new GoogleCloudStorageProviderMetadata(), new GoogleCloudStorageApiMetadata()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobIntegrationLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobIntegrationLiveTest.java deleted file mode 100644 index d68441c..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobIntegrationLiveTest.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.blobstore.integration; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.assertj.core.api.Fail; -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.domain.BlobBuilder.PayloadBlobBuilder; -import org.jclouds.blobstore.domain.BlobMetadata; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.blobstore.domain.StorageMetadata; -import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; -import org.jclouds.blobstore.options.PutOptions; -import org.jclouds.googlecloud.internal.TestProperties; -import org.jclouds.io.Payloads; -import org.jclouds.io.payloads.ByteSourcePayload; -import org.jclouds.utils.TestUtils; -import org.testng.SkipException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.collect.ImmutableMap; -import com.google.common.hash.HashCode; -import com.google.common.hash.HashFunction; -import com.google.common.hash.Hashing; -import com.google.common.io.ByteSource; -import com.google.common.io.Files; - -@Test(groups = { "live", "blobstorelive" }) -public class GoogleCloudStorageBlobIntegrationLiveTest extends BaseBlobIntegrationTest { - - private long PART_SIZE = 5L * 1024L * 1024L; - - @Override - protected long getMinimumMultipartBlobSize() { - return PART_SIZE + 1; - } - - public GoogleCloudStorageBlobIntegrationLiveTest() throws IOException { - provider = "google-cloud-storage"; - } - - @Override protected Properties setupProperties() { - TestProperties.setGoogleCredentialsFromJson(provider); - Properties properties = super.setupProperties(); - properties.put("jclouds.mpu.parts.size", 2 * 1024 * 1024); - return TestProperties.apply(provider, properties); - } - - @Override - @Test(enabled = false) - public void testGetTwoRanges() throws SkipException { - // not supported in GoogleCloudStorage - } - - @Override - @Test(enabled = false) - public void testGetRange() throws SkipException { - // not supported in GoogleCloudStorage - } - - @Override - @Test(enabled = false) - public void testCreateBlobWithExpiry() throws SkipException { - // not supported in object level. - } - - @Override - @Test(groups = { "integration", "live" }, dataProvider = "gcsPutTest") - public void testPutObject(String name, String type, Object content, Object realObject) throws InterruptedException, - IOException { - PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content)) - .contentType(type); - addContentMetadata(blobBuilder); - Blob blob = blobBuilder.build(); - blob.getPayload().setContentMetadata(blob.getMetadata().getContentMetadata()); - String container = getContainerName(); - - try { - assertNotNull(view.getBlobStore().putBlob(container, blob)); - blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName()); - validateMetadata(blob.getMetadata(), container, name); - checkContentMetadata(blob); - - String returnedString = getContentAsStringOrNullAndClose(blob); - assertEquals(returnedString, realObject); - PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container); - assertThat(set).isNotEmpty(); - } finally { - returnContainer(container); - } - } - - @Override - protected void addContentMetadata(PayloadBlobBuilder blobBuilder) { - blobBuilder.contentType("text/csv"); - blobBuilder.contentDisposition("attachment; filename=photo.jpg"); - // TODO: causes failures with subsequent GET operations: - // HTTP/1.1 failed with response: HTTP/1.1 503 Service Unavailable; content: [Service Unavailable] - //blobBuilder.contentEncoding("gzip"); - blobBuilder.contentLanguage("en"); - } - - @Override - protected void checkContentMetadata(Blob blob) { - checkContentType(blob, "text/csv"); - checkContentDisposition(blob, "attachment; filename=photo.jpg"); - //checkContentEncoding(blob, "gzip"); - checkContentLanguage(blob, "en"); - } - - @DataProvider(name = "gcsPutTest") - public Object[][] createData1() throws IOException { - File file = new File("pom.xml"); - String realObject = Files.toString(file, Charsets.UTF_8); - - return new Object[][] { { "file.xml", "text/xml", file, realObject }, - { "string.xml", "text/xml", realObject, realObject }, - { "stringwith/slash.xml", "text/xml", realObject, realObject }, - { "bytes.xml", "application/octet-stream", realObject.getBytes(), realObject } }; - } - - // Content-Length should not be null - @Override - public void testPutObjectStream() throws InterruptedException, IOException, java.util.concurrent.ExecutionException { - - ByteSource byteSource = ByteSource.wrap("foo".getBytes()); - ByteSourcePayload payload = new ByteSourcePayload(byteSource); - PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder("streaming").payload(payload) - .contentLength(byteSource.read().length); - addContentMetadata(blobBuilder); - - Blob blob = blobBuilder.build(); - String container = getContainerName(); - - try { - assertNotNull(view.getBlobStore().putBlob(container, blob)); - - blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName()); - String returnedString = getContentAsStringOrNullAndClose(blob); - assertEquals(returnedString, "foo"); - validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName()); - checkContentMetadata(blob); - PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container); - assertThat(set).isNotEmpty(); - } finally { - returnContainer(container); - } - }; - - @Override - public void testMetadata() throws InterruptedException, IOException { - String name = "hello"; - - HashFunction hf = Hashing.md5(); - HashCode md5 = hf.newHasher().putString(TEST_STRING, Charsets.UTF_8).hash(); - Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("adrian", "powderpuff")) - .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).contentMD5(md5).build(); - String container = getContainerName(); - try { - assertNull(view.getBlobStore().blobMetadata(container, "powderpuff")); - - addBlobToContainer(container, blob); - Blob newObject = validateContent(container, name); - - BlobMetadata metadata = newObject.getMetadata(); - - validateMetadata(metadata); - validateMetadata(metadata, container, name); - validateMetadata(view.getBlobStore().blobMetadata(container, name)); - - blob.getMetadata().getUserMetadata().put("adrian", "wonderpuff"); - blob.getMetadata().getUserMetadata().put("adrian", "powderpuff"); - - addBlobToContainer(container, blob); - validateMetadata(view.getBlobStore().blobMetadata(container, name)); - - } finally { - returnContainer(container); - } - } - - @Override - protected void checkMD5(BlobMetadata metadata) throws IOException { - HashCode md5 = Hashing.md5().hashString(TEST_STRING, Charsets.UTF_8); - assertEquals(metadata.getContentMetadata().getContentMD5AsHashCode(), md5); - } - - @Test(groups = { "integration", "live" }) - public void testMultipartChunkedFileStream() throws IOException, InterruptedException { - String containerName = getContainerName(); - try { - BlobStore blobStore = view.getBlobStore(); - long countBefore = blobStore.countBlobs(containerName); - - addMultipartBlobToContainer(containerName, "const.txt"); - - long countAfter = blobStore.countBlobs(containerName); - assertThat(countAfter).isEqualTo(countBefore + 1); - } finally { - returnContainer(containerName); - } - } - - protected void addMultipartBlobToContainer(String containerName, String key) throws IOException { - ByteSource sourceToUpload = TestUtils.randomByteSource().slice(0, PART_SIZE + 1); - - BlobStore blobStore = view.getBlobStore(); - blobStore.createContainerInLocation(null, containerName); - Blob blob = blobStore.blobBuilder(key).payload(sourceToUpload).contentLength(sourceToUpload.size()) - .contentType(MediaType.TEXT_PLAIN).build(); - blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()); - } - - @DataProvider(name = "delete") - public Object[][] createData() { - if (System.getProperty("os.name").toLowerCase().contains("windows")) { - return new Object[][] { { "normal" }, { "sp ace" } }; - } else { - return new Object[][] { { "normal" }, { "sp ace" }, { "qu?stion" }, { "path/foo" }, { "colon:" }, - { "asteri*k" }, { "quote\"" }, { "{great<r}" }, { "lesst>en" }, { "p|pe" } }; - } - } - - // Remove "unicâªde" from DataProvider - @Override - @Test(groups = { "integration", "live" }, dataProvider = "delete") - public void deleteObject(String name) throws InterruptedException { - super.deleteObject(name); - } - - @Override - public void testSetBlobAccess() throws Exception { - try { - super.testSetBlobAccess(); - Fail.failBecauseExceptionWasNotThrown(UnsupportedOperationException.class); - } catch (UnsupportedOperationException uoe) { - throw new SkipException("request signing not supported on GCS", uoe); - } - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfMatch() throws Exception { - super.testCopyIfMatch(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfMatchNegative() throws Exception { - super.testCopyIfMatch(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfNoneMatch() throws Exception { - super.testCopyIfNoneMatch(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfNoneMatchNegative() throws Exception { - super.testCopyIfNoneMatch(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfModifiedSince() throws Exception { - super.testCopyIfModifiedSince(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfModifiedSinceNegative() throws Exception { - super.testCopyIfModifiedSince(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfUnmodifiedSince() throws Exception { - super.testCopyIfUnmodifiedSince(); - } - - @Override - @Test(expectedExceptions = UnsupportedOperationException.class) - public void testCopyIfUnmodifiedSinceNegative() throws Exception { - super.testCopyIfUnmodifiedSince(); - } - - @Override - public void testListMultipartUploads() throws Exception { - try { - super.testListMultipartUploads(); - } catch (UnsupportedOperationException uoe) { - throw new SkipException("GCS does not support listing multipart uploads", uoe); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobLiveTest.java deleted file mode 100644 index 2584b02..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobLiveTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.blobstore.integration; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest; -import org.jclouds.googlecloud.internal.TestProperties; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.internal.PayloadEnclosingImpl; -import org.jclouds.io.ByteStreams2; -import org.jclouds.io.Payloads; -import org.jclouds.io.payloads.ByteSourcePayload; -import org.jclouds.utils.TestUtils; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.hash.HashCode; -import com.google.common.hash.Hashing; -import com.google.common.io.BaseEncoding; -import com.google.common.io.ByteSource; - -@Test(groups = { "live" }) -public class GoogleCloudStorageBlobLiveTest extends BaseBlobLiveTest { - private static final String sysHttpStreamUrl = System.getProperty("jclouds.blobstore.httpstream.url"); - private static final String sysHttpStreamMD5 = System.getProperty("jclouds.blobstore.httpstream.md5"); - - public GoogleCloudStorageBlobLiveTest() { - provider = "google-cloud-storage"; - } - - @Override protected Properties setupProperties() { - TestProperties.setGoogleCredentialsFromJson(provider); - return TestProperties.apply(provider, super.setupProperties()); - } - - @Override - @Parameters({ "jclouds.blobstore.httpstream.url", "jclouds.blobstore.httpstream.md5" }) - public void testCopyUrl(String httpStreamUrl, String httpStreamMD5) throws Exception { - httpStreamUrl = checkNotNull(httpStreamUrl != null ? httpStreamUrl : sysHttpStreamUrl, "httpStreamUrl"); - httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5"); - - HttpResponse response = view.utils().http() - .invoke(HttpRequest.builder().method("GET").endpoint(httpStreamUrl).build()); - long length = response.getPayload().getContentMetadata().getContentLength(); - - checkNotNull(response.getPayload().getContentMetadata().getContentType()); - assertEquals(response.getPayload().getContentMetadata().getContentType(), "application/x-gzip"); - - String name = "hello"; - HashCode md5 = HashCode.fromBytes(BaseEncoding.base16().lowerCase().decode(httpStreamMD5)); - byte[] payload = ByteStreams2.toByteArrayAndClose(response.getPayload().getInput()); - - Blob blob = view.getBlobStore().blobBuilder(name).payload(payload).contentLength(length) - .contentType(response.getPayload().getContentMetadata().getContentType()) - .contentMD5(md5).build(); - String container = getContainerName(); - try { - assertNotNull(view.getBlobStore().putBlob(container, blob)); - checkMD5(container, name, md5.asBytes()); - } finally { - returnContainer(container); - } - } - - @Test(groups = "live") - public void testPutBlobWithMd5() throws IOException, InterruptedException { - String containerName = getContainerName(); - String blobName = "md5test"; - try { - long contentLength = 32 * 1024L; - ByteSource byteSource = TestUtils.randomByteSource().slice(0, contentLength); - ByteSourcePayload payload = Payloads.newByteSourcePayload(byteSource); - PayloadEnclosingImpl payloadImpl = new PayloadEnclosingImpl(payload); - - BlobStore blobStore = view.getBlobStore(); - - // This would trigger server side validation of md5 - HashCode hcMd5 = byteSource.hash(Hashing.md5()); - - Blob blob = blobStore.blobBuilder(blobName).payload(payloadImpl.getPayload()).contentType("image/jpeg") - .contentLength(contentLength).contentLanguage("en").contentDisposition("attachment") - .contentMD5(hcMd5).userMetadata(ImmutableMap.of("Adrian", "powderpuff")).build(); - - blobStore.putBlob(containerName, blob); - checkMD5(containerName, blobName, hcMd5.asBytes()); - - } finally { - returnContainer(containerName); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobSignerLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobSignerLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobSignerLiveTest.java deleted file mode 100644 index 2f76490..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageBlobSignerLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.blobstore.integration; - -import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest; -import org.testng.SkipException; -import org.testng.annotations.Test; - -@Test(groups = { "live" }) -public class GoogleCloudStorageBlobSignerLiveTest extends BaseBlobSignerLiveTest { - public GoogleCloudStorageBlobSignerLiveTest() { - provider = "google-cloud-storage"; - } - - public void testSignRemoveUrl() throws Exception { - try { - super.testSignRemoveUrl(); - } catch (UnsupportedOperationException uoe) { - throw new SkipException("not yet implemented in GCS", uoe); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java deleted file mode 100644 index ff7f665..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.blobstore.integration; - -import static com.google.common.collect.Iterables.get; -import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.assertj.core.api.Fail; -import org.jclouds.blobstore.domain.BlobMetadata; -import org.jclouds.blobstore.domain.PageSet; -import org.jclouds.blobstore.domain.StorageMetadata; -import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; -import org.jclouds.googlecloud.internal.TestProperties; -import org.testng.SkipException; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.collect.ImmutableMap; -import com.google.common.hash.Hashing; - -public class GoogleCloudStorageContainerIntegrationLiveTest extends BaseContainerIntegrationTest { - - public GoogleCloudStorageContainerIntegrationLiveTest() { - provider = "google-cloud-storage"; - } - - @Override protected Properties setupProperties() { - TestProperties.setGoogleCredentialsFromJson(provider); - return TestProperties.apply(provider, super.setupProperties()); - } - - @Override - @Test(groups = { "integration", "live" }) - public void testWithDetails() throws InterruptedException, IOException { - String key = "hello"; - String containerName = getContainerName(); - try { - addBlobToContainer( - containerName, - view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("adrian", "powderpuff")) - .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) - .contentMD5(Hashing.md5().newHasher().putString(TEST_STRING, Charsets.UTF_8).hash()).build()); - validateContent(containerName, key); - - PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, - maxResults(1).withDetails()); - - BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); - - assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() - .getContentType(); - assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); - assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); - checkMD5(metadata); - } finally { - returnContainer(containerName); - } - } - - @Override - public void testDirectory() throws InterruptedException { - // TODO: testDirectory fails when querying blob with name "directory/directory"; querying "directory%2Fdirectory" - // succeeds, however. I believe this is an escaping issue that should be addressed. - throw new SkipException("directories are not supported in GoogleCloudStorage"); - } - - @Override - public void testListMarkerAfterLastKey() throws Exception { - throw new SkipException("cannot specify arbitrary markers"); - } - - @Override - public void testListMarkerPrefix() throws Exception { - throw new SkipException("cannot specify arbitrary markers"); - } - - @Override - public void testSetContainerAccess() throws Exception { - try { - super.testSetContainerAccess(); - Fail.failBecauseExceptionWasNotThrown(UnsupportedOperationException.class); - } catch (UnsupportedOperationException uoe) { - throw new SkipException("request signing not supported on GCS", uoe); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerLiveTest.java deleted file mode 100644 index 559713b..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecloudstorage.blobstore.integration; - -import java.util.Properties; - -import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest; -import org.jclouds.googlecloud.internal.TestProperties; -import org.testng.annotations.Test; - -@Test(groups = { "live" }) -public class GoogleCloudStorageContainerLiveTest extends BaseContainerLiveTest { - - public GoogleCloudStorageContainerLiveTest() { - provider = "google-cloud-storage"; - } - - @Override protected Properties setupProperties() { - TestProperties.setGoogleCredentialsFromJson(provider); - return TestProperties.apply(provider, super.setupProperties()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiExpectTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiExpectTest.java deleted file mode 100644 index 79f96f6..0000000 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApiExpectTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.googlecloudstorage.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.AssertJUnit.assertNull; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role; -import org.jclouds.googlecloudstorage.domain.templates.BucketAccessControlsTemplate; -import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageApiExpectTest; -import org.jclouds.googlecloudstorage.parse.BucketAclGetTest; -import org.jclouds.googlecloudstorage.parse.BucketAclInsertTest; -import org.jclouds.googlecloudstorage.parse.BucketAclListTest; -import org.jclouds.googlecloudstorage.parse.BucketAclUpdateTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "BucketAccessControlsApiExpectTest") -public class BucketAccessControlsApiExpectTest extends BaseGoogleCloudStorageApiExpectTest { - - private static final String EXPECTED_TEST_BUCKET = "jcloudstestbucket"; - - public static final HttpRequest GET_BUCKETACL_REQUEST = HttpRequest.builder().method("GET") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl/allUsers") - .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build(); - - private final HttpResponse GET_BUCKETACL_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/bucket_acl_get.json")).build(); - - private final HttpResponse CREATE_BUCKETACL_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/bucket_acl_insert_response.json")).build(); - - private final HttpRequest LIST_BUCKETACL_REQUEST = HttpRequest.builder().method("GET") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl") - .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build(); - - private final HttpResponse LIST_BUCKETACL_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/bucket_acl_list.json")).build(); - - // Test getBucketAccessControls - public void testGetBucketAclResponseIs2xx() throws Exception { - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - GET_BUCKETACL_REQUEST, GET_BUCKETACL_RESPONSE).getBucketAccessControlsApi(); - - assertEquals(api.getBucketAccessControls(EXPECTED_TEST_BUCKET, "allUsers"), new BucketAclGetTest().expected()); - } - - public void testGetBucketAclResponseIs4xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - GET_BUCKETACL_REQUEST, getResponse).getBucketAccessControlsApi(); - - assertNull("404", api.getBucketAccessControls(EXPECTED_TEST_BUCKET, "allUsers")); - - } - - // Test listBucketAccessControls - public void testListBucketAclResponseIs2xx() throws Exception { - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - LIST_BUCKETACL_REQUEST, LIST_BUCKETACL_RESPONSE).getBucketAccessControlsApi(); - - assertEquals(api.listBucketAccessControls(EXPECTED_TEST_BUCKET), new BucketAclListTest().expected()); - - } - - public void testListBucketAclResponseIs4xx() throws Exception { - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - LIST_BUCKETACL_REQUEST, listResponse).getBucketAccessControlsApi(); - - assertNull(api.listBucketAccessControls("jcloudstestbucket")); - } - - // Test insertBucketAccessControls - public void testInsertBucketAclResponseIs2xx() throws Exception { - HttpRequest insertRequest = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/bucket_acl_insert_initial.json", - MediaType.APPLICATION_JSON)).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - insertRequest, CREATE_BUCKETACL_RESPONSE).getBucketAccessControlsApi(); - - BucketAccessControlsTemplate template = BucketAccessControlsTemplate.create("allAuthenticatedUsers", Role.WRITER); - - assertEquals(api.createBucketAccessControls(EXPECTED_TEST_BUCKET, template), new BucketAclInsertTest().expected()); - } - - // Test deleteBucketAccessControls - public void testDeleteBucketAclResponseIs2xx() throws Exception { - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl/allAuthenticatedUsers") - .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(204).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - delete, deleteResponse).getBucketAccessControlsApi(); - - assertEquals(api.deleteBucketAccessControls(EXPECTED_TEST_BUCKET, "allAuthenticatedUsers"), deleteResponse); - } - - public void testDeleteBucketAclResponseIs4xx() throws Exception { - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl/allAuthenticatedUsers") - .addHeader("Accept", "application/json").addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - delete, deleteResponse).getBucketAccessControlsApi(); - - assertNull(api.deleteBucketAccessControls(EXPECTED_TEST_BUCKET, "allAuthenticatedUsers")); - } - - // Test updateBucketAccessControls - public void testUpdateBucketAclResponseIs2xx() throws Exception { - HttpRequest update = HttpRequest - .builder() - .method("PUT") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl/allUsers") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/bucket_acl_update_initial.json", - MediaType.APPLICATION_JSON)).build(); - - HttpResponse updateResponse = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/bucket_acl_update_response.json")).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - update, updateResponse).getBucketAccessControlsApi(); - - BucketAccessControlsTemplate template = BucketAccessControlsTemplate.create("allUsers", Role.OWNER); - - assertEquals(api.updateBucketAccessControls(EXPECTED_TEST_BUCKET, "allUsers", template), - new BucketAclUpdateTest().expected()); - } - - // Test updateBucketAccessControls - public void testPatchBucketAclResponseIs2xx() throws Exception { - HttpRequest patchRequest = HttpRequest - .builder() - .method("PATCH") - .endpoint("https://www.googleapis.com/storage/v1/b/jcloudstestbucket/acl/allUsers") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/bucket_acl_update_initial.json", - MediaType.APPLICATION_JSON)).build(); - - HttpResponse patchResponse = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/bucket_acl_update_response.json")).build(); - - BucketAccessControlsApi api = requestsSendResponses(requestForScopes(STORAGE_FULLCONTROL_SCOPE), TOKEN_RESPONSE, - patchRequest, patchResponse).getBucketAccessControlsApi(); - - BucketAccessControlsTemplate template = BucketAccessControlsTemplate.create("allUsers", Role.OWNER); - - assertEquals(api.patchBucketAccessControls(EXPECTED_TEST_BUCKET, "allUsers", template), - new BucketAclUpdateTest().expected()); - } -}
