|
From: SADER, K. D (Contractor) <KEI...@DF...> - 2003-08-12 16:50:39
|
Greetings.
I've got the following test case:
//Hand waving declarations...
Mock request;
Mock response;
Mock session;
protected void setUp() throws Exception
{
action =3D new MyAction();// Struts based action...
mapping =3D new ActionMapping();// More struts...
form =3D new DynaActionForm();// Isn't struts grand?
request =3D new Mock(HttpServletRequest.class);
response =3D new Mock(HttpServletResponse.class);
session =3D new Mock(HttpSession.class);
request.expectAndReturn("getSession", session);
}
public void testSessionIsInRequest() throws Exception
{
ActionForward expected =3D new ActionForward("success", "path", =
false);
ActionForward actual =3D action.doExecute(mapping, form,
(HttpServletRequest)request.proxy(), =
(HttpServletResponse)response.proxy());
assertEquals(expected.getName(), actual.getName());
request.verify();
response.verify();
session.verify();
}
// Code under test...
public ActionForwad doExecute(ActionMapping mapping, ActionForm form, =
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
HttpSession sess =3D request.getSession();
return mapping.findForward("success");
}
The problem I'm having is that the code in doExecute throws a =
ClassCastException on request.
java.lang.ClassCastException: com.mockobjects.dynamic.Mock
at $Proxy24.getSession()(Unknown Source)
...doExecute()
...testSessionIsInRequest()
What am I doing wrong here? By my interpretation of the examples this =
code *should* work.
What am I missing?
thanks,
---
Keith Sader
Nash Resources Group sub-contracting for Computer Sciences Corporation
IAD:TFAS
Email:kei...@df...
We've got a blind date with destiny, and it looks like she ordered the =
lobster.
|