Source:
public void testBatchJwt() throws IOException { Assume.assumeTrue("Batch JWT can only run against Bigtable", sharedTestEnv.isBigtable()); Assume.assumeFalse( "GCJ client does not support cachedDataPool", Boolean.getBoolean("google.bigtable.use.gcj.client")); String currentEndpoint = sharedTestEnv.getConfiguration().get("google.bigtable.endpoint.host"); Assume.assumeTrue( "Batch JWT test can only run in prod", currentEndpoint == null || "bigtable.googleapis.com".equals(currentEndpoint)); Credentials credentials = GoogleCredentials.getApplicationDefault(); if (credentials instanceof ServiceAccountCredentials) { ServiceAccountCredentials svcCreds = (ServiceAccountCredentials) credentials; credentials = ServiceAccountJwtAccessCredentials.newBuilder() .setClientId(svcCreds.getClientId()) .setClientEmail(svcCreds.getClientEmail()) .setPrivateKeyId(svcCreds.getPrivateKeyId()) .setPrivateKey(svcCreds.getPrivateKey()) .build(); } Assume.assumeTrue( "Service account credentials are required", credentials instanceof ServiceAccountJwtAccessCredentials); BigtableExtendedConfiguration config = new BigtableExtendedConfiguration(sharedTestEnv.getConfiguration(), credentials); config.set("google.bigtable.use.batch", "true"); config.set("google.bigtable.rpc.use.timeouts", "true"); config.set("google.bigtable.rpc.timeout.ms", "20000"); try (Connection connection = BigtableConfiguration.connect(config)) { Table table = connection.getTable(sharedTestEnv.getDefaultTableName()); Exception actualError = null; try { table.get(new Get("any-key".getBytes())); } catch (Exception e) { actualError = e; } Assert.assertNull("No error when getting a key with JWT", actualError); } }

Target:
public void testBatchJwt() throws IOException { Assume.assumeTrue("Batch JWT can only run against Bigtable", sharedTestEnv.isBigtable()); Assume.assumeFalse( "GCJ client does not support cachedDataPool", Boolean.getBoolean("google.bigtable.use.gcj.client")); String currentEndpoint = sharedTestEnv.getConfiguration().get("google.bigtable.endpoint.host"); Assume.assumeTrue( "Batch JWT test can only run in prod", currentEndpoint == null || "bigtable.googleapis.com".equals(currentEndpoint)); Credentials credentials = GoogleCredentials.getApplicationDefault(); if (credentials instanceof ServiceAccountCredentials) { ServiceAccountCredentials svcCreds = (ServiceAccountCredentials) credentials; credentials = ServiceAccountJwtAccessCredentials.newBuilder() .setClientId(svcCreds.getClientId()) .setClientEmail(svcCreds.getClientEmail()) .setPrivateKeyId(svcCreds.getPrivateKeyId()) .setPrivateKey(svcCreds.getPrivateKey()) .build(); } Assume.assumeTrue( "Service account credentials are required", credentials instanceof ServiceAccountJwtAccessCredentials); BigtableExtendedConfiguration config = new BigtableExtendedConfiguration(sharedTestEnv.getConfiguration(), credentials); config.set("google.bigtable.use.batch", "true"); config.set("google.bigtable.rpc.use.timeouts", "true"); config.set("google.bigtable.rpc.timeout.ms", "10000"); config.set("google.bigtable.grpc.channel.count", "1"); try (Connection connection = BigtableConfiguration.connect(config)) { Table table = connection.getTable(sharedTestEnv.getDefaultTableName()); Exception actualError = null; try { table.get(new Get("any-key".getBytes())); } catch (Exception e) { actualError = e; } Assert.assertNull("No error when getting a key with JWT", actualError); } }