use of org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer in project spring-security by spring-projects.
the class R2dbcReactiveOAuth2AuthorizedClientServiceTests method createDb.
private static ConnectionFactory createDb() {
ConnectionFactory connectionFactory = H2ConnectionFactory.inMemory("oauth-test");
Mono.from(connectionFactory.create()).flatMapMany((connection) -> Flux.from(connection.createStatement("drop table oauth2_authorized_client").execute()).flatMap(Result::getRowsUpdated).onErrorResume((e) -> Mono.empty()).thenMany(connection.close())).as(StepVerifier::create).verifyComplete();
ConnectionFactoryInitializer createDb = createDb(OAUTH2_CLIENT_SCHEMA_SQL_RESOURCE);
createDb.setConnectionFactory(connectionFactory);
createDb.afterPropertiesSet();
return connectionFactory;
}
use of org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer in project spring-security by spring-projects.
the class R2dbcReactiveOAuth2AuthorizedClientServiceTests method createDb.
private static ConnectionFactoryInitializer createDb(String schema) {
ConnectionFactoryInitializer initializer = new ConnectionFactoryInitializer();
CompositeDatabasePopulator populator = new CompositeDatabasePopulator();
populator.addPopulators(new ResourceDatabasePopulator(new ClassPathResource(schema)));
initializer.setDatabasePopulator(populator);
return initializer;
}
Aggregations