use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderResultsTest method testResultInheritance.
public void testResultInheritance() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-result-inheritance.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
// expectations
provider.init(configuration);
provider.loadPackages();
// assertions
PackageConfig subPkg = configuration.getPackageConfig("subPackage");
assertEquals(1, subPkg.getResultTypeConfigs().size());
assertEquals(3, subPkg.getAllResultTypeConfigs().size());
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderTest method testEmptySpacesNotReloadingConfigs.
public void testEmptySpacesNotReloadingConfigs() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork- test.xml";
buildConfigurationProvider(filename);
ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename);
container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs(false);
container.inject(provider);
provider.init(configuration);
provider.loadPackages();
assertFalse(provider.needsReload());
URI uri = ClassLoaderUtil.getResource(filename, ConfigurationProvider.class).toURI();
File file = new File(uri);
assertTrue(file.exists());
changeFileTime(filename, file);
assertFalse(provider.needsReload());
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderTest method testReload.
public void testReload() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-reload.xml";
ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename);
loadConfigurationProviders(provider);
// Revision exists and timestamp didn't change
assertFalse(provider.needsReload());
File file = new File(getClass().getResource("/" + filename).toURI());
assertTrue("not exists: " + file.toString(), file.exists());
Path configPath = Paths.get(file.getAbsolutePath());
String content = new String(Files.readAllBytes(configPath));
content = content.replaceAll("<constant name=\"struts.configuration.xml.reload\" value=\"true\" />", "<constant name=\"struts.configuration.xml.reload\" value=\"false\" />");
// user demand: stop reloading configs
Files.write(configPath, content.getBytes());
try {
// config file has changed in previous lines
assertTrue(provider.needsReload());
configurationManager.reload();
changeFileTime(filename, file);
// user already has stopped reloading configs
assertFalse(provider.needsReload());
} finally {
content = content.replaceAll("<constant name=\"struts.configuration.xml.reload\" value=\"false\" />", "<constant name=\"struts.configuration.xml.reload\" value=\"true\" />");
Files.write(configPath, content.getBytes());
}
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderTest method testEmptySpaces.
public void testEmptySpaces() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork- test.xml";
ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename);
container.inject(provider);
provider.init(configuration);
provider.loadPackages();
container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs(true);
assertFalse(provider.needsReload());
URI uri = ClassLoaderUtil.getResource(filename, ConfigurationProvider.class).toURI();
File file = new File(uri);
assertTrue(file.exists());
changeFileTime(filename, file);
assertTrue(provider.needsReload());
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderTest method testNeedsReloadNotReloadingConfigs.
public void testNeedsReloadNotReloadingConfigs() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml";
buildConfigurationProvider(filename);
ConfigurationProvider provider = new StrutsXmlConfigurationProvider(filename);
container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs(false);
container.inject(provider);
provider.init(configuration);
provider.loadPackages();
// Revision exists and timestamp didn't change
assertFalse(provider.needsReload());
File file = new File(getClass().getResource("/" + filename).toURI());
assertTrue("not exists: " + file.toString(), file.exists());
changeFileTime(filename, file);
assertFalse(provider.needsReload());
}
Aggregations