Package java.util.logging

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


    assertSame(h.getLevel(), Level.FINE);
    LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter");
    assertTrue(h.isLoggable(r));
    h.close();
    assertFalse(h.isLoggable(r));
    h.publish(r);
    h.flush();
    assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString());
  }

  /*
 
View Full Code Here


    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    h.setEncoding("iso-8859-1");
    assertEquals("iso-8859-1", h.getEncoding());
    LogRecord r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69");
    h.publish(r);
    h.flush();

    byte[] bytes = encoder.encode(
        CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69"))
        .array();
View Full Code Here

    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    h.setEncoding("iso-8859-1");
    assertEquals("iso-8859-1", h.getEncoding());
    LogRecord r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69");
    h.publish(r);
    h.flush();
    assertTrue(Arrays.equals(aos.toByteArray(), encoder.encode(
        CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69"))
        .array()));
View Full Code Here

        .array()));

    h.setEncoding("iso8859-1");
    assertEquals("iso8859-1", h.getEncoding());
    r = new LogRecord(Level.INFO, "\u6881\u884D\u8F69");
    h.publish(r);
    h.flush();
    assertFalse(Arrays.equals(aos.toByteArray(), encoder.encode(
        CharBuffer.wrap("MockFormatter_Head" + "\u6881\u884D\u8F69"
            + "testSetEncoding_Normal2")).array()));
    byte[] b0 = aos.toByteArray();
View Full Code Here

   */
  public void testSetEncoding_FlushBeforeSetting() throws Exception {
    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    StreamHandler h = new StreamHandler(aos, new MockFormatter());
    LogRecord r = new LogRecord(Level.INFO, "abcd");
    h.publish(r);
    assertFalse(aos.toString().indexOf("abcd") > 0);
    h.setEncoding("iso-8859-1");
    assertTrue(aos.toString().indexOf("abcd") > 0);
  }

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.