Package java.util.logging

Examples of java.util.logging.MemoryHandler


    // null target
    try {
      props.remove("java.util.logging.MemoryHandler.target");
      manager.readConfiguration(EnvironmentHelper
          .PropertiesToInputStream(props));
      handler = new MemoryHandler();
      fail("should throw RuntimeException: target must be set");
    } catch (RuntimeException e) {
    }

    // invalid target
    try {
      props.put("java.util.logging.MemoryHandler.target", "badname");
      manager.readConfiguration(EnvironmentHelper
          .PropertiesToInputStream(props));
      handler = new MemoryHandler();
      fail("should throw RuntimeException: target must be valid");
    } catch (RuntimeException e) {
    }

    // invalid formatter
    initProps();
    props.put("java.util.logging.MemoryHandler.formatter", "badname");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    assertTrue(handler.getFormatter() instanceof SimpleFormatter);

    // invalid level
    initProps();
    props.put("java.util.logging.MemoryHandler.level", "badname");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    assertEquals(handler.getLevel(), Level.ALL);

    // invalid pushlevel
    initProps();
    props.put("java.util.logging.MemoryHandler.push", "badname");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    assertEquals(handler.getPushLevel(), Level.SEVERE);

    // invalid filter
    initProps();
    props.put("java.util.logging.MemoryHandler.filter", "badname");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    assertNull(handler.getFilter());

    // invalid size
    initProps();
    props.put("java.util.logging.MemoryHandler.size", "-1");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    initProps();
    props.put("java.util.logging.MemoryHandler.size", "badsize");
    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();

  }
View Full Code Here


    props.put("java.util.logging.MemoryHandler.target", baseClassName
        + "$MockHandler");

    manager.readConfiguration(EnvironmentHelper
        .PropertiesToInputStream(props));
    handler = new MemoryHandler();
    assertNull(handler.getFilter());
    assertTrue(handler.getFormatter() instanceof SimpleFormatter);
    assertNull(handler.getEncoding());
    assertNotNull(handler.getErrorManager());
    assertEquals(handler.getLevel(), Level.ALL);
View Full Code Here

  /*
   * Class under test for void MemoryHandler(Handler, int, Level)
   */
  public void testMemoryHandlerHandlerintLevel() {
    handler = new MemoryHandler(target, 2, Level.FINEST);
    assertTrue(handler.getFilter() instanceof MockFilter);
    assertTrue(handler.getFormatter() instanceof MockFormatter);
    assertNull(handler.getEncoding());
    assertNotNull(handler.getErrorManager());
    assertEquals(handler.getLevel(), Level.FINE);
    assertEquals(handler.getPushLevel(), Level.FINEST);
    assertNull(target.getFormatter());

    try {
      handler = new MemoryHandler(null, 2, Level.FINEST);
      fail("should throw NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
      handler = new MemoryHandler(target, 2, null);
      fail("should throw NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
      handler = new MemoryHandler(target, 0, Level.FINEST);
      fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }
    try {
      handler = new MemoryHandler(target, -1, Level.FINEST);
      fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }

  }
View Full Code Here

TOP

Related Classes of java.util.logging.MemoryHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.