logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamal Ahmed <KAh...@webMethods.com>
Subject unit test decide(LoggingEvent inEvent)
Date Wed, 01 Feb 2006 15:33:49 GMT
Could you please give me some CLUE, on how to proceed to test the following
    public int decide(LoggingEvent inEvent) {

            boolean retCode = false;

            if (inEvent != null) {

                Matcher matcher =

                retCode = (matcher.find() == acceptMatch);


            return (retCode) ? Filter.NEUTRAL : Filter.DENY;


Now i need to write a junit test for this, but I am not sure WHERE to start?

1. Should i create a NEW instance of the class this method belongs to? 

2. How do i get an "inEvent" of type LoggingEvent?

3. So this is how i have started writing test case for the method, decide(),
based on:

The General form of Junit test follows the following steps:

1. Create an object and put it in a known state
2. Invoke a method which returns the "actual result"
3. Create the "expected result" which may be a primitive value or a more
complex object.
4. Invoke "assertEquals(expectedResult,actualResult)

    public int testdecide() {
                   int result=0;

                   // WmLoggerFilter subjectWmLoggerFilter = new

                   return result;
Since WmLoggerFilter is the class that contains testdecide()
I would appreciate any help.


To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message