use of uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper 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.jdbc.persistence.JdbcRepositoryHelper 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.jdbc.persistence.JdbcRepositoryHelper in project microservice_framework by CJSCommonPlatform.
the class StreamStatusJdbcRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
when(dataSource.getConnection()).thenReturn(connection);
when(connection.getMetaData()).thenReturn(dbMetadata);
repository.jdbcRepositoryHelper = new JdbcRepositoryHelper();
}
use of uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper 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.jdbc.persistence.JdbcRepositoryHelper in project microservice_framework by CJSCommonPlatform.
the class StandaloneStreamStatusJdbcRepositoryFactory method getSnapshotStreamStatusJdbcRepository.
public static StreamStatusJdbcRepository getSnapshotStreamStatusJdbcRepository(final DataSource dataSource) {
final StreamStatusJdbcRepository snapshotJdbcRepository = new StreamStatusJdbcRepository();
snapshotJdbcRepository.dataSource = dataSource;
snapshotJdbcRepository.jdbcRepositoryHelper = new JdbcRepositoryHelper();
return snapshotJdbcRepository;
}
Aggregations