Package java.util.logging

Examples of java.util.logging.StreamHandler


    assertEquals(INVALID_LEVEL, LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.level"));
    assertEquals("XXXX", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));
    StreamHandler h = new StreamHandler();
    assertSame(Level.INFO, h.getLevel());
    assertTrue(h.getFormatter() instanceof SimpleFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    h.publish(new LogRecord(Level.SEVERE, "test"));
    assertTrue(CallVerificationStack.getInstance().empty());
    assertNull(h.getEncoding());
  }
View Full Code Here


    assertNull(LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.formatter"));
    assertNull(LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));

    StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
        new MockFormatter2());
    assertSame(Level.INFO, h.getLevel());
    assertTrue(h.getFormatter() instanceof MockFormatter2);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
  }
View Full Code Here

    SecurityManager oldMan = System.getSecurityManager();
    System.setSecurityManager(new MockSecurityManager());
    // set a normal value
    try {
      StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
          new MockFormatter2());
      assertSame(Level.INFO, h.getLevel());
      assertTrue(h.getFormatter() instanceof MockFormatter2);
      assertNull(h.getFilter());
      assertNull(h.getEncoding());
    } finally {
      System.setSecurityManager(oldMan);
    }
  }
View Full Code Here

    assertEquals("FINE", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.level"));
    assertEquals("iso-8859-1", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));
    StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
        new MockFormatter2());
    assertSame(h.getLevel(), Level.parse("FINE"));
    assertTrue(h.getFormatter() instanceof MockFormatter2);
    assertTrue(h.getFilter() instanceof MockFilter);
    assertEquals("iso-8859-1", h.getEncoding());
  }
View Full Code Here

    assertEquals(INVALID_LEVEL, LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.level"));
    assertEquals("XXXX", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));
    StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
        new MockFormatter2());
    assertSame(Level.INFO, h.getLevel());
    assertTrue(h.getFormatter() instanceof MockFormatter2);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
  }
View Full Code Here

    assertEquals("FINE", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.level"));
    assertEquals("iso-8859-1", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));
    try {
      new StreamHandler(new ByteArrayOutputStream(), null);
      fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
      // expected
    }
  }
View Full Code Here

    assertEquals("FINE", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.level"));
    assertEquals("iso-8859-1", LogManager.getLogManager().getProperty(
        "java.util.logging.StreamHandler.encoding"));
    try {
      new StreamHandler(null, new MockFormatter2());
      fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
      // expected
    }
  }
View Full Code Here

   * Test close() when having sufficient privilege, and a record has been
   * written to the output stream.
   */
  public void testClose_SufficientPrivilege_NormalClose() {
    ByteArrayOutputStream aos = new MockOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    h.publish(new LogRecord(Level.SEVERE,
        "testClose_SufficientPrivilege_NormalClose msg"));
    h.close();
    assertEquals("close", CallVerificationStack.getInstance()
        .getCurrentSourceMethod());
    assertNull(CallVerificationStack.getInstance().pop());
    assertEquals("flush", CallVerificationStack.getInstance()
        .getCurrentSourceMethod());
    CallVerificationStack.getInstance().clear();
    assertTrue(aos.toString().endsWith("MockFormatter_Tail"));
    h.close();
  }
View Full Code Here

   * Test close() when having sufficient privilege, and an output stream that
   * always throws exceptions.
   */
  public void testClose_SufficientPrivilege_Exception() {
    ByteArrayOutputStream aos = new MockExceptionOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    h.publish(new LogRecord(Level.SEVERE,
        "testClose_SufficientPrivilege_Exception msg"));
    h.flush();
    h.close();
  }
View Full Code Here

   * Test close() when having sufficient privilege, and no record has been
   * written to the output stream.
   */
  public void testClose_SufficientPrivilege_DirectClose() {
    ByteArrayOutputStream aos = new MockOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    h.close();
    assertEquals("close", CallVerificationStack.getInstance()
        .getCurrentSourceMethod());
    assertNull(CallVerificationStack.getInstance().pop());
    assertEquals("flush", CallVerificationStack.getInstance()
        .getCurrentSourceMethod());
View Full Code Here

TOP

Related Classes of java.util.logging.StreamHandler

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.