You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Michels <st...@apache.org> on 2004/02/02 12:47:33 UTC
Re: Unit test: more usable AbstractCompositeTestCase (or
SitemapComponentTestCase)
> 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.