Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

any integration of JUnit and Log4J?

Thread view: 
nospawn - 03 Feb 2006 15:40 GMT
Hi all,

I want to provide Test Cases for a validation and handling process.
The validation classes are just part of a chain process where if
the validation passes then it continues to the next "successor"
in the chain (of Responsibility -GoF) otherwise the validator stops
the process and does not forward the call but uses logging to file
the problem.

The only outcome of the validation classes is to:

- Write the issue into log.fatal(...) and does not forward the call.
- Forwards the call to the next successor.

Now I have two options to test the validation classes:

1-. Have the original class write some flags somewhere about the
   outcome (nasty and original code intrusive solution).

2-. Have some logging scan facility .... is there any kind of
   integration between Log4J and JUnit to achieve this?

TIA,
Best Regards,
Giovanni
James Westby - 03 Feb 2006 16:02 GMT
> Hi all,
>
[quoted text clipped - 17 lines]
> 2-. Have some logging scan facility .... is there any kind of
>     integration between Log4J and JUnit to achieve this?

Could you write a custom logger that makes a callback to the junit test
case with any logged messages, allowing you to determine if anything
happened? As for success it sounds like mock objects might help. Come to
think of it a mock logger might work quite nicely as well.

James
Giovanni Azua - 03 Feb 2006 19:39 GMT
Hi James,

Many thanks for your response!

> Could you write a custom logger that makes a callback to the junit test
> case with any logged messages, allowing you to determine if anything
> happened? As for success it sounds like mock objects might help. Come to
> think of it a mock logger might work quite nicely as well.

That is a great idea :)

But trying could not setup a custom Appender or even Logger actually
Appender is better for me because my Test class already inherits from
TestCase so I had it implement Appender ... it does not work ... any
hints as to where find an example?

Many thanks!
Best Regards,
Giovanni


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.