Search in sources :

Example 6 with JdbcFeatureStore

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

the class JdbcFeatureStorePrefixTest method initStore.

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

Example 7 with JdbcFeatureStore

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

the class JdbcFeatureStoreTestInvalidData method setUp.

/**
 * {@inheritDoc}
 */
@Before
public void setUp() throws Exception {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(// 
    EmbeddedDatabaseType.HSQL).addScript(// 
    "classpath:schema-ddl.sql").addScript("classpath:ff-invalidstore.sql").build();
    jdbcStore = new JdbcFeatureStore();
    jdbcStore.setDataSource(db);
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) Before(org.junit.Before)

Example 8 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testCreateKO.

@Test(expected = FeatureAccessException.class)
public void testCreateKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.create(new Feature("U1", true));
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) SQLException(java.sql.SQLException) Feature(org.ff4j.core.Feature) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 9 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testReadAllGroupKO.

@Test(expected = FeatureAccessException.class)
public void testReadAllGroupKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.readAllGroups();
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) SQLException(java.sql.SQLException) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 10 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testClearKO.

@Test(expected = FeatureAccessException.class)
public void testClearKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.clear();
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) SQLException(java.sql.SQLException) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)20 Test (org.junit.Test)14 SQLException (java.sql.SQLException)13 DataSource (javax.sql.DataSource)13 EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)5 Feature (org.ff4j.core.Feature)2 PreparedStatement (java.sql.PreparedStatement)1 ArrayList (java.util.ArrayList)1 BasicDataSource (org.apache.commons.dbcp2.BasicDataSource)1 FF4j (org.ff4j.FF4j)1 JdbcEventRepository (org.ff4j.audit.repository.JdbcEventRepository)1 Property (org.ff4j.property.Property)1 PropertyString (org.ff4j.property.PropertyString)1 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)1 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)1 Before (org.junit.Before)1