use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderTest method testInheritence.
public void testInheritence() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-include-parent.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
provider.init(configuration);
provider.loadPackages();
// test expectations
assertEquals(6, configuration.getPackageConfigs().size());
PackageConfig defaultPackage = configuration.getPackageConfig("default");
assertNotNull(defaultPackage);
assertEquals("default", defaultPackage.getName());
PackageConfig namespace1 = configuration.getPackageConfig("namespace1");
assertNotNull(namespace1);
assertEquals("namespace1", namespace1.getName());
assertEquals(defaultPackage, namespace1.getParents().get(0));
PackageConfig namespace2 = configuration.getPackageConfig("namespace2");
assertNotNull(namespace2);
assertEquals("namespace2", namespace2.getName());
assertEquals(1, namespace2.getParents().size());
assertEquals(namespace1, namespace2.getParents().get(0));
PackageConfig namespace4 = configuration.getPackageConfig("namespace4");
assertNotNull(namespace4);
assertEquals("namespace4", namespace4.getName());
assertEquals(1, namespace4.getParents().size());
assertEquals(namespace1, namespace4.getParents().get(0));
PackageConfig namespace5 = configuration.getPackageConfig("namespace5");
assertNotNull(namespace5);
assertEquals("namespace5", namespace5.getName());
assertEquals(1, namespace5.getParents().size());
assertEquals(namespace4, namespace5.getParents().get(0));
configurationManager.addContainerProvider(provider);
configurationManager.reload();
RuntimeConfiguration runtimeConfiguration = configurationManager.getConfiguration().getRuntimeConfiguration();
assertNotNull(runtimeConfiguration.getActionConfig("/namespace1", "action1"));
assertNotNull(runtimeConfiguration.getActionConfig("/namespace2", "action2"));
assertNotNull(runtimeConfiguration.getActionConfig("/namespace4", "action4"));
assertNotNull(runtimeConfiguration.getActionConfig("/namespace5", "action5"));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderUnknownHandlerStackTest method testEmptyStack.
public void testEmptyStack() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
loadConfigurationProviders(provider);
configurationManager.reload();
List<UnknownHandlerConfig> unknownHandlerStack = configuration.getUnknownHandlerStack();
assertNull(unknownHandlerStack);
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderWildCardIncludeTest method testWildCardInclude.
public void testWildCardInclude() throws Exception {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
provider.init(configuration);
provider.loadPackages();
PackageConfig defaultWildcardPackage = configuration.getPackageConfig("default-wildcard");
assertNotNull(defaultWildcardPackage);
assertEquals("default-wildcard", defaultWildcardPackage.getName());
PackageConfig defaultOnePackage = configuration.getPackageConfig("default-1");
assertNotNull(defaultOnePackage);
assertEquals("default-1", defaultOnePackage.getName());
PackageConfig defaultTwoPackage = configuration.getPackageConfig("default-2");
assertNotNull(defaultTwoPackage);
assertEquals("default-2", defaultTwoPackage.getName());
PackageConfig defaultPackage = configuration.getPackageConfig("default");
assertNotNull(defaultPackage);
assertEquals("default", defaultPackage.getName());
configurationManager.addContainerProvider(provider);
configurationManager.reload();
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class OsgiConfigurationProvider method setVelocityManager.
@Inject
public void setVelocityManager(VelocityManager vm) {
LOG.trace("OSGi ConfigurationProvider - setVelocityManager() called - VelocityManager: [{}]", vm);
Properties props = new Properties();
props.setProperty("osgi.resource.loader.description", "OSGI bundle loader");
props.setProperty("osgi.resource.loader.class", VelocityBundleResourceLoader.class.getName());
props.setProperty(Velocity.RESOURCE_LOADER, "strutsfile,strutsclass,osgi");
vm.setVelocityProperties(props);
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class Dispatcher method init_CustomConfigurationProviders.
private void init_CustomConfigurationProviders() {
String configProvs = initParams.get("configProviders");
if (configProvs != null) {
String[] classes = configProvs.split("\\s*[,]\\s*");
for (String cname : classes) {
try {
Class cls = ClassLoaderUtil.loadClass(cname, this.getClass());
ConfigurationProvider prov = (ConfigurationProvider) cls.newInstance();
if (prov instanceof ServletContextAwareConfigurationProvider) {
((ServletContextAwareConfigurationProvider) prov).initWithContext(servletContext);
}
configurationManager.addContainerProvider(prov);
} catch (InstantiationException e) {
throw new ConfigurationException("Unable to instantiate provider: " + cname, e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Unable to access provider: " + cname, e);
} catch (ClassNotFoundException e) {
throw new ConfigurationException("Unable to locate provider class: " + cname, e);
}
}
}
}
Aggregations