You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Johan Lindquist <jo...@kawoo.co.uk> on 2003/10/02 09:35:40 UTC

[HiveMind] Testing Interceptors ...

A general question:  What do you all consider best practices for testing 
interceptors?  Currently involves a lot of manual testing, but would like 
to move to junit testing for it.

Johan

-- 
you too?

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


RE: [HiveMind] Testing Interceptors ...

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
The framework jar includes a base class for tests with many utility methods.

You can read a module descriptor and convert it into a registry.  Create a test service and extend
the implemention with the interceptor.

Invoke the methods of the service to see if the interceptor does its job.

For example, imagine a transaction interceptor, that starts, commits and rollsback transactions
around service methods.

You should abstract out the transaction start, commit and rollback into a service and provide a mock
implementation of the transaction service that simply
logs what it would have done.

You can then invoke service methods of the test interface to ensure that the interceptor invokes the
supporting service (the transaction service) properly.

You may not be able to get full coverage of the actual transaction service itself outside of
integration testing, since it will likely require an actual application server to be running.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Johan Lindquist [mailto:johan@kawoo.co.uk] 
> Sent: Thursday, October 02, 2003 3:36 AM
> To: Jakarta Commons Developers List
> Subject: [HiveMind] Testing Interceptors ...
> 
> 
> A general question:  What do you all consider best practices 
> for testing 
> interceptors?  Currently involves a lot of manual testing, 
> but would like 
> to move to junit testing for it.
> 
> Johan
> 
> -- 
> you too?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org