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:46:24 UTC
[jira] [Comment Edited] (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:comment-tabpanel&focusedCommentId=15839923#comment-15839923 ]
Alexander Scott edited comment on CONFIGURATION-650 at 1/26/17 4:46 PM:
------------------------------------------------------------------------
Assume this isn't just some weird H2/Spring EmbeddedDatabase quirk?
was (Author: alexjascott@gmail.com):
Assume this isn't just some weird H2 quirk?
> 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)