Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing subpackages #221

Merged
merged 4 commits into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* <p>A simple usage example:
* <p>Before the test:
* <pre> {@code
* LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT_NUMBER);

This comment was marked as spam.

* DatastoreOptions options = DatastoreOptions.builder()
* .projectId(PROJECT_ID)
* .host("localhost:8080")
* .build();
* Datastore localDatastore = DatastoreFactory.instance().get(options);
* } </pre>
*
* <p>After the test:
* <pre> {@code
* gcdHelper.stop();
* } </pre>
*
* @see <a href="https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md#testing-code-that-uses-datastore">
* gcloud-java tools for testing</a>
*/
package com.google.gcloud.datastore.testing;
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* <p>A simple usage example:
* <p>Before the test:
* <pre> {@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));
* } </pre>
*
* <p>After the test:
* <pre> {@code
* RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
* } </pre>
*
* @see <a href="https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md#testing-code-that-uses-storage">
* gcloud-java tools for testing</a>
*/
package com.google.gcloud.storage.testing;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down