本文整理匯總了Java中java.util.logging.ConsoleHandler.close方法的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleHandler.close方法的具體用法?Java ConsoleHandler.close怎麽用?Java ConsoleHandler.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.logging.ConsoleHandler
的用法示例。
在下文中一共展示了ConsoleHandler.close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testClose_SufficientPrivilege_NormalClose
import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public void testClose_SufficientPrivilege_NormalClose() 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_NormalClose msg"));
h.close();
assertEquals("flush", CallVerificationStack.getInstance()
.getCurrentSourceMethod());
assertNull(CallVerificationStack.getInstance().pop());
h.close();
}
示例2: 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();
}
示例3: testClose_SufficientPrivilege_DirectClose
import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public void testClose_SufficientPrivilege_DirectClose() 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.close();
assertEquals("flush", CallVerificationStack.getInstance()
.getCurrentSourceMethod());
assertNull(CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
}
示例4: 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);
}
}