use of org.ff4j.store.JdbcFeatureStore in project ff4j by ff4j.
the class JdbcFeatureStoreErrorTest method testgetReadGroupKO.
@Test(expected = FeatureAccessException.class)
public void testgetReadGroupKO() throws SQLException {
DataSource mockDS = Mockito.mock(DataSource.class);
doThrow(new SQLException()).when(mockDS).getConnection();
JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
jrepo.setDataSource(mockDS);
jrepo.readGroup("xx");
}
use of org.ff4j.store.JdbcFeatureStore in project ff4j by ff4j.
the class JdbcFeatureStoreErrorTest method testreadAllKO.
@Test(expected = FeatureAccessException.class)
public void testreadAllKO() throws SQLException {
DataSource mockDS = Mockito.mock(DataSource.class);
doThrow(new SQLException()).when(mockDS).getConnection();
JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
jrepo.setDataSource(mockDS);
jrepo.readAll();
}
use of org.ff4j.store.JdbcFeatureStore in project ff4j by ff4j.
the class JdbcFeatureStoreSchemaTest method initStore.
/**
* {@inheritDoc}
* @throws SQLException
*/
public void initStore() throws SQLException {
builder = new EmbeddedDatabaseBuilder();
db = builder.setType(EmbeddedDatabaseType.HSQL).build();
PreparedStatement prepareStatement = db.getConnection().prepareStatement("CREATE SCHEMA FF4J");
prepareStatement.executeUpdate();
prepareStatement = db.getConnection().prepareStatement("CREATE SCHEMA FF4J_2");
prepareStatement.executeUpdate();
testedStore = new JdbcFeatureStore();
testedStore.setDataSource(db);
}
use of org.ff4j.store.JdbcFeatureStore in project ff4j by ff4j.
the class JdbcFeatureStoreXmlTest method initStore.
/**
* {@inheritDoc}
*/
@Override
protected FeatureStore initStore() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
db = builder.setType(EmbeddedDatabaseType.HSQL).addScript("classpath:schema-ddl.sql").build();
return new JdbcFeatureStore(db, "ff4j.xml");
}
use of org.ff4j.store.JdbcFeatureStore in project TP-CORE by ElmarDott.
the class FeatureFlagsFF4j method getFeatureStore.
@Override
public FF4j getFeatureStore(final String propertyFile) throws IOException, ConnectException {
loadConfigurationFromDatabase();
if (Boolean.parseBoolean(configuration.get("ff.activation"))) {
reader.appendPropertiesFromClasspath(propertyFile);
BasicDataSource cpds = new BasicDataSource();
cpds.setDriverClassName(reader.getPropertyAsString("jdbc.driverClassName"));
cpds.setUrl(reader.getPropertyAsString("jdbc.url"));
cpds.setUsername(reader.getPropertyAsString("jdbc.user"));
cpds.setPassword(reader.getPropertyAsString("jdbc.password"));
ff4j = new FF4j();
ff4j.setFeatureStore(new JdbcFeatureStore(cpds));
ff4j.setPropertiesStore(new JdbcPropertyStore(cpds));
ff4j.setEventRepository(new JdbcEventRepository(cpds));
ff4j.audit(Boolean.parseBoolean(configuration.get("ff.audit")));
ff4j.autoCreate(Boolean.parseBoolean(configuration.get("ff.autocreate")));
} else {
LOGGER.log("Feature Flags are deactivated.", LogLevel.DEBUG);
}
return ff4j;
}
Aggregations