James,
I could only find "LogRecordFilter" and "Filter" classes, and no unit test
classes in the source. But I have resolved this issue as follows:
public void testdecide() {
Logger logger = Logger
.getLogger("com.webmethods.sc.logging.test.unit.WmLoggerFilterTes");
WmLoggerFilter subjectWmLoggerFilter = new WmLoggerFilter();
//MessageRenderer mr = new MessageRenderer();
Throwable e = new Throwable("exception");
assertEquals(Filter.DENY,
subjectWmLoggerFilter.decide(null));
assertEquals(
Filter.NEUTRAL,
subjectWmLoggerFilter
.decide(createEvent("com.webmethods.sc.logging.test.unit.WmLoggerFilterTes")
));
System.out.println(Filter.DENY);
System.out.println(subjectWmLoggerFilter.decide(null));
System.out.println(Filter.NEUTRAL);
assertEquals(Filter.NEUTRAL, 0);
/* LoggingEvent(String fqnOfCategoryClass, Category logger,
* Priority level, Object message, Throwable throwable)
*/
/*LoggingEvent le = new LoggingEvent(
"com.webmethods.sc.logging.test.unit.WmLoggerFilterTest",
logger, Level.DEBUG, mr, e);
*/
LoggingEvent le = new LoggingEvent(
"com.webmethods.sc.logging.test.unit.WmLoggerFilterTest",
logger, Level.DEBUG, "test", e);
assertEquals(Filter.NEUTRAL,
subjectWmLoggerFilter.decide(le));
System.out.println(subjectWmLoggerFilter.decide(le));
}
Thanks,
-Kamal.
-----Original Message-----
From: James Stauffer [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 02, 2006 5:15 PM
To: Log4J Users List
Subject: Re: unit test decide(LoggingEvent inEvent)
Get the source for log4j and you will find there are some filters included.
On 2/2/06, Kamal Ahmed <[EMAIL PROTECTED]> wrote:
> 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]
>
>
--
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]