DefaultModuleDefinition implements ModuleDefinition { public void init() throws IOException { if (!moduleProperties.exists()) { return; } resolveNameAndParent(); contextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getContextLocation(baseDir, name))); configLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getDefaultsLocation(baseDir, name))); inheritableContextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getInheritableContextLocation(baseDir, name))); overrideContextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getOverrideContextLocation(baseDir, name))); valid = true; } DefaultModuleDefinition(String baseDir, Resource moduleProperties, ResourcePatternResolver resolver); void init(); @Override void addChild(ModuleDefinition def); @Override Collection<ModuleDefinition> getChildren(); @Override String getName(); @Override String getParentName(); @Override List<Resource> getConfigLocations(); @Override List<Resource> getContextLocations(); @Override List<Resource> getInheritableContextLocations(); @Override List<Resource> getOverrideContextLocations(); @Override boolean isValid(); @Override ClassLoader getClassLoader(); static final String NAME; static final String PARENT; }
@Test public void testBlankName() { DefaultModuleDefinition def = createDef("blankname"); try { def.init(); fail(); } catch (IOException e) { assertTrue(e.getMessage().contains("Missing name property")); } }
@Test public void testMissingName() { DefaultModuleDefinition def = createDef("missingname"); try { def.init(); fail(); } catch (IOException e) { assertTrue(e.getMessage().contains("Missing name property")); } }
@Test public void testBadName() { DefaultModuleDefinition def = createDef("badname"); try { def.init(); fail(); } catch (IOException e) { assertTrue(e.getMessage().contains("is expected to exist at")); } }
@Test public void testWrongName() { DefaultModuleDefinition def = createDef("wrongname"); try { def.init(); fail(); } catch (IOException e) { assertTrue(e.getMessage().contains("do not appear to be the same resource")); } }