Skip to content

Commit fc8855a

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 891 b: refs/heads/master c: e776320 h: refs/heads/master i: 889: e8550f5 887: bb8aae6 v: v3
1 parent b6c5ec2 commit fc8855a

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
refs/heads/master: 8928c498a3c90586990c13e5496e406c064cd35a
2+
refs/heads/master: e776320245ef694d89fbbf59195487a141aebf4d
33
refs/heads/travis: 0fa997e2fc9c6b61b2d91e6d163655aae67d44b6
44
refs/heads/gh-pages: 5a10432ecc75f29812e33a8236c900379509fe99

trunk/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ public void testKeyFactory() {
640640
}
641641

642642
@Test
643-
public void testRetries() throws Exception {
643+
public void testRetryableException() throws Exception {
644644
DatastoreV1.LookupRequest requestPb =
645645
DatastoreV1.LookupRequest.newBuilder().addKey(KEY1.toPb()).build();
646646
DatastoreV1.LookupResponse responsePb = DatastoreV1.LookupResponse.newBuilder()
@@ -664,7 +664,31 @@ public void testRetries() throws Exception {
664664
}
665665

666666
@Test
667-
public void testRuntimeExceptionHandling() throws Exception {
667+
public void testNonRetryableException() throws Exception {
668+
DatastoreV1.LookupRequest requestPb =
669+
DatastoreV1.LookupRequest.newBuilder().addKey(KEY1.toPb()).build();
670+
DatastoreRpcFactory rpcFactoryMock = EasyMock.createStrictMock(DatastoreRpcFactory.class);
671+
DatastoreRpc rpcMock = EasyMock.createStrictMock(DatastoreRpc.class);
672+
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
673+
.andReturn(rpcMock);
674+
EasyMock.expect(rpcMock.lookup(requestPb))
675+
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.PERMISSION_DENIED))
676+
.times(1);
677+
EasyMock.replay(rpcFactoryMock, rpcMock);
678+
RetryParams retryParams = RetryParams.builder().retryMinAttempts(2).build();
679+
DatastoreOptions options = this.options.toBuilder()
680+
.retryParams(retryParams)
681+
.serviceRpcFactory(rpcFactoryMock)
682+
.build();
683+
Datastore datastore = DatastoreFactory.instance().get(options);
684+
thrown.expect(DatastoreException.class);
685+
thrown.expectMessage(Reason.PERMISSION_DENIED.description());
686+
datastore.get(KEY1);
687+
EasyMock.verify(rpcFactoryMock, rpcMock);
688+
}
689+
690+
@Test
691+
public void testRuntimeException() throws Exception {
668692
DatastoreV1.LookupRequest requestPb =
669693
DatastoreV1.LookupRequest.newBuilder().addKey(KEY1.toPb()).build();
670694
DatastoreRpcFactory rpcFactoryMock = EasyMock.createStrictMock(DatastoreRpcFactory.class);

0 commit comments

Comments
 (0)