io.r2dbc.h2.H2ConnectionConfiguration Java Examples

The following examples show how to use io.r2dbc.h2.H2ConnectionConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactiveNeo4jTransactionManagerTest.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Test
void shouldSynchronizeWithExternalWithCommit() {

	R2dbcTransactionManager t = new R2dbcTransactionManager(new H2ConnectionFactory(
		H2ConnectionConfiguration.builder().inMemory("test").build()));

	TransactionalOperator transactionalOperator = TransactionalOperator.create(t);

	transactionalOperator
		.execute(transactionStatus -> TransactionSynchronizationManager
			.forCurrentTransaction().doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isFalse())
			.then(retrieveReactiveTransaction(driver, databaseName))
			.flatMap(ignoredNativeTx -> TransactionSynchronizationManager.forCurrentTransaction()
				.doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isTrue()))
		)
		.as(StepVerifier::create)
		.expectNextCount(1L)
		.verifyComplete();

	verify(driver).rxSession(any(SessionConfig.class));

	verify(session).beginTransaction(any(TransactionConfig.class));
	verify(session).close();
	verify(transaction).commit();
	verify(transaction, never()).rollback();
}
 
Example #2
Source File: ReactiveNeo4jTransactionManagerTest.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@Test
void shouldSynchronizeWithExternalWithRollback() {

	R2dbcTransactionManager t = new R2dbcTransactionManager(new H2ConnectionFactory(
		H2ConnectionConfiguration.builder().inMemory("test").build()));

	TransactionalOperator transactionalOperator = TransactionalOperator.create(t);

	transactionalOperator
		.execute(transactionStatus -> TransactionSynchronizationManager
			.forCurrentTransaction()
			.doOnNext(tsm -> {
				assertThat(tsm.hasResource(driver)).isFalse();
				transactionStatus.setRollbackOnly();
			})
			.then(retrieveReactiveTransaction(driver, databaseName))
			.flatMap(ignoredNativeTx -> TransactionSynchronizationManager.forCurrentTransaction()
				.doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isTrue()))
		)
		.as(StepVerifier::create)
		.expectNextCount(1L)
		.verifyComplete();

	verify(driver).rxSession(any(SessionConfig.class));

	verify(session).beginTransaction(any(TransactionConfig.class));
	verify(session).close();
	verify(transaction).rollback();
	verify(transaction, never()).commit();
}
 
Example #3
Source File: H2DatabaseClientInitializer.java    From spring-fu with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {

	H2ConnectionConfiguration configuration = H2ConnectionConfiguration
			.builder()
			.url(this.properties.getUrl())
			.username(this.properties.getUsername())
			.password(this.properties.getPassword())
			.build();

	context.registerBean(DatabaseClient.class, () -> DatabaseClient.builder().connectionFactory(new H2ConnectionFactory(configuration)).build());

}
 
Example #4
Source File: ReactiveDbApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public H2ConnectionFactory connectionFactoru() {
	return new H2ConnectionFactory(
		H2ConnectionConfiguration.builder()
		.inMemory("testdb")
		.username("sa")
	    .build()
	);
}
 
Example #5
Source File: R2DBCConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public H2ConnectionFactory connectionFactory() {
    return new H2ConnectionFactory(
            H2ConnectionConfiguration.builder()
                    .url("mem:testdb;DB_CLOSE_DELAY=-1;TRACE_LEVEL_FILE=4")
                    .username("sa")
                    .build());
}