use of org.apache.beam.sdk.extensions.gcp.options.GcpOptions in project beam by apache.
the class BigtableIOTest method testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions.
/** Tests that credentials are used from PipelineOptions if not supplied by BigtableOptions. */
@Test
public void testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions() throws Exception {
BigtableOptions options = BIGTABLE_OPTIONS.toBuilder().setCredentialOptions(CredentialOptions.defaultCredentials()).build();
GcpOptions pipelineOptions = PipelineOptionsFactory.as(GcpOptions.class);
pipelineOptions.setGcpCredential(new TestCredential());
BigtableService readService = BigtableIO.read().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
BigtableService writeService = BigtableIO.write().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
assertEquals(CredentialType.SuppliedCredentials, readService.getBigtableOptions().getCredentialOptions().getCredentialType());
assertEquals(CredentialType.SuppliedCredentials, writeService.getBigtableOptions().getCredentialOptions().getCredentialType());
}
use of org.apache.beam.sdk.extensions.gcp.options.GcpOptions in project beam by apache.
the class BigtableIOTest method testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions.
/** Tests that credentials are not used from PipelineOptions if supplied by BigtableOptions. */
@Test
public void testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions() throws Exception {
BigtableOptions options = BIGTABLE_OPTIONS.toBuilder().setCredentialOptions(CredentialOptions.nullCredential()).build();
GcpOptions pipelineOptions = PipelineOptionsFactory.as(GcpOptions.class);
pipelineOptions.setGcpCredential(new TestCredential());
BigtableService readService = BigtableIO.read().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
BigtableService writeService = BigtableIO.write().withBigtableOptions(options).withTableId("TEST-TABLE").getBigtableService(pipelineOptions);
assertEquals(CredentialType.None, readService.getBigtableOptions().getCredentialOptions().getCredentialType());
assertEquals(CredentialType.None, writeService.getBigtableOptions().getCredentialOptions().getCredentialType());
}
Aggregations