*
* @throws Exception If something goes wrong.
*/
@SuppressWarnings("unchecked")
public void testReadByLocale() throws Exception {
MockPublicUrlDefinitionsFactory factory = new MockPublicUrlDefinitionsFactory();
// Set up multiple data sources.
URL url1 = this.getClass().getClassLoader().getResource(
"org/apache/tiles/config/defs1.xml");
assertNotNull("Could not load defs1 file.", url1);
URL url2 = this.getClass().getClassLoader().getResource(
"org/apache/tiles/config/defs2.xml");
assertNotNull("Could not load defs2 file.", url2);
URL url3 = this.getClass().getClassLoader().getResource(
"org/apache/tiles/config/defs3.xml");
assertNotNull("Could not load defs3 file.", url3);
factory.init(Collections.EMPTY_MAP);
factory.addSource(url1);
factory.addSource(url2);
factory.addSource(url3);
// Parse files.
Definitions definitions = factory.readDefinitions();
factory.addDefinitions(definitions,
new MockOnlyLocaleTilesContext(Locale.US));
factory.addDefinitions(definitions,
new MockOnlyLocaleTilesContext(Locale.FRENCH));
assertNotNull("test.def1 definition not found.", definitions.getDefinition("test.def1"));
assertNotNull("test.def1 US definition not found.", definitions.getDefinition("test.def1", Locale.US));
assertNotNull("test.def1 France definition not found.", definitions.getDefinition("test.def1", Locale.FRENCH));