FileDocCategorySizeDatePackage
FileAppenderTest.javaAPI DocApache log4j 1.2.152601Sat Aug 25 00:09:34 BST 2007org.apache.log4j

FileAppenderTest

public class FileAppenderTest extends TestCase
FileAppender tests.
author
Curt Arnold

Fields Summary
Constructors Summary
Methods Summary
public voidtestDirectoryCreation()
Tests that any necessary directories are attempted to be created if they don't exist. See bug 9150.

    //
    //   known to fail on JDK 1.1
    if (!System.getProperty("java.version").startsWith("1.1.")) {
      File newFile = new File("output/newdir/temp.log");
      newFile.delete();

      File newDir = new File("output/newdir");
      newDir.delete();

      org.apache.log4j.FileAppender wa = new org.apache.log4j.FileAppender();
      wa.setFile("output/newdir/temp.log");
      wa.setLayout(new PatternLayout("%m%n"));
      wa.activateOptions();

      assertTrue(new File("output/newdir/temp.log").exists());
    }
  
public voidtestGetThresholdReturnType()
Tests that the return type of getThreshold is Priority.

throws
Exception

    Method method = FileAppender.class.getMethod("getThreshold", (Class[]) null);
    assertTrue(method.getReturnType() == Priority.class);
  
public voidtestIsAsSevereAsThreshold()
Tests isAsSevereAsThreshold.

    FileAppender appender = new FileAppender();
    Priority debug = Level.DEBUG;
    assertTrue(appender.isAsSevereAsThreshold(debug));
  
public voidtestgetSetThreshold()
Tests getThreshold and setThreshold.

    FileAppender appender = new FileAppender();
    Priority debug = Level.DEBUG;
    Priority all = Level.ALL;
    assertNull(appender.getThreshold());
    appender.setThreshold(debug);
    assertTrue(appender.getThreshold() == debug);