commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Scott (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CONFIGURATION-650) Should throw Initialization error when no database table exists
Date Thu, 26 Jan 2017 16:34:24 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15839982#comment-15839982
] 

Alexander Scott commented on CONFIGURATION-650:
-----------------------------------------------

You can even have a null datasource, with the same behaviour.

> 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)

Mime
View raw message