BigtableHBaseVeneerSettings extends BigtableHBaseSettings { public BigtableTableAdminSettings getTableAdminSettings() { return tableAdminSettings; } BigtableHBaseVeneerSettings(Configuration configuration); @Override String getDataHost(); @Override String getAdminHost(); @Override int getPort(); @Override int getBulkMaxRowCount(); @Override long getBatchingMaxRequestSize(); @Override boolean isRetriesWithoutTimestampAllowed(); boolean isChannelPoolCachingEnabled(); BigtableDataSettings getDataSettings(); BigtableTableAdminSettings getTableAdminSettings(); @Nullable BigtableInstanceAdminSettings getInstanceAdminSettings();  }
@Test public void testAdminSettingsBasicKeys() throws IOException { String adminHost = "testadmin.example.com"; String userAgent = "test-user-agent"; Credentials credentials = Mockito.mock(Credentials.class); configuration.set(BIGTABLE_ADMIN_HOST_KEY, adminHost); configuration.setInt(BIGTABLE_PORT_KEY, TEST_PORT); configuration.set(CUSTOM_USER_AGENT_KEY, userAgent); configuration.setBoolean(BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true); configuration.set(BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, "true"); configuration = BigtableConfiguration.withCredentials(configuration, credentials); BigtableHBaseVeneerSettings settings = (BigtableHBaseVeneerSettings) BigtableHBaseSettings.create(configuration); BigtableTableAdminSettings adminSettings = settings.getTableAdminSettings(); assertEquals(TEST_PROJECT_ID, adminSettings.getProjectId()); assertEquals(TEST_INSTANCE_ID, adminSettings.getInstanceId()); assertEquals(adminHost + ":" + TEST_PORT, adminSettings.getStubSettings().getEndpoint()); Map<String, String> headers = adminSettings.getStubSettings().getHeaderProvider().getHeaders(); assertTrue(headers.get(GrpcUtil.USER_AGENT_KEY.name()).contains(userAgent)); assertEquals( credentials, adminSettings.getStubSettings().getCredentialsProvider().getCredentials()); }
@Test public void testAdminSettingsWithEmulator() throws IOException { ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); String emulatorHost = "localhost:" + availablePort; configuration.set(BIGTABLE_EMULATOR_HOST_KEY, emulatorHost); BigtableTableAdminSettings adminSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)) .getTableAdminSettings(); assertEquals(emulatorHost, adminSettings.getStubSettings().getEndpoint()); CredentialsProvider credProvider = adminSettings.getStubSettings().getCredentialsProvider(); assertTrue(credProvider instanceof NoCredentialsProvider); }