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

LevelTest

public class LevelTest extends TestCase
Tests of Level.
author
Curt Arnold
since
1.2.12

Fields Summary
Constructors Summary
public LevelTest(String name)
Constructs new instance of test.

param
name test name.

    super(name);
  
Methods Summary
public voidtestALL()
Tests Level.ALL.

      assertTrue(Level.ALL instanceof Level);
    
public voidtestCustomLevelSerialization()
Tests that a custom level can be serialized and deserialized and is not resolved to a stock level.

throws
Exception if exception during test.

    CustomLevel custom = new CustomLevel();
    Object obj = SerializationTestHelper.serializeClone(custom);
    assertTrue(obj instanceof CustomLevel);

    CustomLevel clone = (CustomLevel) obj;
    assertEquals(Level.INFO.level, clone.level);
    assertEquals(Level.INFO.levelStr, clone.levelStr);
    assertEquals(Level.INFO.syslogEquivalent, clone.syslogEquivalent);
  
public voidtestDEBUG()
Tests Level.DEBUG.

      assertTrue(Level.DEBUG instanceof Level);
    
public voidtestDeserializeINFO()
Deserialize witness and see if resolved to Level.INFO.

throws
Exception if exception during test.

    Object obj =
      SerializationTestHelper.deserializeStream(
        "witness/serialization/info.bin");
    assertTrue(obj instanceof Level);
    Level info = (Level) obj;
    assertEquals("INFO", info.toString());
    //
    //  JDK 1.1 doesn't support readResolve necessary for the assertion
    if (!System.getProperty("java.version").startsWith("1.1.")) {
       assertTrue(obj == Level.INFO);
    }
  
public voidtestDotlessLowerI()
Test that dotless lower I + "nfo" is recognized as INFO.

      Level level = Level.toLevel("\u0131nfo");
      assertEquals("INFO", level.toString());
  
public voidtestDottedLowerI()
Test that dotted lower I + "nfo" is recognized as INFO even in Turkish locale.

      Locale defaultLocale = Locale.getDefault();
      Locale turkey = new Locale("tr", "TR");
      Locale.setDefault(turkey);
      Level level = Level.toLevel("info");
      Locale.setDefault(defaultLocale);
      assertEquals("INFO", level.toString());
  
public voidtestERROR()
Tests Level.ERROR.

      assertTrue(Level.ERROR instanceof Level);
    
public voidtestFATAL()
Tests Level.FATAL.

      assertTrue(Level.FATAL instanceof Level);
    
public voidtestINFO()
Tests Level.INFO.

      assertTrue(Level.INFO instanceof Level);
    
public voidtestIntToAll()
Tests Level.toLevel(Level.All_INT).

      Level level = Level.toLevel(Level.ALL_INT);
      assertEquals("ALL", level.toString());
  
public voidtestIntToFatal()
Tests Level.toLevel(Level.FATAL_INT).

      Level level = Level.toLevel(Level.FATAL_INT);
      assertEquals("FATAL", level.toString());
  
public voidtestIntToOff()
Tests Level.toLevel(Level.OFF_INT).

      Level level = Level.toLevel(Level.OFF_INT);
      assertEquals("OFF", level.toString());
  
public voidtestIntToTrace()
Tests Level.toLevel(Level.TRACE_INT).

      Level trace = Level.toLevel(5000);
      assertEquals("TRACE", trace.toString());
  
public voidtestLevelExtendsPriority()
Tests that Level extends Priority.

      assertTrue(Priority.class.isAssignableFrom(Level.class));
  
public voidtestOFF()
Tests Level.OFF.

    assertTrue(Level.OFF instanceof Level);
  
public voidtestSerialVersionUID()
Tests Level.serialVersionUID.

      assertEquals(3491141966387921974L, Level.serialVersionUID);
    
public voidtestSerializeINFO()
Serialize Level.INFO and check against witness.

throws
Exception if exception during test.

    int[] skip = new int[] {  };
    SerializationTestHelper.assertSerializationEquals(
      "witness/serialization/info.bin", Level.INFO, skip, Integer.MAX_VALUE);
  
public voidtestStringToTrace()
Tests Level.toLevel("TRACE");

        Level trace = Level.toLevel("TRACE");
        assertEquals("TRACE", trace.toString());
  
public voidtestTRACE()
Tests Level.TRACE.

      assertTrue(Level.TRACE instanceof Level);
    
public voidtestToLevelNull()
Tests Level.toLevel(null, Level.FATAL).

      Level level = Level.toLevel(null, Level.FATAL);
      assertEquals("FATAL", level.toString());
  
public voidtestToLevelUnrecognizedInt()
Tests Level.toLevel(17, Level.FATAL).

      Level level = Level.toLevel(17, Level.FATAL);
      assertEquals("FATAL", level.toString());
  
public voidtestTrace()
Tests Level.TRACE.

      assertEquals("TRACE", Level.TRACE.toString());
      assertEquals(5000, Level.TRACE.toInt());
      assertEquals(7, Level.TRACE.getSyslogEquivalent());
  
public voidtestTraceInt()
Tests Level.TRACE_INT.

      assertEquals(5000, Level.TRACE_INT);
  
public voidtestWARN()
Tests Level.WARN.

      assertTrue(Level.WARN instanceof Level);