Hi,
I am using log4j 1.3.8, testing DailyFileAppender which extends
FileAppender.
Now while testing the method DailyFileAppenderDafaultConstructor, I see the
functionality provided by WriterAppender (see below)
WriterAppender:
protected
boolean checkEntryConditions() {
if(this.closed) {
LogLog.warn("Not allowed to write to a closed appender.");
return false;
}
Does not seem to be working:
Here is my test method:
public void testWmDailyFileAppenderDafaultConstructor() throws Exception {
wmDfa = new WmDailyFileAppender();
assertNotNull("Default Constructor Not Null", wmDfa);
// System.out.println(wmDfa.getDatePattern());
assertEquals("'.'yyyy-MM-dd", wmDfa.getDatePattern());
// this test checks whether it is possible to write to a
closed
// WmDailyFileAppender
wmDfa.setName("testWmDailyFileAppenderDafaultConstructorAppender");
try {
logger.debug("m1");
//wmDfa.close();
logger.debug("m2");
System.out.println("one");
} catch (Exception expected) {
System.out.println("two");
assertTrue(true);
}
}
Ran the class in debug mode, and it passes the statement logger.debug("m2");
, it seems wmDfa.close(); does not really close the Appender.
And it IS printing :
System.out.println("one");