FileDocCategorySizeDatePackage
InvocationSessionStoreTest.javaAPI DocExample3535Mon Jul 23 13:26:26 BST 2007org.apache.struts2.util

InvocationSessionStoreTest

public class InvocationSessionStoreTest extends org.apache.struts2.StrutsTestCase
InvocationSessionStoreTest

Fields Summary
private static final String
INVOCATION_KEY
private static final String
TOKEN_VALUE
private com.opensymphony.xwork2.ActionInvocation
invocation
private Map
session
private com.mockobjects.dynamic.Mock
invocationMock
private com.opensymphony.xwork2.util.ValueStack
stack
Constructors Summary
Methods Summary
protected voidsetUp()

        stack = ValueStackFactory.getFactory().createValueStack();

        ActionContext actionContext = new ActionContext(stack.getContext());
        ActionContext.setContext(actionContext);

        session = new HashMap();
        actionContext.setSession(session);

        invocationMock = new Mock(ActionInvocation.class);
        invocation = (ActionInvocation) invocationMock.proxy();

        actionContext.setValueStack(stack);
        invocationMock.matchAndReturn("getStack", stack);

        Mock proxyMock = new Mock(ActionProxy.class);
        proxyMock.matchAndReturn("getInvocation", invocation);

        ActionProxy proxy = (ActionProxy) proxyMock.proxy();

        invocationMock.matchAndReturn("getProxy", proxy);
    
public voidtestStore()



       
        assertNull(InvocationSessionStore.loadInvocation(INVOCATION_KEY, TOKEN_VALUE));
        InvocationSessionStore.storeInvocation(INVOCATION_KEY, TOKEN_VALUE, invocation);
        assertNotNull(InvocationSessionStore.loadInvocation(INVOCATION_KEY, TOKEN_VALUE));
        assertEquals(invocation, InvocationSessionStore.loadInvocation(INVOCATION_KEY, TOKEN_VALUE));
    
public voidtestValueStackReset()

        ActionContext actionContext = ActionContext.getContext();
        assertEquals(stack, actionContext.getValueStack());
        InvocationSessionStore.storeInvocation(INVOCATION_KEY, TOKEN_VALUE, invocation);
        actionContext.setValueStack(null);
        assertNull(actionContext.getValueStack());
        InvocationSessionStore.loadInvocation(INVOCATION_KEY, TOKEN_VALUE);
        assertEquals(stack, actionContext.getValueStack());