Search in sources :

Example 6 with IsEqual

use of com.mockobjects.constraint.IsEqual in project struts by apache.

the class SessionMapTest method testPutObjectOnSessionMapUsesWrappedSessionsSetsAttributeWithStringValue.

public void testPutObjectOnSessionMapUsesWrappedSessionsSetsAttributeWithStringValue() throws Exception {
    Object key = new Object();
    Object value = new Object();
    sessionMock.expect("getAttribute", new Constraint[] { new IsAnything() });
    sessionMock.expect("setAttribute", new Constraint[] { new IsEqual(key.toString()), new IsEqual(value) });
    SessionMap sessionMap = new SessionMap((HttpServletRequest) requestMock.proxy());
    sessionMap.put(key, value);
    sessionMock.verify();
}
Also used : IsAnything(com.mockobjects.constraint.IsAnything) IsEqual(com.mockobjects.constraint.IsEqual)

Example 7 with IsEqual

use of com.mockobjects.constraint.IsEqual in project struts by apache.

the class SessionMapTest method testGetObjectOnSessionMapUsesWrappedSessionsGetAttributeWithStringValue.

public void testGetObjectOnSessionMapUsesWrappedSessionsGetAttributeWithStringValue() throws Exception {
    Object key = new Object();
    Object value = new Object();
    sessionMock.expectAndReturn("getAttribute", new Constraint[] { new IsEqual(key.toString()) }, value);
    SessionMap sessionMap = new SessionMap((HttpServletRequest) requestMock.proxy());
    assertEquals("Expected the get using KEY to return the value object setup in the mockSession", value, sessionMap.get(key));
    sessionMock.verify();
}
Also used : IsEqual(com.mockobjects.constraint.IsEqual)

Example 8 with IsEqual

use of com.mockobjects.constraint.IsEqual in project struts by apache.

the class SessionMapTest method testPutOnSessionMapUsesWrappedSessionsSetsAttribute.

public void testPutOnSessionMapUsesWrappedSessionsSetsAttribute() throws Exception {
    Object value = new Object();
    sessionMock.expect("getAttribute", new Constraint[] { new IsAnything() });
    sessionMock.expect("setAttribute", new Constraint[] { new IsEqual("KEY"), new IsEqual(value) });
    SessionMap sessionMap = new SessionMap((HttpServletRequest) requestMock.proxy());
    sessionMap.put("KEY", value);
    sessionMock.verify();
}
Also used : IsAnything(com.mockobjects.constraint.IsAnything) IsEqual(com.mockobjects.constraint.IsEqual)

Example 9 with IsEqual

use of com.mockobjects.constraint.IsEqual in project struts by apache.

the class SessionMapTest method testGetOnSessionMapUsesWrappedSessionsGetAttribute.

public void testGetOnSessionMapUsesWrappedSessionsGetAttribute() throws Exception {
    Object value = new Object();
    sessionMock.expectAndReturn("getAttribute", new Constraint[] { new IsEqual("KEY") }, value);
    SessionMap sessionMap = new SessionMap((HttpServletRequest) requestMock.proxy());
    assertEquals("Expected the get using KEY to return the value object setup in the mockSession", value, sessionMap.get("KEY"));
    sessionMock.verify();
}
Also used : IsEqual(com.mockobjects.constraint.IsEqual)

Aggregations

IsEqual (com.mockobjects.constraint.IsEqual)9 IsAnything (com.mockobjects.constraint.IsAnything)2 Mock (com.mockobjects.dynamic.Mock)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1