Search in sources :

Example 46 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project spring-integration by spring-projects.

the class JdbcOutboundGatewayTests method testSetMaxRowsPerPollWithoutSelectQuery.

@Test
public void testSetMaxRowsPerPollWithoutSelectQuery() {
    EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
    JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "update something");
    try {
        jdbcOutboundGateway.setMaxRowsPerPoll(10);
        jdbcOutboundGateway.setBeanFactory(mock(BeanFactory.class));
        jdbcOutboundGateway.afterPropertiesSet();
        fail("Expected an IllegalArgumentException to be thrown.");
    } catch (IllegalArgumentException e) {
        assertEquals("If you want to set 'maxRowsPerPoll', then you must provide a 'selectQuery'.", e.getMessage());
    }
    dataSource.shutdown();
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) BeanFactory(org.springframework.beans.factory.BeanFactory) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Test(org.junit.Test)

Example 47 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project spring-integration by spring-projects.

the class PersistentAcceptOnceFileListFilterExternalStoreTests method testFileSystemWithJdbcMetadataStore.

@Test
public void testFileSystemWithJdbcMetadataStore() throws Exception {
    EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:/org/springframework/integration/jdbc/schema-drop-h2.sql").addScript("classpath:/org/springframework/integration/jdbc/schema-h2.sql").build();
    JdbcMetadataStore metadataStore = new JdbcMetadataStore(dataSource);
    metadataStore.afterPropertiesSet();
    try {
        testFileSystem(metadataStore);
        List<Map<String, Object>> metaData = new JdbcTemplate(dataSource).queryForList("SELECT * FROM INT_METADATA_STORE");
        assertEquals(1, metaData.size());
        assertEquals("43", metaData.get(0).get("METADATA_VALUE"));
    } finally {
        dataSource.shutdown();
    }
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) JdbcMetadataStore(org.springframework.integration.jdbc.metadata.JdbcMetadataStore) Map(java.util.Map) Test(org.junit.Test)

Example 48 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project ff4j by ff4j.

the class JdbcEventRepositorySchemaTest method initStore.

/**
 * {@inheritDoc}
 */
public void initStore() {
    builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(EmbeddedDatabaseType.HSQL).build();
    testedStore = new JdbcEventRepository(db);
}
Also used : JdbcEventRepository(org.ff4j.audit.repository.JdbcEventRepository) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)

Example 49 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project ff4j by ff4j.

the class JdbcEventRepositoryTest method initRepository.

/**
 * {@inheritDoc}
 */
@Override
protected EventRepository initRepository() {
    builder = new EmbeddedDatabaseBuilder();
    db = // 
    builder.setType(EmbeddedDatabaseType.HSQL).addScript(// 
    "classpath:schema-ddl.sql").addScript(// 
    "classpath:ff-store.sql").build();
    return new JdbcEventRepository(db);
}
Also used : JdbcEventRepository(org.ff4j.audit.repository.JdbcEventRepository) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)

Example 50 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project ff4j by ff4j.

the class JdbcPropertyStoreSchemaTest method initStore.

/**
 * {@inheritDoc}
 */
public void initStore() {
    builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(EmbeddedDatabaseType.HSQL).build();
    testedStore = new JdbcPropertyStore();
    testedStore.setDataSource(db);
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore)

Aggregations

EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)67 Before (org.junit.Before)17 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)15 EmbeddedDatabase (org.springframework.jdbc.datasource.embedded.EmbeddedDatabase)15 JndiRegistry (org.apache.camel.impl.JndiRegistry)11 Bean (org.springframework.context.annotation.Bean)9 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)5 FeatureStoreSpringJdbc (org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)5 JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)5 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)4 Test (org.junit.Test)4 PropertyStoreSpringJdbc (org.ff4j.springjdbc.store.PropertyStoreSpringJdbc)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.jupiter.api.Test)3 PreparedStatement (java.sql.PreparedStatement)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 JdbcEventRepository (org.ff4j.audit.repository.JdbcEventRepository)2 Connection (java.sql.Connection)1 Map (java.util.Map)1 Properties (java.util.Properties)1