ModuleBasedContextFactory { public ModuleDefinitionSet loadModules(Collection<ModuleDefinition> defs, String root) throws IOException { Map<String, ModuleDefinition> modules = wireUpModules(root, defs); DefaultModuleDefinitionSet moduleSet = new DefaultModuleDefinitionSet(modules, root); moduleSet.load(); return moduleSet; }  ModuleDefinitionSet loadModules(Collection<ModuleDefinition> defs, String root);  }
@Test public void testLoad() throws IOException { ModuleBasedContextFactory factory = new ModuleBasedContextFactory(); ModuleDefinitionSet set = factory.loadModules(defs, "base"); assertNotNull(set.getApplicationContext("base")); }
@Test public void testOverride() throws IOException { InitTest.initted = false; ModuleBasedContextFactory factory = new ModuleBasedContextFactory(); ModuleDefinitionSet set = factory.loadModules(defs, "base"); assertTrue(!InitTest.initted); assertEquals("a string", set.getApplicationContext("child1").getBean("override", String.class)); }
@Test public void testExcluded() throws IOException { ModuleBasedContextFactory factory = new ModuleBasedContextFactory(); ModuleDefinitionSet set = factory.loadModules(defs, "base"); assertNull(set.getApplicationContext("excluded")); assertNull(set.getApplicationContext("excluded2")); assertNull(set.getApplicationContext("orphan-of-excluded")); }
@Test public void testBeans() throws IOException { ModuleBasedContextFactory factory = new ModuleBasedContextFactory(); ModuleDefinitionSet set = factory.loadModules(defs, "base"); testBeansInContext(set, "base", 1, new String[] {"base"}, new String[] {"child1", "child2", "child1-1"}); testBeansInContext(set, "child1", 2, new String[] {"base", "child1"}, new String[] {"child2", "child1-1"}); testBeansInContext(set, "child2", 4, new String[] {"base", "child2"}, new String[] {"child1", "child1-1"}); testBeansInContext(set, "child1-1", 3, new String[] {"base", "child1", "child1-1"}, new String[] {"child2"}); }