@Test public void testCreateFactoryWithClientLibraryClient() { SpannerConnectionFactoryProvider customSpannerConnectionFactoryProvider = new SpannerConnectionFactoryProvider(); ConnectionFactoryOptions options = ConnectionFactoryOptions.builder() .option(DRIVER, DRIVER_NAME) .option(PROJECT, "project-id") .option(INSTANCE, "an-instance") .option(DATABASE, "db") .option(GOOGLE_CREDENTIALS, mock(GoogleCredentials.class)) .option(Option.valueOf("client-implementation"), "client-library") .build(); ConnectionFactory spannerConnectionFactory = customSpannerConnectionFactoryProvider.create(options); assertThat(spannerConnectionFactory).isNotNull(); assertThat(spannerConnectionFactory).isInstanceOf(SpannerClientLibraryConnectionFactory.class); }
@Override public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions) { SpannerConnectionConfiguration config = createConfiguration(connectionFactoryOptions); if (connectionFactoryOptions.hasOption(Option.valueOf("client-implementation")) && connectionFactoryOptions.getValue(Option.valueOf("client-implementation")) .equals("client-library")) { return new SpannerClientLibraryConnectionFactory(config); } else { if (this.client == null) { this.client = new GrpcClient(config.getCredentials()); } return new SpannerConnectionFactory(this.client, config); } }
SpannerConnectionFactoryProvider implements ConnectionFactoryProvider { @Override public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions) { SpannerConnectionConfiguration config = createConfiguration(connectionFactoryOptions); if (connectionFactoryOptions.hasOption(Option.valueOf("client-implementation")) && connectionFactoryOptions.getValue(Option.valueOf("client-implementation")) .equals("client-library")) { return new SpannerClientLibraryConnectionFactory(config); } else { if (this.client == null) { this.client = new GrpcClient(config.getCredentials()); } return new SpannerConnectionFactory(this.client, config); } } }
SpannerConnectionFactoryProvider implements ConnectionFactoryProvider { @Override public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions) { SpannerConnectionConfiguration config = createConfiguration(connectionFactoryOptions); if (connectionFactoryOptions.hasOption(Option.valueOf("client-implementation")) && connectionFactoryOptions.getValue(Option.valueOf("client-implementation")) .equals("client-library")) { return new SpannerClientLibraryConnectionFactory(config); } else { if (this.client == null) { this.client = new GrpcClient(config.getCredentials()); } return new SpannerConnectionFactory(this.client, config); } }  }
SpannerConnectionFactoryProvider implements ConnectionFactoryProvider { @Override public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions) { SpannerConnectionConfiguration config = createConfiguration(connectionFactoryOptions); if (connectionFactoryOptions.hasOption(Option.valueOf("client-implementation")) && connectionFactoryOptions.getValue(Option.valueOf("client-implementation")) .equals("client-library")) { return new SpannerClientLibraryConnectionFactory(config); } else { if (this.client == null) { this.client = new GrpcClient(config.getCredentials()); } return new SpannerConnectionFactory(this.client, config); } }  @Override ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions); @Override boolean supports(ConnectionFactoryOptions connectionFactoryOptions); @Override String getDriver(); }
SpannerConnectionFactoryProvider implements ConnectionFactoryProvider { @Override public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions) { SpannerConnectionConfiguration config = createConfiguration(connectionFactoryOptions); if (connectionFactoryOptions.hasOption(Option.valueOf("client-implementation")) && connectionFactoryOptions.getValue(Option.valueOf("client-implementation")) .equals("client-library")) { return new SpannerClientLibraryConnectionFactory(config); } else { if (this.client == null) { this.client = new GrpcClient(config.getCredentials()); } return new SpannerConnectionFactory(this.client, config); } }  @Override ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOptions); @Override boolean supports(ConnectionFactoryOptions connectionFactoryOptions); @Override String getDriver(); static final String DRIVER_NAME; static final Option<String> PROJECT; static final Option<String> INSTANCE; static final Option<String> URL; static final Option<Integer> THREAD_POOL_SIZE; static final Option<Integer> PARTIAL_RESULT_SET_FETCH_SIZE; static final Option<Duration> DDL_OPERATION_TIMEOUT; static final Option<Duration> DDL_OPERATION_POLL_INTERVAL; static final Option<GoogleCredentials> GOOGLE_CREDENTIALS; }