use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderInterceptorsTest method testInterceptorInheritance.
public void testInterceptorInheritance() throws ConfigurationException {
// expectations - the inherited interceptor stack
InterceptorStackConfig inheritedStack = new InterceptorStackConfig.Builder("subDefaultStack").addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap<String, String>()))).build();
ConfigurationProvider provider = buildConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-inheritance.xml");
// assertions
PackageConfig defaultPkg = configuration.getPackageConfig("default");
assertEquals(2, defaultPkg.getInterceptorConfigs().size());
PackageConfig subPkg = configuration.getPackageConfig("subPackage");
assertEquals(1, subPkg.getInterceptorConfigs().size());
assertEquals(3, subPkg.getAllInterceptorConfigs().size());
assertEquals(inheritedStack, subPkg.getInterceptorConfigs().get("subDefaultStack"));
// expectations - the inherited interceptor stack
inheritedStack = new InterceptorStackConfig.Builder("subSubDefaultStack").addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap<String, String>()))).addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap<String, String>()))).build();
PackageConfig subSubPkg = configuration.getPackageConfig("subSubPackage");
assertEquals(1, subSubPkg.getInterceptorConfigs().size());
assertEquals(4, subSubPkg.getAllInterceptorConfigs().size());
assertEquals(inheritedStack, subSubPkg.getInterceptorConfigs().get("subSubDefaultStack"));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderPackagesTest method testBadInheritance.
public void testBadInheritance() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-bad-inheritance.xml";
ConfigurationProvider provider = null;
try {
provider = buildConfigurationProvider(filename);
fail("Should have thrown a ConfigurationException");
provider.init(configuration);
provider.loadPackages();
} catch (ConfigurationException e) {
// Expected
}
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderPackagesTest method testDefaultClassRef.
public void testDefaultClassRef() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-defaultclassref-package.xml";
final String hasDefaultClassRefPkgName = "hasDefaultClassRef";
final String noDefaultClassRefPkgName = "noDefaultClassRef";
final String testDefaultClassRef = "com.opensymphony.xwork2.ActionSupport";
ConfigurationProvider provider = buildConfigurationProvider(filename);
provider.init(configuration);
// setup our expectations
PackageConfig expectedDefaultClassRefPackage = new PackageConfig.Builder(hasDefaultClassRefPkgName).defaultClassRef(testDefaultClassRef).build();
PackageConfig expectedNoDefaultClassRefPackage = new PackageConfig.Builder(noDefaultClassRefPkgName).build();
// test expectations
assertEquals(2, configuration.getPackageConfigs().size());
assertEquals(expectedDefaultClassRefPackage, configuration.getPackageConfig(hasDefaultClassRefPkgName));
assertEquals(expectedNoDefaultClassRefPackage, configuration.getPackageConfig(noDefaultClassRefPkgName));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class XmlConfigurationProviderPackagesTest method testBasicPackages.
public void testBasicPackages() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-basic-packages.xml";
ConfigurationProvider provider = buildConfigurationProvider(filename);
provider.init(configuration);
provider.loadPackages();
// setup our expectations
PackageConfig expectedNamespacePackage = new PackageConfig.Builder("namespacepkg").namespace("/namespace/set").isAbstract(false).build();
PackageConfig expectedAbstractPackage = new PackageConfig.Builder("abstractpkg").isAbstract(true).build();
// test expectations
assertEquals(3, configuration.getPackageConfigs().size());
assertEquals(expectedNamespacePackage, configuration.getPackageConfig("namespacepkg"));
assertEquals(expectedAbstractPackage, configuration.getPackageConfig("abstractpkg"));
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class ConfigurationTestBase method buildConfigurationProvider.
protected ConfigurationProvider buildConfigurationProvider(final String filename) {
configuration = new MockConfiguration();
((MockConfiguration) configuration).selfRegister();
container = configuration.getContainer();
XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider(filename);
container.inject(prov);
prov.init(configuration);
prov.loadPackages();
return prov;
}
Aggregations