use of io.r2dbc.spi.ConnectionFactory 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 io.r2dbc.spi.ConnectionFactory in project spring-framework by spring-projects.
the class BeanFactoryConnectionFactoryLookupUnitTests method shouldLookupConnectionFactory.
@Test
public void shouldLookupConnectionFactory() {
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
when(beanFactory.getBean(CONNECTION_FACTORY_BEAN_NAME, ConnectionFactory.class)).thenReturn(expectedConnectionFactory);
BeanFactoryConnectionFactoryLookup lookup = new BeanFactoryConnectionFactoryLookup();
lookup.setBeanFactory(beanFactory);
ConnectionFactory connectionFactory = lookup.getConnectionFactory(CONNECTION_FACTORY_BEAN_NAME);
assertThat(connectionFactory).isNotNull();
assertThat(connectionFactory).isSameAs(expectedConnectionFactory);
}
use of io.r2dbc.spi.ConnectionFactory in project spring-framework by spring-projects.
the class MapConnectionFactoryLookupUnitTests method addingConnectionFactoryPermitsOverride.
@Test
public void addingConnectionFactoryPermitsOverride() {
Map<String, ConnectionFactory> connectionFactories = new HashMap<>();
DummyConnectionFactory overriddenConnectionFactory = new DummyConnectionFactory();
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
connectionFactories.put(CONNECTION_FACTORY_NAME, overriddenConnectionFactory);
MapConnectionFactoryLookup lookup = new MapConnectionFactoryLookup();
lookup.setConnectionFactories(connectionFactories);
lookup.addConnectionFactory(CONNECTION_FACTORY_NAME, expectedConnectionFactory);
ConnectionFactory connectionFactory = lookup.getConnectionFactory(CONNECTION_FACTORY_NAME);
assertThat(connectionFactory).isNotNull().isSameAs(expectedConnectionFactory);
}
use of io.r2dbc.spi.ConnectionFactory in project spring-framework by spring-projects.
the class ConnectionFactoryUtils method getConnectionSynchronizationOrder.
/**
* Determine the connection synchronization order to use for the given {@link ConnectionFactory}.
* Decreased for every level of nesting that a {@link ConnectionFactory} has,
* checked through the level of {@link DelegatingConnectionFactory} nesting.
* @param connectionFactory the {@link ConnectionFactory} to check
* @return the connection synchronization order to use
* @see #CONNECTION_SYNCHRONIZATION_ORDER
*/
private static int getConnectionSynchronizationOrder(ConnectionFactory connectionFactory) {
int order = CONNECTION_SYNCHRONIZATION_ORDER;
ConnectionFactory current = connectionFactory;
while (current instanceof DelegatingConnectionFactory) {
order--;
current = ((DelegatingConnectionFactory) current).getTargetConnectionFactory();
}
return order;
}
use of io.r2dbc.spi.ConnectionFactory in project jOOQ by jOOQ.
the class R2dbcTest method setup.
@Before
public void setup() {
ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.parse("r2dbc:h2:file://localhost/~/jooq-r2dbc-example").mutate().option(ConnectionFactoryOptions.USER, "sa").option(ConnectionFactoryOptions.PASSWORD, "").build());
ctx = DSL.using(connectionFactory);
Flux.fromIterable(ctx.parser().parse(Source.of(R2dbcTest.class.getResourceAsStream("/db.sql")).readString())).ofType(RowCountQuery.class).flatMap(q -> q).collectList().block();
}
Aggregations