Search in sources :

Example 11 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class JdbcEventRepositorySchemaTest method testCreateSchema.

@Test
public void testCreateSchema() {
    DataSource ds = testedStore.getDataSource();
    JdbcQueryBuilder qb = testedStore.getQueryBuilder();
    // Given
    Assert.assertFalse(isTableExist(ds, qb.getTableNameAudit()));
    // When
    testedStore.createSchema();
    // then
    Assert.assertTrue(isTableExist(ds, qb.getTableNameAudit()));
    // When (no error)
    testedStore.createSchema();
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 12 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class JdbcPropertyStoreSchemaTest method testCreateSchema.

@Test
public void testCreateSchema() {
    DataSource ds = testedStore.getDataSource();
    JdbcQueryBuilder qb = testedStore.getQueryBuilder();
    // Given
    Assert.assertFalse(isTableExist(ds, qb.getTableNameProperties()));
    // When
    testedStore.createSchema();
    // then
    Assert.assertTrue(isTableExist(ds, qb.getTableNameProperties()));
    // When (no error)
    testedStore.createSchema();
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 13 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class SpringJdbcPropertyStorePrefixTest method initPropertyStore.

/**
 * {@inheritDoc}
 */
@Override
protected PropertyStore initPropertyStore() {
    builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(// 
    EmbeddedDatabaseType.HSQL).addScript(// 
    "classpath:ddl-prefix-schema.sql").addScript("classpath:ddl-prefix-data.sql").build();
    PropertyStoreSpringJdbc jdbcStore = new PropertyStoreSpringJdbc();
    jdbcStore.setQueryBuilder(new JdbcQueryBuilder("T_FF4J_", "_01"));
    jdbcStore.setDataSource(db);
    return jdbcStore;
}
Also used : PropertyStoreSpringJdbc(org.ff4j.springjdbc.store.PropertyStoreSpringJdbc) JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)

Example 14 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class SpringJdbcStoresCreateSchema method testCreateTablesWithDataBaseSchema.

@Test
public void testCreateTablesWithDataBaseSchema() {
    JdbcQueryBuilder queryBuilder = testedStore.getQueryBuilder();
    queryBuilder.setDbSchema("FF4J");
    testedStore.createSchema();
    DataSource dataSource = testedStore.getJdbcTemplate().getDataSource();
    Assert.assertTrue(JdbcUtils.isTableExist(dataSource, queryBuilder.getTableNameFeatures(), "FF4J"));
    Assert.assertFalse(JdbcUtils.isTableExist(dataSource, queryBuilder.getTableNameFeatures(), "FF4J_2"));
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)14 Test (org.junit.Test)7 DataSource (javax.sql.DataSource)6 EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)4 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)1 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)1 FeatureStoreSpringJdbc (org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)1 PropertyStoreSpringJdbc (org.ff4j.springjdbc.store.PropertyStoreSpringJdbc)1 JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)1 Transactional (org.springframework.transaction.annotation.Transactional)1