use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class AliasInterceptorTest method testUsingDefaultInterceptorThatAliasPropertiesAreCopied.
public void testUsingDefaultInterceptorThatAliasPropertiesAreCopied() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("aliasSource", "source here");
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml");
container.inject(provider);
loadConfigurationProviders(provider);
ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", null, params);
SimpleAction actionOne = (SimpleAction) proxy.getAction();
actionOne.setAliasSource("name to be copied");
actionOne.setFoo(17);
actionOne.setBar(23);
proxy.execute();
assertEquals("name to be copied", actionOne.getAliasSource());
assertEquals(actionOne.getAliasSource(), actionOne.getAliasDest());
// WW-5087
assertNull(actionOne.getBlah());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class AliasInterceptorTest method testNotExisting.
public void testNotExisting() throws Exception {
Map<String, Object> params = new HashMap<>();
Map<String, Object> httpParams = new HashMap<>();
httpParams.put("notExisting", "from http parameter");
params.put(ActionContext.PARAMETERS, HttpParameters.create(httpParams).build());
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml");
container.inject(provider);
loadConfigurationProviders(provider);
ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", null, params);
SimpleAction actionOne = (SimpleAction) proxy.getAction();
// prevent ERROR result
actionOne.setFoo(-1);
actionOne.setBar(1);
proxy.execute();
assertEquals("from http parameter", actionOne.getBlah());
// WW-5087
assertNull(actionOne.getAliasDest());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class AliasInterceptorTest method testValueNotAccepted.
public void testValueNotAccepted() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("aliasSource", "source here");
Map<String, String> httpParams = new HashMap<>();
httpParams.put("name", "aliasSource");
httpParams.put("value", "[0].aliasDest");
params.put("parameters", HttpParameters.create(httpParams).build());
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml");
container.inject(provider);
loadConfigurationProviders(provider);
ActionProxy proxy = actionProxyFactory.createActionProxy("", "dynamicAliasTest", null, params);
SimpleAction actionOne = (SimpleAction) proxy.getAction();
actionOne.setAliasSource("name to be copied");
// prevent ERROR result
actionOne.setFoo(-1);
actionOne.setBar(1);
proxy.execute();
assertEquals("name to be copied", actionOne.getAliasSource());
assertNotEquals(actionOne.getAliasSource(), actionOne.getAliasDest());
proxy = actionProxyFactory.createActionProxy("", "dynamicAliasTest", null, params);
((AliasInterceptor) proxy.getConfig().getInterceptors().get(1).getInterceptor()).setExcludedPatterns(NO_EXCLUSION_PATTERNS_CHECKER);
((AliasInterceptor) proxy.getConfig().getInterceptors().get(1).getInterceptor()).setAcceptedPatterns(ACCEPT_ALL_PATTERNS_CHECKER);
actionOne = (SimpleAction) proxy.getAction();
actionOne.setAliasSource("name to be copied");
// prevent ERROR result
actionOne.setFoo(-1);
actionOne.setBar(1);
proxy.execute();
assertEquals("name to be copied", actionOne.getAliasSource());
assertEquals(actionOne.getAliasSource(), actionOne.getAliasDest());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ChainingInterceptorWithConfigTest method testTwoExcludesPropertiesChained.
public void testTwoExcludesPropertiesChained() throws Exception {
assertNotNull(objectFactory);
ActionProxy proxy = actionProxyFactory.createActionProxy("", CHAINED_ACTION, null, null);
SimpleAction chainedAction = (SimpleAction) proxy.getAction();
chainedAction.setBar(1);
chainedAction.setFoo(1);
chainedAction.setBlah("WW-4528");
proxy.execute();
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ConversionErrorInterceptorTest method testFieldErrorAdded.
public void testFieldErrorAdded() throws Exception {
conversionErrors.put("foo", new ConversionData(123L, int.class));
SimpleAction action = new SimpleAction();
mockInvocation.expectAndReturn("getAction", action);
stack.push(action);
mockInvocation.matchAndReturn("getAction", action);
assertNull(action.getFieldErrors().get("foo"));
interceptor.doIntercept(invocation);
assertTrue(action.hasFieldErrors());
assertNotNull(action.getFieldErrors().get("foo"));
}
Aggregations