use of com.opensymphony.xwork2.Result in project struts by apache.
the class PrepareInterceptorTest method testPrefixInvocation1.
public void testPrefixInvocation1() throws Exception {
ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("submit");
ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
expect(mockActionInvocation.invoke()).andStubReturn("okok");
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
mockAction.prepareSubmit();
expectLastCall().times(1);
mockAction.prepare();
expectLastCall().times(1);
replay(mockAction, mockActionProxy, mockActionInvocation);
PrepareInterceptor interceptor = new PrepareInterceptor();
String result = interceptor.intercept(mockActionInvocation);
assertEquals("okok", result);
verify(mockAction, mockActionProxy, mockActionInvocation);
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class ValidationInterceptorPrefixMethodInvocationTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
ActionConfig config = new ActionConfig.Builder("", "action", "").build();
invocation = EasyMock.createNiceMock(ActionInvocation.class);
ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
ValidateAction action = EasyMock.createNiceMock(ValidateAction.class);
EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
EasyMock.expect(invocation.getAction()).andReturn(action).anyTimes();
EasyMock.expect(invocation.invoke()).andAnswer(() -> result).anyTimes();
EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
EasyMock.expect(proxy.getMethod()).andAnswer(() -> method).anyTimes();
EasyMock.replay(invocation);
EasyMock.replay(action);
EasyMock.replay(proxy);
ActionContext.of(new HashMap<>()).withActionInvocation(invocation).bind();
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class ValidationInterceptorPrefixMethodInvocationTest method testPrefixMethodInvocation2.
public void testPrefixMethodInvocation2() throws Exception {
method = "save";
result = "okok";
ValidationInterceptor interceptor = create();
String result = interceptor.intercept(invocation);
assertEquals("okok", result);
}
use of com.opensymphony.xwork2.Result in project struts by apache.
the class AliasInterceptorTest method testNameNotAccepted.
public void testNameNotAccepted() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("aliasSource", "source here");
Map<String, String> httpParams = new HashMap<>();
httpParams.put("name", "getAliasSource()");
httpParams.put("value", "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.Result in project struts by apache.
the class DefaultWorkflowInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
ActionConfig config = new ActionConfig.Builder("", "name", "").build();
Action action = EasyMock.createNiceMock(ValidateAction.class);
invocation = EasyMock.createNiceMock(ActionInvocation.class);
interceptor = new DefaultWorkflowInterceptor();
ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
EasyMock.expect(invocation.getAction()).andReturn(action).anyTimes();
EasyMock.expect(invocation.invoke()).andAnswer(() -> result).anyTimes();
EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
EasyMock.replay(invocation);
EasyMock.replay(action);
EasyMock.replay(proxy);
ActionContext.of(new HashMap<>()).withActionInvocation(invocation).bind();
}
Aggregations