本文整理汇总了Java中java.util.logging.ConsoleHandler.flush方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleHandler.flush方法的具体用法?Java ConsoleHandler.flush怎么用?Java ConsoleHandler.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.logging.ConsoleHandler
的用法示例。
在下文中一共展示了ConsoleHandler.flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClose_SufficientPrivilege_Exception
import java.util.logging.ConsoleHandler; //导入方法依赖的package包/类
public void testClose_SufficientPrivilege_Exception() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
h.publish(new LogRecord(Level.SEVERE,
"testClose_SufficientPrivilege_Exception msg"));
h.flush();
h.close();
}
示例2: testPublish_NoFilter
import java.util.logging.ConsoleHandler; //导入方法依赖的package包/类
public void testPublish_NoFilter() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter");
h.setLevel(Level.INFO);
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head" + "testPublish_NoFilter",
this.errSubstituteStream.toString());
h.setLevel(Level.WARNING);
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head" + "testPublish_NoFilter",
this.errSubstituteStream.toString());
h.setLevel(Level.CONFIG);
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head" + "testPublish_NoFilter"
+ "testPublish_NoFilter", this.errSubstituteStream.toString());
r.setLevel(Level.OFF);
h.setLevel(Level.OFF);
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head" + "testPublish_NoFilter"
+ "testPublish_NoFilter", this.errSubstituteStream.toString());
}
示例3: testPublish_EmptyMsg
import java.util.logging.ConsoleHandler; //导入方法依赖的package包/类
public void testPublish_EmptyMsg() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
LogRecord r = new LogRecord(Level.INFO, "");
h.publish(r);
h.flush();
assertEquals("MockFormatter_Head", this.errSubstituteStream.toString());
}
示例4: testPublish_NullMsg
import java.util.logging.ConsoleHandler; //导入方法依赖的package包/类
public void testPublish_NullMsg() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
LogRecord r = new LogRecord(Level.INFO, null);
h.publish(r);
h.flush();
// assertEquals("MockFormatter_Head",
// this.errSubstituteStream.toString());
}
示例5: testPublish_AfterClose
import java.util.logging.ConsoleHandler; //导入方法依赖的package包/类
public void testPublish_AfterClose() throws Exception {
PrintStream backup = System.err;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
System.setErr(new PrintStream(bos));
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.level", "FINE");
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
assertSame(h.getLevel(), Level.FINE);
LogRecord r1 = new LogRecord(Level.INFO, "testPublish_Record1");
LogRecord r2 = new LogRecord(Level.INFO, "testPublish_Record2");
assertTrue(h.isLoggable(r1));
h.publish(r1);
assertTrue(bos.toString().indexOf("testPublish_Record1") >= 0);
h.close();
// assertFalse(h.isLoggable(r));
assertTrue(h.isLoggable(r2));
h.publish(r2);
assertTrue(bos.toString().indexOf("testPublish_Record2") >= 0);
h.flush();
// assertEquals("MockFormatter_Head",
// this.errSubstituteStream.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
System.setErr(backup);
}
}