ModuleFactory { static boolean needLoad(String moduleLoadList, String moduleName) { String[] activatedModules = StringUtils.splitWithCommaOrSemicolon(moduleLoadList); boolean match = false; for (String activatedModule : activatedModules) { if (StringUtils.ALL.equals(activatedModule)) { match = true; } else if (activatedModule.equals(moduleName)) { match = true; } else if (match && (activatedModule.equals("!" + moduleName) || activatedModule.equals("-" + moduleName))) { match = false; break; } } return match; }  static void installModules(); static void uninstallModules(); static void uninstallModule(String moduleName);  }
@Test public void needLoad() throws Exception { Assert.assertTrue(ModuleFactory.needLoad("*", "xxx")); Assert.assertTrue(ModuleFactory.needLoad("*,xxx", "xxx")); Assert.assertTrue(ModuleFactory.needLoad("xxx", "xxx")); Assert.assertTrue(ModuleFactory.needLoad("xxx,yyy", "xxx")); Assert.assertTrue(ModuleFactory.needLoad("yyy,xxx", "xxx")); Assert.assertTrue(ModuleFactory.needLoad("yyy,xxx,zzz", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("yyy", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("xxxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("xxxx,yyy", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("yyy,xxxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("*,-xxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("a,b,-xxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("xxx,-xxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("*,!xxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("a,b,!xxx", "xxx")); Assert.assertFalse(ModuleFactory.needLoad("xxx,!xxx", "xxx")); }