ResourceRuntimeConfig implements IResourceRuntimeConfig { public ResourceRuntimeConfig(String contextPath, File warRoot) { validate(contextPath, "context"); try { m_warRoot = warRoot.getCanonicalFile(); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to resolve WarRoot(%s)!", warRoot), e); } m_properties.put(RESOURCE_BASE, RESOURCES); ResourcePropertiesLoader loader = new ResourcePropertiesLoader(); Map<String, String> map = loader.load(m_warRoot); if (map != null && !map.isEmpty()) { m_properties.putAll(map); } IResourceRegistry registry = new ResourceRegistry(this); new ResourceConfigurator().configure(registry); m_registry = registry; m_contextPath = contextPath; m_cacheManager = new ResourceCacheManager(); m_bundleConfig = new ResourceBundleConfig(); } ResourceRuntimeConfig(String contextPath, File warRoot); @Override ClassLoader getAppClassLoader(); @Override String getAppId(); @Override String getAppVersion(); @Override ResourceCacheManager getCacheManager(); @Override String getContextPath(); @Override String getOptimizationCommand(String type); @Override Map<String, String> getProperties(); @Override String getProperty(String key); @Override IResourceRegistry getRegistry(); @Override String getResourceBase(String type); @Override ResourceBundleConfig getResourceBundleConfig(); @Override ResourceErrPolicy getResourceErrPolicy(); @Override File getWarRoot(); @Override boolean isDev(); @Override boolean isOptimizationEnabled(); boolean isStatisticsEnabled(); @Override Map<String, List<IResource>> loadResource(String namespace, boolean isSecure); void setAppClassLoader(ClassLoader appClassLoader); void setAppId(String appId); void setAppVersion(String appVersion); @Override void setDev(boolean isDev); @Override void setOptimizationCommand(String type, String command); @Override void setOptimizationEnabled(boolean enabled); @Override void setResourceErrPolicy(ResourceErrPolicy policy); void setStatisticsEnabled(Boolean statisticsEnabled); @Override void setProperty(String key, String value); @Override void setVariationResource(IResource resource, IResource minResource); @Override IResource gettVariationResource(IResource Resource); Map<IResource, IResource> getResourceVariationMap(); @Override boolean isResourcePreCollected(); @Override void setResourcePreCollected(boolean collected);  }
@Test public void testResourceRuntimeConfig() { ResourceRuntimeConfig cfg = new ResourceRuntimeConfig("/ResourceRuntimeConfigTest", new File("warRoot")); cfg.setOptimizationCommand("test", "testCommand"); Assert.assertEquals("testCommand", cfg.getOptimizationCommand("test")); cfg.setProperty("testProperties", "123"); Map<String, String> properties = cfg.getProperties(); Assert.assertEquals("/resources", properties.get("resource.base")); Assert.assertEquals("123", properties.get("testProperties")); Assert.assertTrue(cfg.loadResource("local", false).isEmpty()); Assert.assertTrue(cfg.loadResource("shared", false).isEmpty()); cfg.setDev(false); cfg.setOptimizationEnabled(false); cfg.setStatisticsEnabled(false); Assert.assertNull(cfg.gettVariationResource(null)); }