Search in sources :

Example 1 with JdbcPropertyStore

use of org.ff4j.property.store.JdbcPropertyStore in project ff4j by ff4j.

the class JdbcPropertyStoreErrorTest method testCreateKO.

@Test(expected = PropertyAccessException.class)
public void testCreateKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcPropertyStore jrepo = new JdbcPropertyStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.createProperty(new PropertyString("p1", "v1"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) SQLException(java.sql.SQLException) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 2 with JdbcPropertyStore

use of org.ff4j.property.store.JdbcPropertyStore in project ff4j by ff4j.

the class JdbcPropertyStoreErrorTest method testUpdateKO2.

@Test(expected = PropertyAccessException.class)
public void testUpdateKO2() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcPropertyStore jrepo = new JdbcPropertyStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.updateProperty("p1", "v1");
}
Also used : SQLException(java.sql.SQLException) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 3 with JdbcPropertyStore

use of org.ff4j.property.store.JdbcPropertyStore in project ff4j by ff4j.

the class JdbcPropertyStoreErrorTest method testgetExistKO.

@Test(expected = PropertyAccessException.class)
public void testgetExistKO() throws SQLException {
    DataSource mockDS = Mockito.mock(DataSource.class);
    doThrow(new SQLException()).when(mockDS).getConnection();
    JdbcPropertyStore jrepo = new JdbcPropertyStore(mockDS);
    jrepo.setDataSource(mockDS);
    jrepo.existProperty("xx");
}
Also used : SQLException(java.sql.SQLException) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 4 with JdbcPropertyStore

use of org.ff4j.property.store.JdbcPropertyStore in project ff4j by ff4j.

the class JdbcPropertyStorePrefixTest 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();
    JdbcPropertyStore jdbcStore = new JdbcPropertyStore();
    jdbcStore.setQueryBuilder(new JdbcQueryBuilder("T_FF4J_", "_01"));
    jdbcStore.setDataSource(db);
    return jdbcStore;
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore)

Example 5 with JdbcPropertyStore

use of org.ff4j.property.store.JdbcPropertyStore in project ff4j by ff4j.

the class JdbcPropertyStoreTest method initJdbcPropertyStore.

@Test
public void initJdbcPropertyStore() {
    EmbeddedDatabaseBuilder b2 = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db2 = // 
    b2.setType(EmbeddedDatabaseType.HSQL).build();
    JdbcPropertyStore jdbcStore2 = new JdbcPropertyStore(db2, "ff4j.xml");
    Assert.assertNotNull(jdbcStore2);
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) JdbcPropertyStore(org.ff4j.property.store.JdbcPropertyStore) Test(org.junit.Test)

Aggregations

JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)14 Test (org.junit.Test)11 SQLException (java.sql.SQLException)9 DataSource (javax.sql.DataSource)9 EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)5 EmbeddedDatabase (org.springframework.jdbc.datasource.embedded.EmbeddedDatabase)2 PropertyString (org.ff4j.property.PropertyString)1 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)1