Package java.util.logging

Examples of java.util.logging.StreamHandler.publish()


    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


   * 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());
View Full Code Here

   * 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 publish(), use no filter, having output stream, normal log record.
   */
  public void testPublish_NoOutputStream() {
    StreamHandler h = new StreamHandler();
    LogRecord r = new LogRecord(Level.INFO, "testPublish_NoOutputStream");
    h.publish(r);

    h.setLevel(Level.WARNING);
    h.publish(r);

    h.setLevel(Level.CONFIG);
View Full Code Here

    StreamHandler h = new StreamHandler();
    LogRecord r = new LogRecord(Level.INFO, "testPublish_NoOutputStream");
    h.publish(r);

    h.setLevel(Level.WARNING);
    h.publish(r);

    h.setLevel(Level.CONFIG);
    h.publish(r);

    r.setLevel(Level.OFF);
View Full Code Here

    h.setLevel(Level.WARNING);
    h.publish(r);

    h.setLevel(Level.CONFIG);
    h.publish(r);

    r.setLevel(Level.OFF);
    h.setLevel(Level.OFF);
    h.publish(r);
  }
View Full Code Here

    h.setLevel(Level.CONFIG);
    h.publish(r);

    r.setLevel(Level.OFF);
    h.setLevel(Level.OFF);
    h.publish(r);
  }

  /*
   * Test publish(), use no filter, having output stream, normal log record.
   */
 
View Full Code Here

    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());

    LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter");
    h.setLevel(Level.INFO);
    h.publish(r);
    h.flush();
    assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos
        .toString());

    h.setLevel(Level.WARNING);
View Full Code Here

    h.flush();
    assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos
        .toString());

    h.setLevel(Level.WARNING);
    h.publish(r);
    h.flush();
    assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos
        .toString());

    h.setLevel(Level.CONFIG);
View Full Code Here

    h.flush();
    assertEquals("MockFormatter_Head" + "testPublish_NoFilter", aos
        .toString());

    h.setLevel(Level.CONFIG);
    h.publish(r);
    h.flush();
    assertEquals("MockFormatter_Head" + "testPublish_NoFilter"
        + "testPublish_NoFilter", aos.toString());

    r.setLevel(Level.OFF);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.