Methods Summary |
---|
protected com.opensymphony.xwork2.ActionProxy | buildProxy(java.lang.String actionName)
return actionProxyFactory.createActionProxy("", actionName, extraContext, true, true);
|
protected java.lang.String | getActionName()
return TestConfigurationProvider.TOKEN_ACTION_NAME;
|
protected java.lang.String | setToken(javax.servlet.http.HttpServletRequest request)
String token = TokenHelper.setToken();
setToken(token);
return token;
|
protected void | setToken(java.lang.String token)
request.getParameterMap().put(TokenHelper.TOKEN_NAME_FIELD, new String[]{
TokenHelper.DEFAULT_TOKEN_NAME
});
request.getParameterMap().put(TokenHelper.DEFAULT_TOKEN_NAME, new String[]{
token
});
|
protected void | setUp()
loadConfigurationProviders(new TestConfigurationProvider());
session = new HashMap();
params = new HashMap();
extraContext = new HashMap();
extraContext.put(ActionContext.SESSION, session);
extraContext.put(ActionContext.PARAMETERS, params);
request = new StrutsMockHttpServletRequest();
httpSession = new StrutsMockHttpSession();
request.setSession(httpSession);
request.setParameterMap(params);
extraContext.put(ServletActionContext.HTTP_REQUEST, request);
ValueStack stack = ValueStackFactory.getFactory().createValueStack();
stack.getContext().putAll(extraContext);
oldContext = new ActionContext(stack.getContext());
ActionContext.setContext(oldContext);
|
protected void | tearDown()
configurationManager.destroyConfiguration();
ActionContext.setContext(null);
|
public void | testCAllExecute2Times()
ActionProxy proxy = buildProxy(getActionName());
setToken(request);
assertEquals(Action.SUCCESS, proxy.execute());
ActionProxy proxy2 = buildProxy(getActionName());
// must not call setToken
// double post will result in a invalid.token return code
assertEquals(TokenInterceptor.INVALID_TOKEN_CODE, proxy2.execute());
|
public void | testNoTokenInParams()
ActionProxy proxy = buildProxy(getActionName());
assertEquals(TokenInterceptor.INVALID_TOKEN_CODE, proxy.execute());
|
public void | testNoTokenInSession()
assertEquals(oldContext, ActionContext.getContext());
ActionProxy proxy = buildProxy(getActionName());
setToken(request);
ActionContext.getContext().getSession().clear();
assertEquals(TokenInterceptor.INVALID_TOKEN_CODE, proxy.execute());
|
public void | testTokenInterceptorSuccess()
ActionProxy proxy = buildProxy(getActionName());
setToken(request);
assertEquals(Action.SUCCESS, proxy.execute());
|