James, Unfortunately, I do not have any examples, let me know if you of any web site that has any, That would really help. Thanks, -Kamal.
-----Original Message----- From: James Stauffer [mailto:[EMAIL PROTECTED] Sent: Thursday, February 02, 2006 11:31 AM To: Log4J Users List Subject: Re: unit test decide(LoggingEvent inEvent) If you check the source code of the other filters do they have unit tests that would work as examples? On 2/1/06, Kamal Ahmed <[EMAIL PROTECTED]> wrote: > Hi, > Could you please give me some CLUE, on how to proceed to test the following > method: > public int decide(LoggingEvent inEvent) { > > boolean retCode = false; > > if (inEvent != null) { > > Matcher matcher = > targetPattern.matcher(inEvent.getLoggerName()); > > 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 > WmLoggerFilter(); > > return result; > } > Since WmLoggerFilter is the class that contains testdecide() > I would appreciate any help. > Thanks, > > -Kamal. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- James Stauffer Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
