Skip to content

Commit

Permalink
fix test case and add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Oct 18, 2020
1 parent 45673db commit 054704c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Expand Up @@ -807,8 +807,6 @@ public EnhancedBigtableStubSettings build() {
Preconditions.checkArgument(
getTransportChannelProvider() instanceof InstantiatingGrpcChannelProvider,
"refreshingChannel only works with InstantiatingGrpcChannelProviders");
Preconditions.checkArgument(
appProfileId != null, "refreshingChannel only works when appProfileId is set");
InstantiatingGrpcChannelProvider.Builder channelProviderBuilder =
((InstantiatingGrpcChannelProvider) getTransportChannelProvider()).toBuilder();
try {
Expand Down
Expand Up @@ -47,7 +47,6 @@
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -80,7 +79,6 @@ public class BigtableDataClientFactoryTest {
private int port;

private final BlockingQueue<Attributes> attributes = new LinkedBlockingDeque<>();
private final AtomicInteger terminationCount = new AtomicInteger();

@Before
public void setUp() throws IOException {
Expand All @@ -100,12 +98,6 @@ public Attributes transportReady(Attributes transportAttrs) {
attributes.add(transportAttrs);
return super.transportReady(transportAttrs);
}

@Override
public void transportTerminated(Attributes transportAttrs) {
terminationCount.incrementAndGet();
super.transportTerminated(transportAttrs);
}
})
.build();

Expand Down Expand Up @@ -279,8 +271,6 @@ public void testCreateWithRefreshingChannel() throws Exception {
}
}
assertThat(service.readRowsRequests).containsExactly(expectedRequests.toArray());
factory.close();
assertThat(terminationCount.get()).isEqualTo(poolSize);
}

private static class FakeBigtableService extends BigtableGrpc.BigtableImplBase {
Expand Down
Expand Up @@ -612,4 +612,21 @@ public void isRefreshingChannelFalseValueTest() {
assertThat(builder.build().isRefreshingChannel()).isFalse();
assertThat(builder.build().toBuilder().isRefreshingChannel()).isFalse();
}

@Test
public void verifyRefreshingChannelTransportProviderTest() {
String dummyProjectId = "my-project";
String dummyInstanceId = "my-instance";
EnhancedBigtableStubSettings.Builder builder =
EnhancedBigtableStubSettings.newBuilder()
.setProjectId(dummyProjectId)
.setInstanceId(dummyInstanceId)
.setRefreshingChannel(true);
assertThat(builder.getTransportChannelProvider())
.isInstanceOf(InstantiatingGrpcChannelProvider.class);
assertThat(builder.build().getTransportChannelProvider())
.isInstanceOf(InstantiatingGrpcChannelProvider.class);
assertThat(builder.build().toBuilder().getTransportChannelProvider())
.isInstanceOf(InstantiatingGrpcChannelProvider.class);
}
}

0 comments on commit 054704c

Please sign in to comment.