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

TTCCLayoutTest

public class TTCCLayoutTest extends org.apache.log4j.helpers.DateLayoutTest
Test for TTCCLayout.
author
Curt Arnold

Fields Summary
Constructors Summary
public TTCCLayoutTest(String testName)
Construct new instance of TTCCLayoutTest.

param
testName test name.

    super(testName, "text/plain", true, null, null);
  
Methods Summary
protected org.apache.log4j.LayoutcreateLayout()

{inheritDoc}

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

    NDC.clear();
    NDC.push("NDC goes here");

    Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest");
    LoggingEvent event =
      new LoggingEvent(
        "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
    TTCCLayout layout = (TTCCLayout) createLayout();
    String result = layout.format(event);
    NDC.pop();

    StringBuffer buf = new StringBuffer(100);
    layout.dateFormat(buf, event);
    buf.append('[");
    buf.append(event.getThreadName());
    buf.append("] ");
    buf.append(event.getLevel().toString());
    buf.append(' ");
    buf.append(event.getLoggerName());
    buf.append(' ");
    buf.append("NDC goes here");
    buf.append(" - ");
    buf.append(event.getMessage());
    buf.append(System.getProperty("line.separator"));
    assertEquals(buf.toString(), result);
  
public voidtestGetSetCategoryPrefixing()
Tests getCategoryPrefixing and setCategoryPrefixing.

    TTCCLayout layout = new TTCCLayout();
    assertEquals(true, layout.getCategoryPrefixing());
    layout.setCategoryPrefixing(false);
    assertEquals(false, layout.getCategoryPrefixing());
    layout.setCategoryPrefixing(true);
    assertEquals(true, layout.getCategoryPrefixing());
  
public voidtestGetSetContextPrinting()
Tests getContextPrinting and setContextPrinting.

    TTCCLayout layout = new TTCCLayout();
    assertEquals(true, layout.getContextPrinting());
    layout.setContextPrinting(false);
    assertEquals(false, layout.getContextPrinting());
    layout.setContextPrinting(true);
    assertEquals(true, layout.getContextPrinting());
  
public voidtestGetSetThreadPrinting()
Tests getThreadPrinting and setThreadPrinting.

    TTCCLayout layout = new TTCCLayout();
    assertEquals(true, layout.getThreadPrinting());
    layout.setThreadPrinting(false);
    assertEquals(false, layout.getThreadPrinting());
    layout.setThreadPrinting(true);
    assertEquals(true, layout.getThreadPrinting());