#3 Unable to test chained actions

open
nobody
None
5
2003-08-27
2003-08-27
Matt Stine
No

I am using the command pattern in a web application for
online ordering. Each command sent to the Servlet is
delegated to a command handler.

Currently I have a passing unit test for a
SaveOrderHandler and an EditOrderHandler. What I
want to do is chain these two actions together, so that
a user can save an order they are currently working on
and then edit another one w/ only one click.

To do this, I have written a test for a command handler
called SaveThenEditOrderHandler...what it does is call
the SaveOrderHandler, check a request attribute to see
if the save succeeded, and then calls EditOrderHandler.

These two requests share some common request/session
parameters/attributes. The behavior that I am seeing is
that the first command handler executes successfully.
Open entering the second command handler, any
attempt to access request/session
parameters/attributes that is shares with the first
handler fail with a message such as:

junit.framework.AssertionFailedError:
parameters.orderType has run out of objects.

If I am reading this correctly, any objects stored in the
request/session objects can must be accessed once and
only once. Is this true? And if so, is there another way
to implement this test?

Thanks!

Discussion