use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ActionAutowiringInterceptorTest method testSetAutowireType.
public void testSetAutowireType() throws Exception {
XmlConfigurationProvider prov = new StrutsXmlConfigurationProvider("xwork-default.xml");
container.inject(prov);
prov.setThrowExceptionOnDuplicateBeans(false);
XmlConfigurationProvider c = new StrutsXmlConfigurationProvider("com/opensymphony/xwork2/spring/xwork-autowire.xml");
container.inject(c);
loadConfigurationProviders(c, prov);
StaticWebApplicationContext appContext = new StaticWebApplicationContext();
loadSpringApplicationContextIntoApplication(appContext);
ActionAutowiringInterceptor interceptor = new ActionAutowiringInterceptor();
interceptor.init();
SimpleAction action = new SimpleAction();
ActionInvocation invocation = new TestActionInvocation(action);
interceptor.intercept(invocation);
ApplicationContext loadedContext = interceptor.getApplicationContext();
assertEquals(appContext, loadedContext);
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ActionAutowiringInterceptorTest method testIfApplicationContextIsNullThenBeanWillNotBeWiredUp.
public void testIfApplicationContextIsNullThenBeanWillNotBeWiredUp() throws Exception {
ActionContext.of(new HashMap<>()).withApplication(new HashMap<>()).bind();
ActionAutowiringInterceptor interceptor = new ActionAutowiringInterceptor();
interceptor.init();
SimpleAction action = new SimpleAction();
ActionInvocation invocation = new TestActionInvocation(action);
TestBean bean = action.getBean();
// If an exception is thrown here, things are going to go wrong in
// production
interceptor.intercept(invocation);
assertEquals(bean, action.getBean());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ActionsFromSpringTest method testLoadSimpleAction.
public void testLoadSimpleAction() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleAction", null, null);
Object action = proxy.getAction();
Action expected = (Action) appContext.getBean("simple-action");
assertEquals(expected.getClass(), action.getClass());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ActionsFromSpringTest method testLoadActionWithDependencies.
public void testLoadActionWithDependencies() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "dependencyAction", null, null);
SimpleAction action = (SimpleAction) proxy.getAction();
assertEquals("injected", action.getBlah());
}
use of com.opensymphony.xwork2.SimpleAction in project struts by apache.
the class ActionsFromSpringTest method testAutoProxiedAction.
public void testAutoProxiedAction() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "autoProxiedAction", null, null);
SimpleAction action = (SimpleAction) proxy.getAction();
String result = action.execute();
assertEquals(Action.INPUT, result);
}
Aggregations