use of com.opensymphony.xwork2.config.RuntimeConfiguration 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.RuntimeConfiguration in project struts by apache.
the class ConfigurationTest method testWildcardNamespace.
public void testWildcardNamespace() {
RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
ActionConfig config = configuration.getActionConfig("/animals/dog", "commandTest");
assertNotNull(config);
assertTrue("Wrong class name, " + config.getClassName(), "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName()));
Map<String, String> p = config.getParams();
assertTrue("Wrong parameter, " + p.get("0"), "/animals/dog".equals(p.get("0")));
assertTrue("Wrong parameter, " + p.get("1"), "dog".equals(p.get("1")));
}
use of com.opensymphony.xwork2.config.RuntimeConfiguration in project struts by apache.
the class ConventionUnknownHandlerTest method configuration.
private Configuration configuration(final String packageName) {
final Configuration mock = createNiceMock(Configuration.class);
packageConfiguration = packageConfiguration();
expect(mock.getPackageConfig(packageName)).andStubReturn(packageConfiguration);
RuntimeConfiguration runtime = createNiceMock(RuntimeConfiguration.class);
expect(runtime.getActionConfig("", "index")).andStubReturn(new ActionConfig.Builder("", "index", "").build());
expect(mock.getRuntimeConfiguration()).andStubReturn(runtime);
replay(mock, runtime);
return mock;
}
use of com.opensymphony.xwork2.config.RuntimeConfiguration in project struts by apache.
the class Form method isValidateAnnotatedMethodOnly.
private boolean isValidateAnnotatedMethodOnly(String actionName) {
RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
String actionNamespace = TagUtils.buildNamespace(actionMapper, stack, request);
ActionConfig actionConfig = runtimeConfiguration.getActionConfig(actionNamespace, actionName);
if (actionConfig != null) {
List<InterceptorMapping> interceptors = actionConfig.getInterceptors();
for (InterceptorMapping interceptorMapping : interceptors) {
if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
return validationInterceptor.isValidateAnnotatedMethodOnly();
}
}
}
return false;
}
use of com.opensymphony.xwork2.config.RuntimeConfiguration in project struts by apache.
the class ConfigurationTest method testWildcardName.
public void testWildcardName() {
RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
ActionConfig config = configuration.getActionConfig("", "WildCard/Simple/input");
assertNotNull(config);
assertTrue("Wrong class name, " + config.getClassName(), "com.opensymphony.xwork2.SimpleAction".equals(config.getClassName()));
assertTrue("Wrong method name", "input".equals(config.getMethodName()));
Map<String, String> p = config.getParams();
assertTrue("Wrong parameter, " + p.get("foo"), "Simple".equals(p.get("foo")));
assertTrue("Wrong parameter, " + p.get("bar"), "input".equals(p.get("bar")));
}
Aggregations