Search in sources :

Example 11 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 12 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 13 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testcreateCustomKO.

@Test(expected = FeatureAccessException.class)
public void testcreateCustomKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    List<Property<?>> lp = new ArrayList<Property<?>>();
    lp.add(new PropertyString("p1", "v1"));
    lp.add(new PropertyString("p2", "v2"));
    jrepo.createCustomProperties("F1", lp);
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) PropertyString(org.ff4j.property.PropertyString) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Property(org.ff4j.property.Property) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 14 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testJetDataSourceKO.

@Test(expected = IllegalStateException.class)
public void testJetDataSourceKO() throws SQLException {
    JdbcFeatureStore jrepo = new JdbcFeatureStore(null);
    jrepo.getDataSource();
}
Also used : JdbcFeatureStore(org.ff4j.store.JdbcFeatureStore) Test(org.junit.Test)

Example 15 with JdbcFeatureStore

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

the class JdbcFeatureStoreErrorTest method testgetExistKO.

@Test(expected = FeatureAccessException.class)
public void testgetExistKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.exist("xx");
}
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