From 3fdecb69cb866c424a6ab0a6d1fb6756f528b453 Mon Sep 17 00:00:00 2001 From: aozarov Date: Wed, 13 May 2015 19:02:22 -0700 Subject: [PATCH 1/6] acl test --- .../java/com/google/gcloud/storage/Acl.java | 40 ++++++++ .../com/google/gcloud/storage/AclTest.java | 94 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/test/java/com/google/gcloud/storage/AclTest.java diff --git a/src/main/java/com/google/gcloud/storage/Acl.java b/src/main/java/com/google/gcloud/storage/Acl.java index 138ba4f3fa3a..7e78bd7981d6 100644 --- a/src/main/java/com/google/gcloud/storage/Acl.java +++ b/src/main/java/com/google/gcloud/storage/Acl.java @@ -20,6 +20,7 @@ import com.google.api.services.storage.model.ObjectAccessControl; import java.io.Serializable; +import java.util.Objects; /** * Access Control List on for buckets or blobs. @@ -59,6 +60,24 @@ protected String value() { return value; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Entity entity = (Entity) o; + return Objects.equals(type, entity.type) && + Objects.equals(value, entity.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + @Override public String toString() { return toPb(); @@ -81,6 +100,9 @@ static Entity fromPb(String entity) { if (entity.startsWith("group-")) { return new Group(entity.substring(6)); } + if (entity.startsWith("domain-")) { + return new Domain(entity.substring(7)); + } if (entity.startsWith("project-")) { int idx = entity.indexOf('-', 8); String team = entity.substring(8, idx); @@ -207,6 +229,24 @@ public Role role() { return role; } + @Override + public int hashCode() { + return Objects.hash(entity, role); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final Acl other = (Acl) obj; + return Objects.equals(this.entity, other.entity) + && Objects.equals(this.role, other.role); + } + BucketAccessControl toBucketPb() { BucketAccessControl bucketPb = new BucketAccessControl(); bucketPb.setRole(role().toString()); diff --git a/src/test/java/com/google/gcloud/storage/AclTest.java b/src/test/java/com/google/gcloud/storage/AclTest.java new file mode 100644 index 000000000000..6a11fb0b2810 --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/AclTest.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import static org.junit.Assert.assertEquals; + +import com.google.api.services.storage.model.BucketAccessControl; +import com.google.api.services.storage.model.ObjectAccessControl; +import com.google.gcloud.storage.Acl.Domain; +import com.google.gcloud.storage.Acl.Entity; +import com.google.gcloud.storage.Acl.Entity.Type; +import com.google.gcloud.storage.Acl.Group; +import com.google.gcloud.storage.Acl.Project; +import com.google.gcloud.storage.Acl.Project.ProjectRole; +import com.google.gcloud.storage.Acl.RawEntity; +import com.google.gcloud.storage.Acl.Role; +import com.google.gcloud.storage.Acl.User; + +import org.junit.Test; + +public class AclTest { + + @Test + public void testDomainEntity() { + Domain acl = new Domain("d1"); + assertEquals("d1", acl.domain()); + assertEquals(Type.DOMAIN, acl.type()); + String pb = acl.toPb(); + assertEquals(acl, Entity.fromPb(pb)); + } + + @Test + public void testGroupEntity() { + Group acl = new Group("g1"); + assertEquals("g1", acl.email()); + assertEquals(Type.GROUP, acl.type()); + String pb = acl.toPb(); + assertEquals(acl, Entity.fromPb(pb)); + } + + @Test + public void testUserEntity() { + User acl = new User("u1"); + assertEquals("u1", acl.email()); + assertEquals(Type.USER, acl.type()); + String pb = acl.toPb(); + assertEquals(acl, Entity.fromPb(pb)); + } + + @Test + public void testProjectEntity() { + Project acl = new Project(ProjectRole.VIEWERS, "p1"); + assertEquals(ProjectRole.VIEWERS, acl.projectRole()); + assertEquals("p1", acl.projectId()); + assertEquals(Type.PROJECT, acl.type()); + String pb = acl.toPb(); + assertEquals(acl, Entity.fromPb(pb)); + } + + @Test + public void testRawEntity() { + Entity acl = new RawEntity("bla"); + assertEquals("bla", acl.value()); + assertEquals(Type.UNKNOWN, acl.type()); + String pb = acl.toPb(); + assertEquals(acl, Entity.fromPb(pb)); + } + + + @Test + public void testAcl() { + Acl acl = new Acl(User.ofAllUsers(), Role.READER); + assertEquals(User.ofAllUsers(), acl.entity()); + assertEquals(Role.READER, acl.role()); + ObjectAccessControl objectPb = acl.toObjectPb(); + assertEquals(acl, Acl.fromPb(objectPb)); + BucketAccessControl bucketPb = acl.toBucketPb(); + assertEquals(acl, Acl.fromPb(bucketPb)); + } +} From faab59d5f1a428c9c41547d71e668ef6cd53cb36 Mon Sep 17 00:00:00 2001 From: aozarov Date: Thu, 14 May 2015 10:08:43 -0700 Subject: [PATCH 2/6] adding BatchRequestTest --- .../gcloud/storage/BatchRequestTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/test/java/com/google/gcloud/storage/BatchRequestTest.java diff --git a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java new file mode 100644 index 000000000000..d459ba73a0af --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java @@ -0,0 +1,48 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import com.google.gcloud.storage.BatchRequest.Builder; +import com.google.gcloud.storage.StorageService.BlobSourceOption; + +import org.junit.Test; + +public class BatchRequestTest { + + @Test + public void testRequest() throws Exception { + Builder builder = BatchRequest.builder(); + builder.delete("b1", "o1") + BatchRequest.builder().delete("b1", "o1", + BlobSourceOption.generationMatch(), BlobSourceOption.metagenerationMatch()); + } + + @Test + public void testToUpdate() throws Exception { + + } + + @Test + public void testToGet() throws Exception { + + } + + @Test + public void testBuilder() throws Exception { + + } +} From b941c0809ccd5eba269a1d2fa8090233c5cdfdbd Mon Sep 17 00:00:00 2001 From: aozarov Date: Thu, 14 May 2015 17:33:08 -0700 Subject: [PATCH 3/6] work in progress --- .../gcloud/storage/BatchRequestTest.java | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java index d459ba73a0af..56c1f72dd84d 100644 --- a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java +++ b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java @@ -16,33 +16,54 @@ package com.google.gcloud.storage; -import com.google.gcloud.storage.BatchRequest.Builder; +import static com.google.gcloud.storage.StorageService.PredefinedAcl.PUBLIC_READ; +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.Iterables; import com.google.gcloud.storage.StorageService.BlobSourceOption; +import com.google.gcloud.storage.StorageService.BlobTargetOption; import org.junit.Test; +import java.util.Iterator; +import java.util.Map.Entry; + public class BatchRequestTest { @Test public void testRequest() throws Exception { - Builder builder = BatchRequest.builder(); - builder.delete("b1", "o1") - BatchRequest.builder().delete("b1", "o1", - BlobSourceOption.generationMatch(), BlobSourceOption.metagenerationMatch()); - } + BatchRequest request = BatchRequest.builder() + .delete("b1", "o1") + .delete("b1", "o2", BlobSourceOption.generationMatch(1), + BlobSourceOption.metagenerationMatch(2)) + .update(Blob.of("b2", "o1"), BlobTargetOption.predefinedAcl(PUBLIC_READ)) + .update(Blob.of("b2", "o2")) + .get("b3", "o1") + .get("b3", "o2", BlobSourceOption.generationMatch(1)) + .get("b3", "o3") + .build(); - @Test - public void testToUpdate() throws Exception { - - } + Iterator>> deletes = request + .toDelete().entrySet().iterator(); + Entry> delete = deletes.next(); + assertEquals(Blob.of("b1", "o1"), delete.getKey()); + assertTrue(Iterables.isEmpty(delete.getValue())); + delete = deletes.next(); + assertEquals(Blob.of("b1", "o2"), delete.getKey()); + assertEquals(2, Iterables.size(delete.getValue())); + assertFalse(deletes.hasNext()); - @Test - public void testToGet() throws Exception { - - } - - @Test - public void testBuilder() throws Exception { + Iterator>> updates = request + .toDelete().entrySet().iterator(); + Entry> update = updates.next(); + assertEquals(Blob.of("b1", "o1"), update.getKey()); + assertTrue(Iterables.isEmpty(update.getValue())); + update = updates.next(); + assertEquals(Blob.of("b1", "o2"), update.getKey()); + assertEquals(2, Iterables.size(update.getValue())); + assertFalse(updates.hasNext()); } } From ed351d47806f3a730e821cc58e3905adb1670397 Mon Sep 17 00:00:00 2001 From: ozarov Date: Thu, 14 May 2015 20:30:19 -0700 Subject: [PATCH 4/6] basic tests --- .../google/gcloud/storage/BatchResponse.java | 4 ++ .../com/google/gcloud/storage/ListResult.java | 4 +- .../gcloud/storage/StorageServiceImpl.java | 4 +- .../gcloud/storage/BatchRequestTest.java | 32 ++++++++--- .../gcloud/storage/BatchResponseTest.java | 45 +++++++++++++++ .../com/google/gcloud/storage/CorsTest.java | 55 +++++++++++++++++++ .../google/gcloud/storage/ListResultTest.java | 34 ++++++++++++ .../com/google/gcloud/storage/OptionTest.java | 38 +++++++++++++ .../gcloud/storage/SerializationTest.java | 2 +- 9 files changed, 206 insertions(+), 12 deletions(-) create mode 100644 src/test/java/com/google/gcloud/storage/BatchResponseTest.java create mode 100644 src/test/java/com/google/gcloud/storage/CorsTest.java create mode 100644 src/test/java/com/google/gcloud/storage/ListResultTest.java create mode 100644 src/test/java/com/google/gcloud/storage/OptionTest.java diff --git a/src/main/java/com/google/gcloud/storage/BatchResponse.java b/src/main/java/com/google/gcloud/storage/BatchResponse.java index f0675e348f72..03e02ff01d3a 100644 --- a/src/main/java/com/google/gcloud/storage/BatchResponse.java +++ b/src/main/java/com/google/gcloud/storage/BatchResponse.java @@ -53,6 +53,10 @@ public static class Result implements Serializable { this.value = null; } + static Result of(T value) { + return new Result<>(value); + } + /** * Returns the result. * diff --git a/src/main/java/com/google/gcloud/storage/ListResult.java b/src/main/java/com/google/gcloud/storage/ListResult.java index dd843020376e..de7349328b9a 100644 --- a/src/main/java/com/google/gcloud/storage/ListResult.java +++ b/src/main/java/com/google/gcloud/storage/ListResult.java @@ -16,7 +16,9 @@ package com.google.gcloud.storage; + import java.io.Serializable; +import java.util.Collections; import java.util.Iterator; import java.util.Objects; @@ -41,7 +43,7 @@ public String nextPageCursor() { @Override public Iterator iterator() { - return results.iterator(); + return results == null ? Collections.emptyIterator() : results.iterator(); } @Override diff --git a/src/main/java/com/google/gcloud/storage/StorageServiceImpl.java b/src/main/java/com/google/gcloud/storage/StorageServiceImpl.java index 1f66401105d0..4507146a50f0 100644 --- a/src/main/java/com/google/gcloud/storage/StorageServiceImpl.java +++ b/src/main/java/com/google/gcloud/storage/StorageServiceImpl.java @@ -345,14 +345,14 @@ private List> transformBatch for (Tuple tuple : request) { Tuple result = results.get(tuple.x()); if (result.x() != null) { - response.add(new BatchResponse.Result<>(transform.apply(result.x()))); + response.add(BatchResponse.Result.of(transform.apply(result.x()))); } else { StorageServiceException exception = result.y(); if (nullOnErrorCodesSet.contains(exception.code())) { //noinspection unchecked response.add(BatchResponse.Result.empty()); } else { - response.add(new BatchResponse.Result(result.y())); + response.add(new BatchResponse.Result(exception)); } } } diff --git a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java index 56c1f72dd84d..445e65dc6c35 100644 --- a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java +++ b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java @@ -33,7 +33,7 @@ public class BatchRequestTest { @Test - public void testRequest() throws Exception { + public void testBatchRequest() { BatchRequest request = BatchRequest.builder() .delete("b1", "o1") .delete("b1", "o2", BlobSourceOption.generationMatch(1), @@ -55,15 +55,31 @@ public void testRequest() throws Exception { assertEquals(2, Iterables.size(delete.getValue())); assertFalse(deletes.hasNext()); - Iterator>> updates = request - .toDelete().entrySet().iterator(); - Entry> update = updates.next(); - assertEquals(Blob.of("b1", "o1"), update.getKey()); - assertTrue(Iterables.isEmpty(update.getValue())); + Iterator>> updates = request + .toUpdate().entrySet().iterator(); + Entry> update = updates.next(); + assertEquals(Blob.of("b2", "o1"), update.getKey()); + assertEquals(1, Iterables.size(update.getValue())); + assertEquals(BlobTargetOption.predefinedAcl(PUBLIC_READ), + Iterables.getFirst(update.getValue(), null)); update = updates.next(); - assertEquals(Blob.of("b1", "o2"), update.getKey()); - assertEquals(2, Iterables.size(update.getValue())); + assertEquals(Blob.of("b2", "o2"), update.getKey()); + assertTrue(Iterables.isEmpty(update.getValue())); assertFalse(updates.hasNext()); + Iterator>> gets = request + .toGet().entrySet().iterator(); + Entry> get = gets.next(); + assertEquals(Blob.of("b3", "o1"), get.getKey()); + assertTrue(Iterables.isEmpty(get.getValue())); + get = gets.next(); + assertEquals(Blob.of("b3", "o2"), get.getKey()); + assertEquals(1, Iterables.size(get.getValue())); + assertEquals(BlobSourceOption.generationMatch(1), + Iterables.getFirst(get.getValue(), null)); + get = gets.next(); + assertEquals(Blob.of("b3", "o3"), get.getKey()); + assertTrue(Iterables.isEmpty(get.getValue())); + assertFalse(gets.hasNext()); } } diff --git a/src/test/java/com/google/gcloud/storage/BatchResponseTest.java b/src/test/java/com/google/gcloud/storage/BatchResponseTest.java new file mode 100644 index 000000000000..8e6e850fca61 --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/BatchResponseTest.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import static junit.framework.TestCase.assertEquals; + +import com.google.common.collect.ImmutableList; +import com.google.gcloud.storage.BatchResponse.Result; + +import org.junit.Test; + +import java.util.List; + +public class BatchResponseTest { + + private static final Blob BLOB1 = Blob.of("b", "o1"); + private static final Blob BLOB2 = Blob.of("b", "o2"); + private static final Blob BLOB3 = Blob.of("b", "o3"); + + @Test + public void testBatchResponse() { + List> deletes = ImmutableList.of(Result.of(true), Result.of(false)); + List> updates = ImmutableList.of(Result.of(BLOB1), Result.of(BLOB2)); + List> gets = ImmutableList.of(Result.of(BLOB2), Result.of(BLOB3)); + BatchResponse response = new BatchResponse(deletes, updates, gets); + + assertEquals(deletes, response.deletes()); + assertEquals(updates, response.updates()); + assertEquals(gets, response.gets()); + } +} diff --git a/src/test/java/com/google/gcloud/storage/CorsTest.java b/src/test/java/com/google/gcloud/storage/CorsTest.java new file mode 100644 index 000000000000..fcb343cd56f6 --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/CorsTest.java @@ -0,0 +1,55 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import static junit.framework.TestCase.assertEquals; + +import com.google.common.collect.ImmutableList; +import com.google.gcloud.storage.Cors.Method; +import com.google.gcloud.storage.Cors.Origin; + +import org.junit.Test; + +import java.util.List; + +public class CorsTest { + + @Test + public void testOrigin() { + assertEquals("bla", Origin.of("bla").value()); + assertEquals("http://host:8080", Origin.of("http", "host", 8080).toString()); + assertEquals(Origin.of("*"), Origin.any()); + } + + @Test + public void corsTest() { + List origins = ImmutableList.of(Origin.any(), Origin.of("o")); + List headers = ImmutableList.of("h1", "h2"); + List methods = ImmutableList.of(Method.ANY); + Cors cors = Cors.builder() + .maxAgeSeconds(100) + .origins(origins) + .responseHeaders(headers) + .methods(methods) + .build(); + + assertEquals(Integer.valueOf(100), cors.maxAgeSeconds()); + assertEquals(origins, cors.origins()); + assertEquals(methods, cors.methods()); + assertEquals(headers, cors.responseHeaders()); + } +} diff --git a/src/test/java/com/google/gcloud/storage/ListResultTest.java b/src/test/java/com/google/gcloud/storage/ListResultTest.java new file mode 100644 index 000000000000..3295e86d01ec --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/ListResultTest.java @@ -0,0 +1,34 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import static junit.framework.TestCase.assertEquals; + +import com.google.common.collect.ImmutableList; + +import org.junit.Test; + +public class ListResultTest { + + @Test + public void testListResult() throws Exception { + ImmutableList values = ImmutableList.of("1", "2"); + ListResult result = new ListResult("c", values); + assertEquals("c", result.nextPageCursor()); + assertEquals(values, ImmutableList.copyOf(result.iterator())); + } +} diff --git a/src/test/java/com/google/gcloud/storage/OptionTest.java b/src/test/java/com/google/gcloud/storage/OptionTest.java new file mode 100644 index 000000000000..b900ce2fc293 --- /dev/null +++ b/src/test/java/com/google/gcloud/storage/OptionTest.java @@ -0,0 +1,38 @@ +/* + * 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. + */ + +package com.google.gcloud.storage; + +import static junit.framework.TestCase.assertEquals; + +import com.google.gcloud.spi.StorageRpc; + +import org.junit.Test; + +public class OptionTest { + + @Test + public void testOption() { + Option option = new Option(StorageRpc.Option.DELIMITER, "/"); + assertEquals(StorageRpc.Option.DELIMITER, option.rpcOption()); + assertEquals("/", option.value()); + } + + @Test(expected=NullPointerException.class) + public void testIndexOutOfBoundsException() { + new Option(null, "/"); + } +} diff --git a/src/test/java/com/google/gcloud/storage/SerializationTest.java b/src/test/java/com/google/gcloud/storage/SerializationTest.java index 365462d3f69a..97119698c1cf 100644 --- a/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -47,7 +47,7 @@ public class SerializationTest { Cors.builder().maxAgeSeconds(1).origins(Collections.singleton(ORIGIN)).build(); private static final BatchRequest BATCH_REQUEST = BatchRequest.builder().delete("B", "N").build(); private static final BatchResponse BATCH_RESPONSE = new BatchResponse( - Collections.singletonList(new BatchResponse.Result<>(true)), + Collections.singletonList(BatchResponse.Result.of(true)), Collections.>emptyList(), Collections.>emptyList()); private static final ListResult LIST_RESULT = From ccd84c30ee9370261b81c25a84347198e2c4312b Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 15 May 2015 09:46:28 -0700 Subject: [PATCH 5/6] make Project constructor public --- src/main/java/com/google/gcloud/storage/Acl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/gcloud/storage/Acl.java b/src/main/java/com/google/gcloud/storage/Acl.java index e2246bd29d75..d77bb1eaef02 100644 --- a/src/main/java/com/google/gcloud/storage/Acl.java +++ b/src/main/java/com/google/gcloud/storage/Acl.java @@ -186,7 +186,7 @@ enum ProjectRole { OWNERS, EDITORS, VIEWERS } - Project(ProjectRole pRole, String projectId) { + public Project(ProjectRole pRole, String projectId) { super(Type.PROJECT, pRole.name().toLowerCase() + "-" + projectId); this.pRole = pRole; this.projectId = projectId; From 28c9010c8b60e62577fa2dccb9153e200b7dffcb Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 15 May 2015 14:29:34 -0700 Subject: [PATCH 6/6] s/junit.framework.TestCase/org.junit.Assert/g --- .../google/gcloud/datastore/BaseEntityTest.java | 2 +- .../google/gcloud/datastore/BlobValueTest.java | 2 +- .../google/gcloud/datastore/BooleanValueTest.java | 2 +- .../gcloud/datastore/DatastoreHelperTest.java | 15 +++++++++++---- .../datastore/DatastoreServiceExceptionTest.java | 2 +- .../datastore/DatastoreServiceOptionsTest.java | 8 ++++---- .../gcloud/datastore/DatastoreServiceTest.java | 2 +- .../gcloud/datastore/DateTimeValueTest.java | 2 +- .../google/gcloud/datastore/DoubleValueTest.java | 2 +- .../google/gcloud/datastore/EntityValueTest.java | 2 +- .../google/gcloud/datastore/KeyFactoryTest.java | 4 ++-- .../com/google/gcloud/datastore/KeyValueTest.java | 2 +- .../google/gcloud/datastore/ListValueTest.java | 2 +- .../google/gcloud/datastore/LongValueTest.java | 2 +- .../google/gcloud/datastore/NullValueTest.java | 2 +- .../gcloud/datastore/ProjectionEntityTest.java | 6 +++--- .../com/google/gcloud/datastore/RawValueTest.java | 2 +- .../google/gcloud/datastore/StringValueTest.java | 2 +- .../com/google/gcloud/datastore/ValueTest.java | 4 ++-- .../google/gcloud/storage/BatchRequestTest.java | 2 +- .../google/gcloud/storage/BatchResponseTest.java | 2 +- .../java/com/google/gcloud/storage/CorsTest.java | 2 +- .../com/google/gcloud/storage/ListResultTest.java | 2 +- .../com/google/gcloud/storage/OptionTest.java | 2 +- 24 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java b/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java index 8a2ffb26d68e..567e795a66e7 100644 --- a/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java +++ b/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java @@ -1 +1 @@ -/* * 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. */ package com.google.gcloud.datastore; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.junit.Before; import org.junit.Test; import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Set; public class BaseEntityTest { private static final Blob BLOB = Blob.copyFrom(new byte[]{1, 2}); private static final DateTime DATE_TIME = DateTime.now(); private static final Key KEY = Key.builder("ds1", "k1", "n1").build(); private static final Entity ENTITY = Entity.builder(KEY).set("name", "foo").build(); private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.builder("ds1", "k1").build(); private static final FullEntity PARTIAL_ENTITY = Entity.builder(INCOMPLETE_KEY).build(); private Builder builder; private class Builder extends BaseEntity.Builder { @Override public BaseEntity build() { return new BaseEntity(this) { @Override protected Builder emptyBuilder() { return new BaseEntityTest.Builder(); } }; } } @Before public void setUp() { builder = new Builder(); builder.set("blob", BLOB).set("boolean", true).set("dateTime", DATE_TIME); builder.set("double", 1.25).set("key", KEY).set("string", "hello world"); builder.set("long", 125).setNull("null").set("entity", ENTITY); builder.set("partialEntity", PARTIAL_ENTITY).set("stringValue", StringValue.of("bla")); builder.set("list1", NullValue.of(), StringValue.of("foo")); builder.set("list2", ImmutableList.of(LongValue.of(10), DoubleValue.of(2))); builder.set("list3", Collections.singletonList(BooleanValue.of(true))); } @Test public void testContains() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.contains("list1")); assertFalse(entity.contains("bla")); entity = builder.clear().build(); assertFalse(entity.contains("list1")); } @Test public void testGetValue() throws Exception { BaseEntity entity = builder.build(); assertEquals(BlobValue.of(BLOB), entity.getValue("blob")); } @Test(expected = DatastoreServiceException.class) public void testGetValueNotFound() throws Exception { BaseEntity entity = builder.clear().build(); entity.getValue("blob"); } @Test public void testIsNull() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.isNull("null")); assertFalse(entity.isNull("blob")); entity = builder.setNull("blob").build(); assertTrue(entity.isNull("blob")); } @Test(expected = DatastoreServiceException.class) public void testIsNullNotFound() throws Exception { BaseEntity entity = builder.clear().build(); entity.isNull("null"); } @Test public void testGetString() throws Exception { BaseEntity entity = builder.build(); assertEquals("hello world", entity.getString("string")); assertEquals("bla", entity.getString("stringValue")); entity = builder.set("string", "foo").build(); assertEquals("foo", entity.getString("string")); } @Test public void testGetLong() throws Exception { BaseEntity entity = builder.build(); assertEquals(125, entity.getLong("long")); entity = builder.set("long", LongValue.of(10)).build(); assertEquals(10, entity.getLong("long")); } @Test public void testGetDouble() throws Exception { BaseEntity entity = builder.build(); assertEquals(1.25, entity.getDouble("double"), 0); entity = builder.set("double", DoubleValue.of(10)).build(); assertEquals(10, entity.getDouble("double"), 0); } @Test public void testGetBoolean() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.getBoolean("boolean")); entity = builder.set("boolean", BooleanValue.of(false)).build(); assertFalse(entity.getBoolean("boolean")); } @Test public void testGetDateTime() throws Exception { BaseEntity entity = builder.build(); assertEquals(DATE_TIME, entity.getDateTime("dateTime")); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); DateTime dateTime = DateTime.copyFrom(cal); entity = builder.set("dateTime", DateTimeValue.of(dateTime)).build(); assertEquals(dateTime, entity.getDateTime("dateTime")); } @Test public void testGetKey() throws Exception { BaseEntity entity = builder.build(); assertEquals(KEY, entity.getKey("key")); Key key = Key.builder(KEY).name("BLA").build(); entity = builder.set("key", key).build(); assertEquals(key, entity.getKey("key")); } @Test public void testGetEntity() throws Exception { BaseEntity entity = builder.build(); assertEquals(ENTITY, entity.getEntity("entity")); assertEquals(PARTIAL_ENTITY, entity.getEntity("partialEntity")); entity = builder.set("entity", EntityValue.of(PARTIAL_ENTITY)).build(); assertEquals(PARTIAL_ENTITY, entity.getEntity("entity")); } @Test public void testGetList() throws Exception { BaseEntity entity = builder.build(); List> list = entity.getList("list1"); assertEquals(2, list.size()); assertEquals(NullValue.of(), list.get(0)); assertEquals("foo", list.get(1).get()); list = entity.getList("list2"); assertEquals(2, list.size()); assertEquals(Long.valueOf(10), list.get(0).get()); assertEquals(Double.valueOf(2), list.get(1).get()); list = entity.getList("list3"); assertEquals(1, list.size()); assertEquals(Boolean.TRUE, list.get(0).get()); entity = builder.set("list1", ListValue.of(list)).build(); assertEquals(list, entity.getList("list1")); } @Test public void testGetBlob() throws Exception { BaseEntity entity = builder.build(); assertEquals(BLOB, entity.getBlob("blob")); Blob blob = Blob.copyFrom(new byte[] {}); entity = builder.set("blob", BlobValue.of(blob)).build(); assertEquals(blob, entity.getBlob("blob")); } @Test public void testNames() throws Exception { Set names = ImmutableSet.builder() .add("string", "stringValue", "boolean", "double", "long", "list1", "list2", "list3") .add("entity", "partialEntity", "null", "dateTime", "blob", "key") .build(); BaseEntity entity = builder.build(); assertEquals(names, entity.names()); } } \ No newline at end of file +/* * 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. */ package com.google.gcloud.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.junit.Before; import org.junit.Test; import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Set; public class BaseEntityTest { private static final Blob BLOB = Blob.copyFrom(new byte[]{1, 2}); private static final DateTime DATE_TIME = DateTime.now(); private static final Key KEY = Key.builder("ds1", "k1", "n1").build(); private static final Entity ENTITY = Entity.builder(KEY).set("name", "foo").build(); private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.builder("ds1", "k1").build(); private static final FullEntity PARTIAL_ENTITY = Entity.builder(INCOMPLETE_KEY).build(); private Builder builder; private class Builder extends BaseEntity.Builder { @Override public BaseEntity build() { return new BaseEntity(this) { @Override protected Builder emptyBuilder() { return new BaseEntityTest.Builder(); } }; } } @Before public void setUp() { builder = new Builder(); builder.set("blob", BLOB).set("boolean", true).set("dateTime", DATE_TIME); builder.set("double", 1.25).set("key", KEY).set("string", "hello world"); builder.set("long", 125).setNull("null").set("entity", ENTITY); builder.set("partialEntity", PARTIAL_ENTITY).set("stringValue", StringValue.of("bla")); builder.set("list1", NullValue.of(), StringValue.of("foo")); builder.set("list2", ImmutableList.of(LongValue.of(10), DoubleValue.of(2))); builder.set("list3", Collections.singletonList(BooleanValue.of(true))); } @Test public void testContains() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.contains("list1")); assertFalse(entity.contains("bla")); entity = builder.clear().build(); assertFalse(entity.contains("list1")); } @Test public void testGetValue() throws Exception { BaseEntity entity = builder.build(); assertEquals(BlobValue.of(BLOB), entity.getValue("blob")); } @Test(expected = DatastoreServiceException.class) public void testGetValueNotFound() throws Exception { BaseEntity entity = builder.clear().build(); entity.getValue("blob"); } @Test public void testIsNull() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.isNull("null")); assertFalse(entity.isNull("blob")); entity = builder.setNull("blob").build(); assertTrue(entity.isNull("blob")); } @Test(expected = DatastoreServiceException.class) public void testIsNullNotFound() throws Exception { BaseEntity entity = builder.clear().build(); entity.isNull("null"); } @Test public void testGetString() throws Exception { BaseEntity entity = builder.build(); assertEquals("hello world", entity.getString("string")); assertEquals("bla", entity.getString("stringValue")); entity = builder.set("string", "foo").build(); assertEquals("foo", entity.getString("string")); } @Test public void testGetLong() throws Exception { BaseEntity entity = builder.build(); assertEquals(125, entity.getLong("long")); entity = builder.set("long", LongValue.of(10)).build(); assertEquals(10, entity.getLong("long")); } @Test public void testGetDouble() throws Exception { BaseEntity entity = builder.build(); assertEquals(1.25, entity.getDouble("double"), 0); entity = builder.set("double", DoubleValue.of(10)).build(); assertEquals(10, entity.getDouble("double"), 0); } @Test public void testGetBoolean() throws Exception { BaseEntity entity = builder.build(); assertTrue(entity.getBoolean("boolean")); entity = builder.set("boolean", BooleanValue.of(false)).build(); assertFalse(entity.getBoolean("boolean")); } @Test public void testGetDateTime() throws Exception { BaseEntity entity = builder.build(); assertEquals(DATE_TIME, entity.getDateTime("dateTime")); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); DateTime dateTime = DateTime.copyFrom(cal); entity = builder.set("dateTime", DateTimeValue.of(dateTime)).build(); assertEquals(dateTime, entity.getDateTime("dateTime")); } @Test public void testGetKey() throws Exception { BaseEntity entity = builder.build(); assertEquals(KEY, entity.getKey("key")); Key key = Key.builder(KEY).name("BLA").build(); entity = builder.set("key", key).build(); assertEquals(key, entity.getKey("key")); } @Test public void testGetEntity() throws Exception { BaseEntity entity = builder.build(); assertEquals(ENTITY, entity.getEntity("entity")); assertEquals(PARTIAL_ENTITY, entity.getEntity("partialEntity")); entity = builder.set("entity", EntityValue.of(PARTIAL_ENTITY)).build(); assertEquals(PARTIAL_ENTITY, entity.getEntity("entity")); } @Test public void testGetList() throws Exception { BaseEntity entity = builder.build(); List> list = entity.getList("list1"); assertEquals(2, list.size()); assertEquals(NullValue.of(), list.get(0)); assertEquals("foo", list.get(1).get()); list = entity.getList("list2"); assertEquals(2, list.size()); assertEquals(Long.valueOf(10), list.get(0).get()); assertEquals(Double.valueOf(2), list.get(1).get()); list = entity.getList("list3"); assertEquals(1, list.size()); assertEquals(Boolean.TRUE, list.get(0).get()); entity = builder.set("list1", ListValue.of(list)).build(); assertEquals(list, entity.getList("list1")); } @Test public void testGetBlob() throws Exception { BaseEntity entity = builder.build(); assertEquals(BLOB, entity.getBlob("blob")); Blob blob = Blob.copyFrom(new byte[] {}); entity = builder.set("blob", BlobValue.of(blob)).build(); assertEquals(blob, entity.getBlob("blob")); } @Test public void testNames() throws Exception { Set names = ImmutableSet.builder() .add("string", "stringValue", "boolean", "double", "long", "list1", "list2", "list3") .add("entity", "partialEntity", "null", "dateTime", "blob", "key") .build(); BaseEntity entity = builder.build(); assertEquals(names, entity.names()); } } \ No newline at end of file diff --git a/src/test/java/com/google/gcloud/datastore/BlobValueTest.java b/src/test/java/com/google/gcloud/datastore/BlobValueTest.java index 56ef03ac278e..40d0299d8fb3 100644 --- a/src/test/java/com/google/gcloud/datastore/BlobValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/BlobValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/BooleanValueTest.java b/src/test/java/com/google/gcloud/datastore/BooleanValueTest.java index fb3e62e6e27d..16bbe9cbf518 100644 --- a/src/test/java/com/google/gcloud/datastore/BooleanValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/BooleanValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/DatastoreHelperTest.java b/src/test/java/com/google/gcloud/datastore/DatastoreHelperTest.java index 25c0e8b2e691..8a31ece583ff 100644 --- a/src/test/java/com/google/gcloud/datastore/DatastoreHelperTest.java +++ b/src/test/java/com/google/gcloud/datastore/DatastoreHelperTest.java @@ -16,13 +16,20 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertTrue; -import static junit.framework.TestCase.fail; -import static org.easymock.EasyMock.*; -import static org.junit.Assert.*; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import com.google.common.collect.Iterators; import com.google.gcloud.datastore.DatastoreService.TransactionCallable; + import org.easymock.EasyMock; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/DatastoreServiceExceptionTest.java b/src/test/java/com/google/gcloud/datastore/DatastoreServiceExceptionTest.java index 2700d277b9a3..1a06de833cf2 100644 --- a/src/test/java/com/google/gcloud/datastore/DatastoreServiceExceptionTest.java +++ b/src/test/java/com/google/gcloud/datastore/DatastoreServiceExceptionTest.java @@ -1 +1 @@ -/* * 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. */ package com.google.gcloud.datastore; import static junit.framework.TestCase.fail; import static org.junit.Assert.assertEquals; import com.google.gcloud.spi.DatastoreRpc.DatastoreRpcException; import com.google.gcloud.spi.DatastoreRpc.DatastoreRpcException.Reason; import com.google.gcloud.datastore.DatastoreServiceException.Code; import org.junit.Test; public class DatastoreServiceExceptionTest { @Test public void testCode() throws Exception { for (Reason reason : Reason.values()) { Code code = Code.valueOf(reason.name()); assertEquals(reason.retryable(), code.retryable()); assertEquals(reason.description(), code.description()); assertEquals(reason.httpStatus(), code.httpStatus()); } DatastoreServiceException exception = new DatastoreServiceException(Code.ABORTED, "bla"); assertEquals(Code.ABORTED, exception.code()); } @Test public void testTranslateAndThrow() throws Exception { for (Reason reason : Reason.values()) { try { DatastoreServiceException.translateAndThrow(new DatastoreRpcException(reason)); fail("Exception expected"); } catch (DatastoreServiceException ex) { assertEquals(reason.name(), ex.code().name()); } } } @Test public void testThrowInvalidRequest() throws Exception { try { DatastoreServiceException.throwInvalidRequest("message %s %d", "a", 1); fail("Exception expected"); } catch (DatastoreServiceException ex) { assertEquals(Code.FAILED_PRECONDITION, ex.code()); assertEquals("message a 1", ex.getMessage()); } } } \ No newline at end of file +/* * 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. */ package com.google.gcloud.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import com.google.gcloud.datastore.DatastoreServiceException.Code; import com.google.gcloud.spi.DatastoreRpc.DatastoreRpcException; import com.google.gcloud.spi.DatastoreRpc.DatastoreRpcException.Reason; import org.junit.Test; public class DatastoreServiceExceptionTest { @Test public void testCode() throws Exception { for (Reason reason : Reason.values()) { Code code = Code.valueOf(reason.name()); assertEquals(reason.retryable(), code.retryable()); assertEquals(reason.description(), code.description()); assertEquals(reason.httpStatus(), code.httpStatus()); } DatastoreServiceException exception = new DatastoreServiceException(Code.ABORTED, "bla"); assertEquals(Code.ABORTED, exception.code()); } @Test public void testTranslateAndThrow() throws Exception { for (Reason reason : Reason.values()) { try { DatastoreServiceException.translateAndThrow(new DatastoreRpcException(reason)); fail("Exception expected"); } catch (DatastoreServiceException ex) { assertEquals(reason.name(), ex.code().name()); } } } @Test public void testThrowInvalidRequest() throws Exception { try { DatastoreServiceException.throwInvalidRequest("message %s %d", "a", 1); fail("Exception expected"); } catch (DatastoreServiceException ex) { assertEquals(Code.FAILED_PRECONDITION, ex.code()); assertEquals("message a 1", ex.getMessage()); } } } \ No newline at end of file diff --git a/src/test/java/com/google/gcloud/datastore/DatastoreServiceOptionsTest.java b/src/test/java/com/google/gcloud/datastore/DatastoreServiceOptionsTest.java index a533f4ddc15e..59468be58129 100644 --- a/src/test/java/com/google/gcloud/datastore/DatastoreServiceOptionsTest.java +++ b/src/test/java/com/google/gcloud/datastore/DatastoreServiceOptionsTest.java @@ -16,10 +16,10 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertNull; -import static junit.framework.TestCase.assertSame; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import com.google.gcloud.spi.DatastoreRpc; diff --git a/src/test/java/com/google/gcloud/datastore/DatastoreServiceTest.java b/src/test/java/com/google/gcloud/datastore/DatastoreServiceTest.java index 0423cfe2d494..535fcb5f13e1 100644 --- a/src/test/java/com/google/gcloud/datastore/DatastoreServiceTest.java +++ b/src/test/java/com/google/gcloud/datastore/DatastoreServiceTest.java @@ -16,10 +16,10 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertNotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/com/google/gcloud/datastore/DateTimeValueTest.java b/src/test/java/com/google/gcloud/datastore/DateTimeValueTest.java index 39e0d1ca3f01..d7fef2ca69b9 100644 --- a/src/test/java/com/google/gcloud/datastore/DateTimeValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/DateTimeValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/DoubleValueTest.java b/src/test/java/com/google/gcloud/datastore/DoubleValueTest.java index 012f9bbf4de9..fa39511a45de 100644 --- a/src/test/java/com/google/gcloud/datastore/DoubleValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/DoubleValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/EntityValueTest.java b/src/test/java/com/google/gcloud/datastore/EntityValueTest.java index dfacfb0b67a6..cd1f7af38067 100644 --- a/src/test/java/com/google/gcloud/datastore/EntityValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/EntityValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/KeyFactoryTest.java b/src/test/java/com/google/gcloud/datastore/KeyFactoryTest.java index ca9ea08294f4..92851bd87efe 100644 --- a/src/test/java/com/google/gcloud/datastore/KeyFactoryTest.java +++ b/src/test/java/com/google/gcloud/datastore/KeyFactoryTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Before; diff --git a/src/test/java/com/google/gcloud/datastore/KeyValueTest.java b/src/test/java/com/google/gcloud/datastore/KeyValueTest.java index ea6b77ed97da..131a80462a62 100644 --- a/src/test/java/com/google/gcloud/datastore/KeyValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/KeyValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/ListValueTest.java b/src/test/java/com/google/gcloud/datastore/ListValueTest.java index ae07f0c4fa51..04fdbec54727 100644 --- a/src/test/java/com/google/gcloud/datastore/ListValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/ListValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; diff --git a/src/test/java/com/google/gcloud/datastore/LongValueTest.java b/src/test/java/com/google/gcloud/datastore/LongValueTest.java index d93dfaf331a8..c4c899785d68 100644 --- a/src/test/java/com/google/gcloud/datastore/LongValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/LongValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/NullValueTest.java b/src/test/java/com/google/gcloud/datastore/NullValueTest.java index 15fe78dd1a4f..a42fdaf0229f 100644 --- a/src/test/java/com/google/gcloud/datastore/NullValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/NullValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/com/google/gcloud/datastore/ProjectionEntityTest.java b/src/test/java/com/google/gcloud/datastore/ProjectionEntityTest.java index f67d719af265..0262fb04b89d 100644 --- a/src/test/java/com/google/gcloud/datastore/ProjectionEntityTest.java +++ b/src/test/java/com/google/gcloud/datastore/ProjectionEntityTest.java @@ -16,10 +16,10 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertNull; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/RawValueTest.java b/src/test/java/com/google/gcloud/datastore/RawValueTest.java index 26854ff9d22b..4d63bc89bacb 100644 --- a/src/test/java/com/google/gcloud/datastore/RawValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/RawValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.api.services.datastore.DatastoreV1; diff --git a/src/test/java/com/google/gcloud/datastore/StringValueTest.java b/src/test/java/com/google/gcloud/datastore/StringValueTest.java index aa53cea22d3a..a2cacd6574aa 100644 --- a/src/test/java/com/google/gcloud/datastore/StringValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/StringValueTest.java @@ -16,8 +16,8 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/src/test/java/com/google/gcloud/datastore/ValueTest.java b/src/test/java/com/google/gcloud/datastore/ValueTest.java index 51304e9f1cac..bbfb790b69a2 100644 --- a/src/test/java/com/google/gcloud/datastore/ValueTest.java +++ b/src/test/java/com/google/gcloud/datastore/ValueTest.java @@ -16,10 +16,10 @@ package com.google.gcloud.datastore; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java index 445e65dc6c35..dbe0eaa19411 100644 --- a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java +++ b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java @@ -17,8 +17,8 @@ package com.google.gcloud.storage; import static com.google.gcloud.storage.StorageService.PredefinedAcl.PUBLIC_READ; -import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.common.collect.Iterables; diff --git a/src/test/java/com/google/gcloud/storage/BatchResponseTest.java b/src/test/java/com/google/gcloud/storage/BatchResponseTest.java index 8e6e850fca61..277c46860ef1 100644 --- a/src/test/java/com/google/gcloud/storage/BatchResponseTest.java +++ b/src/test/java/com/google/gcloud/storage/BatchResponseTest.java @@ -16,7 +16,7 @@ package com.google.gcloud.storage; -import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertEquals; import com.google.common.collect.ImmutableList; import com.google.gcloud.storage.BatchResponse.Result; diff --git a/src/test/java/com/google/gcloud/storage/CorsTest.java b/src/test/java/com/google/gcloud/storage/CorsTest.java index fcb343cd56f6..8b0379f03583 100644 --- a/src/test/java/com/google/gcloud/storage/CorsTest.java +++ b/src/test/java/com/google/gcloud/storage/CorsTest.java @@ -16,7 +16,7 @@ package com.google.gcloud.storage; -import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertEquals; import com.google.common.collect.ImmutableList; import com.google.gcloud.storage.Cors.Method; diff --git a/src/test/java/com/google/gcloud/storage/ListResultTest.java b/src/test/java/com/google/gcloud/storage/ListResultTest.java index 3295e86d01ec..1345b0ced240 100644 --- a/src/test/java/com/google/gcloud/storage/ListResultTest.java +++ b/src/test/java/com/google/gcloud/storage/ListResultTest.java @@ -16,7 +16,7 @@ package com.google.gcloud.storage; -import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertEquals; import com.google.common.collect.ImmutableList; diff --git a/src/test/java/com/google/gcloud/storage/OptionTest.java b/src/test/java/com/google/gcloud/storage/OptionTest.java index b900ce2fc293..4665d04b2d82 100644 --- a/src/test/java/com/google/gcloud/storage/OptionTest.java +++ b/src/test/java/com/google/gcloud/storage/OptionTest.java @@ -16,7 +16,7 @@ package com.google.gcloud.storage; -import static junit.framework.TestCase.assertEquals; +import static org.junit.Assert.assertEquals; import com.google.gcloud.spi.StorageRpc;