You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alexander Scott (JIRA)" <ji...@apache.org> on 2017/01/26 16:10:25 UTC
[jira] [Updated] (CONFIGURATION-650) Should throw Initialization
error when no database table exists
[ https://issues.apache.org/jira/browse/CONFIGURATION-650?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Scott updated CONFIGURATION-650:
------------------------------------------
Description:
I have created a unit test using the H2 database. If I try and simulate a new configuration when no database table has been created, I would expect a ConfigurationException to be thrown.
But instead it seems to create the config fine.
{code}
@Test
public void databaseNotPresent2() throws Exception {
EmbeddedDatabase db = new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.build();
BasicConfigurationBuilder<DatabaseConfiguration> builder = new BasicConfigurationBuilder(DatabaseConfiguration.class);
Parameters params = new Parameters();
builder.configure(
params.database()
.setDataSource(db)
.setTable("BADTABLE")
.setKeyColumn("BADKEY")
.setValueColumn("BADVALUE")
//.setThrowExceptionOnMissing(true)
);
DatabaseConfiguration missingTableConfig = builder.getConfiguration();
String missing = missingTableConfig.getString("MISSING_KEY");
assertEquals(null, missing);
missingTableConfig.addProperty("PRESENT_KEY", "some value");
String present = missingTableConfig.getString("PRESENT_KEY");
assertEquals(null, present);
}
{code}
was:
I have created a unit test using the H2 database. If I try and simulate a new configuration when no database table has been created, I would expect a ConfigurationException to be thrown.
But instead it seems to create the config fine.
> Should throw Initialization error when no database table exists
> ---------------------------------------------------------------
>
> Key: CONFIGURATION-650
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-650
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 2.1
> Reporter: Alexander Scott
>
> I have created a unit test using the H2 database. If I try and simulate a new configuration when no database table has been created, I would expect a ConfigurationException to be thrown.
> But instead it seems to create the config fine.
> {code}
> @Test
> public void databaseNotPresent2() throws Exception {
> EmbeddedDatabase db = new EmbeddedDatabaseBuilder()
> .setType(EmbeddedDatabaseType.H2)
> .build();
> BasicConfigurationBuilder<DatabaseConfiguration> builder = new BasicConfigurationBuilder(DatabaseConfiguration.class);
> Parameters params = new Parameters();
> builder.configure(
> params.database()
> .setDataSource(db)
> .setTable("BADTABLE")
> .setKeyColumn("BADKEY")
> .setValueColumn("BADVALUE")
> //.setThrowExceptionOnMissing(true)
> );
> DatabaseConfiguration missingTableConfig = builder.getConfiguration();
> String missing = missingTableConfig.getString("MISSING_KEY");
> assertEquals(null, missing);
> missingTableConfig.addProperty("PRESENT_KEY", "some value");
> String present = missingTableConfig.getString("PRESENT_KEY");
> assertEquals(null, present);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)