On Wed, 2003-10-01 at 12:24, Craig R. McClanahan wrote:
> __matthewHawthorne wrote:
>
> > One trick that may work is to call Digester.setLogger() with your own
> > org.apache.commons.logging.Log implementation that does nothing.
> >
> > Or you can use org.apache.commons.logging.impl.NoOpLog, which does the
> > same thing.
>
> Another approach would be to modify the build.xml file so that it
> deliberately selects the SimpleLog logger implementation, and configures
> it for error-level output only. This can easily be done by passing
> <sysproperty> elements inside the <java> elements that fire each test.
>
> I'd certainly be interested in a patch to make this sort of behavior
> permanent; I agree that the deliberately induced messages can be
> misleading/annoying.
Thanks, Matthew.
I added this for all the tests where I expect an exception to be thrown.
Works like a charm..
try {
Log oldLog = digester.getLogger();
digester.setLogger(new NoOpLog());
digester.parse(
TestAll.getInputStream(this, "test2.xml"));
digester.setLogger(oldLog);
}
catch(Exception e) {
// yay - exception was correctly generated
// ....
}
[In fact, restoring the old logger is probably unnecessary].
Pesonally I think this is a better approach than totally disabling all
log output, because when a test which is not expected to throws an
exception actually does so, we *do* get useful logging output.
Disabling all logging below "error" isn't adequate in this case, because
the test is *deliberately* triggering an error, to check that the
digester code correctly handles user misconfiguration by reporting an
error [rather than continuing to run with bad configuration].
If it's ok with everyone, I will submit a patch to existing tests which
deliberately throw exceptions to treat them as above.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]