[ https://issues.apache.org/jira/browse/CONFIGURATION-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15840079#comment-15840079 ]
Alexander Scott commented on CONFIGURATION-650: ----------------------------------------------- Looks like I need to add the following line to enable Exceptions; {code} ConfigurationUtils.enableRuntimeExceptions(missingTableConfig); {code} > 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)