use of com.opensymphony.xwork2.SimpleAction 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.SimpleAction in project struts by apache.
the class ChainResultTest method testNamespaceChain.
public void testNamespaceChain() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "chain_with_namespace", null, null);
((SimpleAction) proxy.getAction()).setBlah("%{foo}");
proxy.execute();
assertTrue(proxy.getInvocation().getResult() instanceof MockResult);
MockResult result = (MockResult) proxy.getInvocation().getResult();
assertEquals("%{foo}", result.getInvocation().getProxy().getNamespace());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class DefaultActionInvocationTester method testActionChainResult.
public void testActionChainResult() throws Exception {
ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "Foo", null, new HashMap<String, Object>());
DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation();
defaultActionInvocation.init(actionProxy);
SimpleAction action = (SimpleAction) defaultActionInvocation.getAction();
action.setFoo(1);
action.setBar(2);
defaultActionInvocation.invoke();
// then
assertTrue(defaultActionInvocation.result instanceof ActionChainResult);
Result result = defaultActionInvocation.getResult();
assertTrue(result instanceof MockResult);
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class DefaultActionInvocationTester method testActionEventListener.
public void testActionEventListener() throws Exception {
ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "ExceptionFoo", "exceptionMethod", new HashMap<String, Object>());
DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation();
SimpleActionEventListener actionEventListener = new SimpleActionEventListener("prepared", "exceptionHandled");
defaultActionInvocation.setActionEventListener(actionEventListener);
defaultActionInvocation.init(actionProxy);
SimpleAction action = (SimpleAction) defaultActionInvocation.getAction();
action.setThrowException(true);
defaultActionInvocation.unknownHandlerManager = new DefaultUnknownHandlerManager() {
@Override
public boolean hasUnknownHandlers() {
return false;
}
};
String result = defaultActionInvocation.invoke();
// then
assertEquals("prepared", action.getName());
assertEquals("exceptionHandled", result);
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class DefaultActionInvocationTester method testInvokingMissingMethod.
public void testInvokingMissingMethod() throws Exception {
// given
DefaultActionInvocation dai = new DefaultActionInvocation(ActionContext.getContext().getContextMap(), false);
container.inject(dai);
SimpleAction action = new SimpleAction() {
@Override
public String execute() throws Exception {
return ERROR;
}
};
MockActionProxy proxy = new MockActionProxy();
proxy.setMethod("notExists");
UnknownHandlerManager uhm = new DefaultUnknownHandlerManager() {
@Override
public boolean hasUnknownHandlers() {
return false;
}
};
dai.stack = container.getInstance(ValueStackFactory.class).createValueStack();
dai.proxy = proxy;
dai.ognlUtil = new OgnlUtil();
dai.unknownHandlerManager = uhm;
// when
Throwable actual = null;
try {
dai.invokeAction(action, null);
} catch (Exception e) {
actual = e;
}
// then
assertNotNull(actual);
assertTrue(actual instanceof NoSuchMethodException);
}
Aggregations