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

LayoutTest

public class LayoutTest extends TestCase
Tests for Layout.

Fields Summary
private final String
contentType
Expected content type.
private final boolean
ignoresThrowable
Expected value for ignoresThrowable.
private final String
header
Expected value for header.
private final String
footer
Expected value for footer.
Constructors Summary
public LayoutTest(String testName)
Construct a new instance of LayoutTest.

param
testName test name.

    super(testName);
    contentType = "text/plain";
    ignoresThrowable = true;
    header = null;
    footer = null;
  
protected LayoutTest(String testName, String expectedContentType, boolean expectedIgnoresThrowable, String expectedHeader, String expectedFooter)
Constructor for use by derived tests.

param
testName name of test.
param
expectedContentType expected value for getContentType().
param
expectedIgnoresThrowable expected value for ignoresThrowable().
param
expectedHeader expected value for getHeader().
param
expectedFooter expected value for getFooter().

    super(testName);
    contentType = expectedContentType;
    ignoresThrowable = expectedIgnoresThrowable;
    header = expectedHeader;
    footer = expectedFooter;
  
Methods Summary
protected org.apache.log4j.LayoutcreateLayout()
Creates layout for test.

return
new instance of Layout.

    return new MockLayout();
  
public voidtestFormat()
Tests format.

throws
Exception derived tests, particular XMLLayoutTest, may throw exceptions.

    Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest");
    LoggingEvent event =
      new LoggingEvent(
        "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
    String result = createLayout().format(event);
    assertEquals("Mock", result);
  
public voidtestGetContentType()
Tests getContentType.

    assertEquals(contentType, createLayout().getContentType());
  
public voidtestGetFooter()
Tests getFooter.

    assertEquals(footer, createLayout().getFooter());
  
public voidtestGetHeader()
Tests getHeader.

    assertEquals(header, createLayout().getHeader());
  
public voidtestIgnoresThrowable()
Tests ignoresThrowable.

    assertEquals(ignoresThrowable, createLayout().ignoresThrowable());
  
public voidtestLineSep()
Tests Layout.LINE_SEP.

    assertEquals(System.getProperty("line.separator"), Layout.LINE_SEP);
  
public voidtestLineSepLen()
Tests Layout.LINE_SEP.

    assertEquals(Layout.LINE_SEP.length(), Layout.LINE_SEP_LEN);