use of uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory 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 uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory in project microservice_framework by CJSCommonPlatform.
the class EventStreamJdbcRepositoryIT method initialize.
@Before
public void initialize() {
try {
jdbcRepository.dataSource = new TestDataSourceFactory(LIQUIBASE_EVENT_STORE_DB_CHANGELOG_XML).createDataSource();
jdbcRepository.logger = mock(Logger.class);
jdbcRepository.eventStreamJdbcRepositoryHelper = new JdbcRepositoryHelper();
jdbcRepository.clock = new UtcClock();
final Poller poller = new Poller();
poller.pollUntilFound(() -> {
try {
jdbcRepository.dataSource.getConnection().prepareStatement("SELECT COUNT (*) FROM event_stream;").execute();
return Optional.of("Success");
} catch (SQLException e) {
e.printStackTrace();
return Optional.empty();
}
});
} catch (final Exception e) {
e.printStackTrace();
Assert.fail("EventStreamJdbcRepository construction failed");
}
}
use of uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory 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 uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory in project microservice_framework by CJSCommonPlatform.
the class EventJdbcRepositoryIT method initialize.
@Before
public void initialize() {
try {
jdbcRepository.dataSource = new TestDataSourceFactory(LIQUIBASE_EVENT_STORE_DB_CHANGELOG_XML).createDataSource();
jdbcRepository.logger = mock(Logger.class);
jdbcRepository.eventInsertionStrategy = new AnsiSQLEventLogInsertionStrategy();
jdbcRepository.jdbcRepositoryHelper = new JdbcRepositoryHelper();
final Poller poller = new Poller();
poller.pollUntilFound(() -> {
try {
jdbcRepository.dataSource.getConnection().prepareStatement("SELECT COUNT (*) FROM event_log;").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");
}
}
Aggregations