Search in sources :

Example 6 with JdbcRepositoryHelper

use of uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper in project microservice_framework by CJSCommonPlatform.

the class EventRepositoryFactory method getEventJdbcRepository.

public static EventJdbcRepository getEventJdbcRepository(final DataSource dataSource) throws NamingException {
    final EventJdbcRepository eventJdbcRepository = new EventJdbcRepository();
    eventJdbcRepository.dataSource = dataSource;
    eventJdbcRepository.jdbcDataSourceProvider = new JdbcDataSourceProvider();
    eventJdbcRepository.logger = getLogger(EventJdbcRepository.class);
    eventJdbcRepository.jdbcRepositoryHelper = new JdbcRepositoryHelper();
    eventJdbcRepository.eventInsertionStrategy = new AnsiSQLEventLogInsertionStrategy();
    return eventJdbcRepository;
}
Also used : JdbcRepositoryHelper(uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper) AnsiSQLEventLogInsertionStrategy(uk.gov.justice.services.eventsourcing.repository.jdbc.AnsiSQLEventLogInsertionStrategy) JdbcDataSourceProvider(uk.gov.justice.services.jdbc.persistence.JdbcDataSourceProvider)

Example 7 with JdbcRepositoryHelper

use of uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper 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");
    }
}
Also used : JdbcRepositoryHelper(uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper) SQLException(java.sql.SQLException) TestDataSourceFactory(uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory) AnsiSQLEventLogInsertionStrategy(uk.gov.justice.services.eventsourcing.repository.jdbc.AnsiSQLEventLogInsertionStrategy) Logger(org.slf4j.Logger) Poller(uk.gov.justice.services.test.utils.core.messaging.Poller) JdbcRepositoryException(uk.gov.justice.services.jdbc.persistence.JdbcRepositoryException) SQLException(java.sql.SQLException) InvalidPositionException(uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException) Before(org.junit.Before)

Aggregations

JdbcRepositoryHelper (uk.gov.justice.services.jdbc.persistence.JdbcRepositoryHelper)7 Before (org.junit.Before)5 SQLException (java.sql.SQLException)4 Poller (uk.gov.justice.services.test.utils.core.messaging.Poller)4 TestDataSourceFactory (uk.gov.justice.services.test.utils.persistence.TestDataSourceFactory)4 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)2 Logger (org.slf4j.Logger)2 AnsiSQLEventLogInsertionStrategy (uk.gov.justice.services.eventsourcing.repository.jdbc.AnsiSQLEventLogInsertionStrategy)2 InvalidPositionException (uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException)2 UtcClock (uk.gov.justice.services.common.util.UtcClock)1 JdbcDataSourceProvider (uk.gov.justice.services.jdbc.persistence.JdbcDataSourceProvider)1 JdbcRepositoryException (uk.gov.justice.services.jdbc.persistence.JdbcRepositoryException)1