use of org.h2.jdbcx.JdbcDataSource in project microservice_framework by CJSCommonPlatform.
the class StreamStatusJdbcRepositoryIT method initDatabase.
@Before
public void initDatabase() throws Exception {
final TestDataSourceFactory testDataSourceFactory = new TestDataSourceFactory(LIQUIBASE_STREAM_STATUS_CHANGELOG_XML);
final JdbcDataSource dataSource = testDataSourceFactory.createDataSource();
jdbcRepository = new StreamStatusJdbcRepository(dataSource, new JdbcRepositoryHelper());
try {
final Poller poller = new Poller();
poller.pollUntilFound(() -> {
try {
dataSource.getConnection().prepareStatement("SELECT COUNT (*) FROM stream_buffer;").execute();
return Optional.of("Success");
} catch (SQLException e) {
e.printStackTrace();
fail("EventJdbcRepository construction failed");
return Optional.empty();
}
});
} catch (final Exception e) {
e.printStackTrace();
fail("EventJdbcRepository construction failed");
}
}
use of org.h2.jdbcx.JdbcDataSource in project microservice_framework by CJSCommonPlatform.
the class StreamBufferJdbcRepositoryIT method initDatabase.
@Before
public void initDatabase() throws Exception {
final TestDataSourceFactory testDataSourceFactory = new TestDataSourceFactory(LIQUIBASE_STREAM_STATUS_CHANGELOG_XML);
final JdbcDataSource dataSource = testDataSourceFactory.createDataSource();
jdbcRepository = new StreamBufferJdbcRepository(dataSource, new JdbcRepositoryHelper());
try {
final Poller poller = new Poller();
poller.pollUntilFound(() -> {
try {
dataSource.getConnection().prepareStatement("SELECT COUNT (*) FROM stream_buffer;").execute();
return Optional.of("Success");
} catch (SQLException e) {
e.printStackTrace();
fail("EventJdbcRepository construction failed");
return Optional.empty();
}
});
} catch (final Exception e) {
e.printStackTrace();
fail("EventJdbcRepository construction failed");
}
}
use of org.h2.jdbcx.JdbcDataSource in project narayana by jbosstm.
the class TestCommitMarkableResourceFailAfterPrepare method testFailAfterPrepare.
@Test
@BMScript("commitMarkableResourceFailAfterPrepare")
public void testFailAfterPrepare() throws Exception {
final DataSource dataSource = new JdbcDataSource();
generateCMRRecord(dataSource);
checkCMRRecovery(dataSource);
}
use of org.h2.jdbcx.JdbcDataSource in project narayana by jbosstm.
the class TestCommitMarkableResourceFailAfterCommitTwoXAResources method testFailAfterCommitH2.
@Test
@BMScript("commitMarkableResourceFailAfterCommit")
public void testFailAfterCommitH2() throws Exception {
final JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:mem:JBTMDB;MVCC=TRUE");
}
use of org.h2.jdbcx.JdbcDataSource in project narayana by jbosstm.
the class TestCommitMarkableResourceMultiEnlist method testFailDoubleEnlist.
@Test
public void testFailDoubleEnlist() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, SQLException {
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:mem:JBTMDB;MVCC=TRUE");
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.begin();
tm.getTransaction().enlistResource(new JDBCConnectableResource(dataSource.getConnection()));
if (tm.getTransaction().enlistResource(new JDBCConnectableResource(dataSource.getConnection()))) {
fail();
}
tm.rollback();
}
Aggregations