use of com.opensymphony.xwork2.interceptor.Interceptor in project struts by apache.
the class DefaultInterceptorMapBuilder method build.
protected List<InterceptorMapping> build(InterceptorRef[] interceptors, String actionName, PackageConfig.Builder builder) {
List<InterceptorMapping> interceptorList = new ArrayList<>(10);
for (InterceptorRef interceptor : interceptors) {
LOG.trace("Adding interceptor [{}] to [{}]", interceptor.value(), actionName);
Map<String, String> params = StringTools.createParameterMap(interceptor.params());
interceptorList.addAll(buildInterceptorList(builder, interceptor, params));
}
return interceptorList;
}
use of com.opensymphony.xwork2.interceptor.Interceptor in project struts by apache.
the class SpringObjectFactoryTest method testObtainInterceptorBySpringName.
public void testObtainInterceptorBySpringName() throws Exception {
sac.registerSingleton("noop-interceptor", NoOpInterceptor.class, new MutablePropertyValues());
InterceptorConfig iConfig = new InterceptorConfig.Builder("noop", "noop-interceptor").build();
Interceptor interceptor = objectFactory.buildInterceptor(iConfig, new HashMap<String, String>());
assertEquals(NoOpInterceptor.class, interceptor.getClass());
}
use of com.opensymphony.xwork2.interceptor.Interceptor in project struts by apache.
the class ActionAutowiringInterceptorTest method testShouldAutowireAction.
public void testShouldAutowireAction() throws Exception {
StaticWebApplicationContext context = new StaticWebApplicationContext();
context.getBeanFactory().registerSingleton("bean", new TestBean());
TestBean bean = (TestBean) context.getBean("bean");
loadSpringApplicationContextIntoApplication(context);
SimpleAction action = new SimpleAction();
ActionInvocation invocation = new TestActionInvocation(action);
ActionAutowiringInterceptor interceptor = new ActionAutowiringInterceptor();
interceptor.setApplicationContext(context);
interceptor.init();
interceptor.intercept(invocation);
assertEquals(bean, action.getBean());
}
use of com.opensymphony.xwork2.interceptor.Interceptor in project entando-core by entando.
the class TestCustomTokenInterceptor method testExecuteValidation_1.
public void testExecuteValidation_1() throws Exception {
ActionInvocation invocation = this.prepareAction();
CustomTokenInterceptor interceptor = new CustomTokenInterceptor();
String result = interceptor.intercept(invocation);
assertEquals(Action.SUCCESS, result);
String newResult = interceptor.intercept(invocation);
assertEquals(CustomTokenInterceptor.INVALID_TOKEN_CODE, newResult);
ActionSupport action = super.getAction();
assertEquals(0, action.getActionErrors().size());
assertEquals(0, action.getActionMessages().size());
}
use of com.opensymphony.xwork2.interceptor.Interceptor in project entando-core by entando.
the class TestCustomTokenInterceptor method testExecuteValidation_2.
public void testExecuteValidation_2() throws Exception {
ActionInvocation invocation = this.prepareAction();
CustomTokenInterceptor interceptor = new CustomTokenInterceptor();
interceptor.setTypeMessages(CustomTokenInterceptor.TYPE_RETURN_ACTION_ERROR_MESSAGE);
String result = interceptor.intercept(invocation);
assertEquals(Action.SUCCESS, result);
String newResult = interceptor.intercept(invocation);
assertEquals(CustomTokenInterceptor.INVALID_TOKEN_CODE, newResult);
ActionSupport action = super.getAction();
assertEquals(1, action.getActionErrors().size());
assertEquals(0, action.getActionMessages().size());
}
Aggregations