diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelper.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java similarity index 99% rename from gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelper.java rename to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java index 0e0e726a7fba..e9cd54a7dc95 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelper.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.datastore; +package com.google.gcloud.datastore.testing; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/package-info.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/package-info.java new file mode 100644 index 000000000000..9d20b3c7ffd8 --- /dev/null +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/package-info.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed 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. + */ + +/** + * A testing helper for Google Cloud Datastore. + * + *

A simple usage example: + *

Before the test: + *

 {@code
+ * LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT_NUMBER);
+ * DatastoreOptions options = DatastoreOptions.builder()
+ *     .projectId(PROJECT_ID)
+ *     .host("localhost:8080")
+ *     .build();
+ * Datastore localDatastore = DatastoreFactory.instance().get(options);
+ * } 
+ * + *

After the test: + *

 {@code
+ * gcdHelper.stop();
+ * } 
+ * + * @see + * gcloud-java tools for testing + */ +package com.google.gcloud.datastore.testing; diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java index b3365876773e..f9200b3327e1 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import com.google.gcloud.datastore.testing.LocalGcdHelper; import com.google.gcloud.spi.DatastoreRpc; import com.google.gcloud.spi.DatastoreRpcFactory; diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index e5f632d0fe14..0bef237ee48a 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -33,6 +33,7 @@ import com.google.gcloud.datastore.StructuredQuery.OrderBy; import com.google.gcloud.datastore.StructuredQuery.Projection; import com.google.gcloud.datastore.StructuredQuery.PropertyFilter; +import com.google.gcloud.datastore.testing.LocalGcdHelper; import com.google.gcloud.spi.DatastoreRpc; import com.google.gcloud.spi.DatastoreRpc.DatastoreRpcException.Reason; import com.google.gcloud.spi.DatastoreRpcFactory; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelper.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java similarity index 93% rename from gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelper.java rename to gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java index b6e8daeec445..e4d92b71a940 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelper.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java @@ -14,12 +14,16 @@ * limitations under the License. */ -package com.google.gcloud.storage; +package com.google.gcloud.storage.testing; import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; +import com.google.gcloud.storage.BlobInfo; import com.google.gcloud.RetryParams; -import com.google.gcloud.storage.RemoteGcsHelper.Option.KeyFromClasspath; +import com.google.gcloud.storage.Storage; +import com.google.gcloud.storage.StorageException; +import com.google.gcloud.storage.StorageOptions; +import com.google.gcloud.storage.testing.RemoteGcsHelper.Option.KeyFromClasspath; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -54,7 +58,7 @@ private RemoteGcsHelper(StorageOptions options) { } /** - * Returns a {@StorageOptions} object to be used for testing. + * Returns a {@link StorageOptions} object to be used for testing. */ public StorageOptions options() { return options; @@ -99,7 +103,7 @@ public static String generateBucketName() { * @param keyPath path to the JSON key to be used for running the tests * @param options creation options * @return A {@code RemoteGcsHelper} object for the provided options. - * @throws com.google.gcloud.storage.RemoteGcsHelper.GcsHelperException if the file pointed by + * @throws com.google.gcloud.storage.testing.RemoteGcsHelper.GcsHelperException if the file pointed by * {@code keyPath} does not exist */ public static RemoteGcsHelper create(String projectId, String keyPath, Option... options) @@ -145,7 +149,7 @@ public static RemoteGcsHelper create(String projectId, String keyPath, Option... * * @param options creation options * @return A {@code RemoteGcsHelper} object for the provided options. - * @throws com.google.gcloud.storage.RemoteGcsHelper.GcsHelperException if environment variables + * @throws com.google.gcloud.storage.testing.RemoteGcsHelper.GcsHelperException if environment variables * {@code GCLOUD_TESTS_PROJECT_ID} and {@code GCLOUD_TESTS_KEY} are not set or if the file * pointed by {@code GCLOUD_TESTS_KEY} does not exist */ diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/package-info.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/package-info.java new file mode 100644 index 000000000000..eca45b4b6306 --- /dev/null +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/package-info.java @@ -0,0 +1,37 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed 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. + */ + +/** + * A testing helper for Google Cloud Storage. + * + *

A simple usage example: + *

Before the test: + *

 {@code
+ * RemoteGcsHelper gcsHelper = RemoteGcsHelper.create(PROJECT_ID, "/path/to/JSON/key.json");
+ * Storage storage = StorageFactory.instance().get(gcsHelper.options());
+ * String bucket = RemoteGcsHelper.generateBucketName();
+ * storage.create(BucketInfo.of(bucket));
+ * } 
+ * + *

After the test: + *

 {@code
+ * RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
+ * } 
+ * + * @see + * gcloud-java tools for testing + */ +package com.google.gcloud.storage.testing; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java index f4cf11d9a73f..4c3ff1fa9a7c 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import com.google.gcloud.storage.testing.RemoteGcsHelper; import java.io.ByteArrayInputStream; import java.io.IOException;