File additonalFile =
ConfigurationAssert
.getTestFile("testDigesterConfiguration2.xml");
builder.configure(createParameters()
.setFile(additonalFile));
CombinedConfiguration compositeConfiguration =
builder.getConfiguration();
assertEquals("Verify how many configs", 2,
compositeConfiguration.getNumberOfConfigurations());
// Test if union was constructed correctly
Object prop = compositeConfiguration.getProperty("tables.table.name");
assertTrue(prop instanceof Collection);
assertEquals(3, ((Collection<?>) prop).size());
assertEquals("users",
compositeConfiguration.getProperty("tables.table(0).name"));
assertEquals("documents",
compositeConfiguration.getProperty("tables.table(1).name"));
assertEquals("tasks",
compositeConfiguration.getProperty("tables.table(2).name"));
prop =
compositeConfiguration
.getProperty("tables.table.fields.field.name");
assertTrue(prop instanceof Collection);
assertEquals(17, ((Collection<?>) prop).size());
assertEquals("smtp.mydomain.org",
compositeConfiguration.getString("mail.host.smtp"));
assertEquals("pop3.mydomain.org",
compositeConfiguration.getString("mail.host.pop"));
// This was overriden
assertEquals("masterOfPost",
compositeConfiguration.getString("mail.account.user"));
assertEquals("topsecret",
compositeConfiguration.getString("mail.account.psswd"));
// This was overridden, too, but not in additional section
assertEquals("enhanced factory",
compositeConfiguration.getString("test.configuration"));
}