use of com.opensymphony.xwork2.util.Bar 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")));
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class ConfigurationTest method testMultipleConfigProviders.
public void testMultipleConfigProviders() {
configurationManager.addContainerProvider(new MockConfigurationProvider());
try {
configurationManager.reload();
} catch (ConfigurationException e) {
e.printStackTrace();
fail();
}
RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
// check that it has configuration from xml
assertNotNull(configuration.getActionConfig("/foo/bar", "Bar"));
// check that it has configuration from MockConfigurationProvider
assertNotNull(configuration.getActionConfig("", MockConfigurationProvider.FOO_ACTION_NAME));
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class ConfigurationTest method testMultipleContainerProviders.
public void testMultipleContainerProviders() throws Exception {
// to start from scratch
configurationManager.destroyConfiguration();
// to build basic configuration
configurationManager.getConfiguration();
Mock mockContainerProvider = new Mock(ContainerProvider.class);
mockContainerProvider.expect("init", C.ANY_ARGS);
mockContainerProvider.expect("register", C.ANY_ARGS);
mockContainerProvider.matchAndReturn("equals", C.ANY_ARGS, false);
mockContainerProvider.matchAndReturn("toString", "foo");
mockContainerProvider.matchAndReturn("destroy", null);
mockContainerProvider.expectAndReturn("needsReload", true);
// the order of providers must be changed as just first is checked if reload is needed
configurationManager.addContainerProvider((ContainerProvider) mockContainerProvider.proxy());
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml");
container.inject(provider);
configurationManager.addContainerProvider(provider);
Configuration config = null;
try {
config = configurationManager.getConfiguration();
} catch (ConfigurationException e) {
e.printStackTrace();
fail();
}
RuntimeConfiguration configuration = config.getRuntimeConfiguration();
// check that it has configuration from xml
assertNotNull(configuration.getActionConfig("/foo/bar", "Bar"));
mockContainerProvider.verify();
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class ConfigurationTest method testInterceptorParamInehritanceOverride.
public void testInterceptorParamInehritanceOverride() {
try {
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInehritanceOverride", null, null);
assertEquals(1, proxy.getConfig().getInterceptors().size());
MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
assertEquals("foo123", testInterceptor.getExpectedFoo());
proxy.execute();
assertTrue(testInterceptor.isExecuted());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class ActionConfigMatcherTest method testLooseMatch.
public void testLooseMatch() {
configMap.put("*!*", configMap.get("bar/*/**"));
ActionConfigMatcher matcher = new ActionConfigMatcher(new WildcardHelper(), configMap, true);
// exact match
ActionConfig m = matcher.match("foo/class/method");
assertNotNull("ActionConfig should be matched", m);
assertTrue("Class hasn't been replaced " + m.getClassName(), "foo.bar.classAction".equals(m.getClassName()));
assertTrue("Method hasn't been replaced", "domethod".equals(m.getMethodName()));
// Missing last wildcard
m = matcher.match("foo/class");
assertNotNull("ActionConfig should be matched", m);
assertTrue("Class hasn't been replaced", "foo.bar.classAction".equals(m.getClassName()));
assertTrue("Method hasn't been replaced, " + m.getMethodName(), "do".equals(m.getMethodName()));
// Simple mapping
m = matcher.match("class!method");
assertNotNull("ActionConfig should be matched", m);
assertTrue("Class hasn't been replaced, " + m.getPackageName(), "package-class".equals(m.getPackageName()));
assertTrue("Method hasn't been replaced", "method".equals(m.getParams().get("first")));
// Simple mapping
m = matcher.match("class");
assertNotNull("ActionConfig should be matched", m);
assertTrue("Class hasn't been replaced", "package-class".equals(m.getPackageName()));
assertTrue("Method hasn't been replaced", "".equals(m.getParams().get("first")));
}
Aggregations