Search in sources :

Example 1 with JdbcFeatureStore

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

the class JdbcFeatureStoreCoreTest method initStore.

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

Example 2 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testexistGroupKO.

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

Example 3 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testUpdateKO.

@Test(expected = FeatureAccessException.class)
public void testUpdateKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.update(new Feature("f1", 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 4 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 5 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testReadGroupKO.

@Test(expected = FeatureAccessException.class)
public void testReadGroupKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.readGroup("invalid");
}
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)19 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 Property (org.ff4j.property.Property)1 PropertyString (org.ff4j.property.PropertyString)1 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)1 Before (org.junit.Before)1