cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Michels <step...@apache.org>
Subject Re: Unit test: more usable AbstractCompositeTestCase (or SitemapComponentTestCase)
Date Mon, 02 Feb 2004 11:47:33 GMT

> public final Map act(String type, String source, Parameters parameters)
>         throws AbstractCompositeTestException {
>
>         if (resolver == null) {
>             throw new AbstractCompositeTestException("Lookup of source
>                 resolver failed");
>         }
> }

You don't need to extra "AbstractCompositeTestException" since the asserts
throw a RuntimeException, which must not be catched.

>     public void testWrongParams() {
>         try {
>             Parameters params = new Parameters();
>             Map map = super.act("my-action", null, params);
>             fail("Action should throw exception");
>         } catch (AbstractCompositeTestException e) {
>             if (e.getCause() instanceof FooException) {
>                 // ok - expected behaviour
>             } else {
>                 e.printStackTrace();
>                 fail(e.getMessage());
>             }
>         }
>     }

I can change the catch block so that every Exception will be rethrown
except the ComponentException

> The questions are:
>
> 0. Is it a good idea to make this changes?

Of course.

> 1. In which versions of cocoon should it be made?
>
> 2. Should I provide some patches? (It would be easier to someone who has
> cvs access)
>
> Note: The class AbstractCompositeTestCase above is from latest CVS in
> Cocoon 2.2 branch. Code in this post wasn't tested, it even hasn't been
> compiled.

I havn't updated the class in the cocoon-2.2 repository.

Stephan.


Mime
View raw message