本文整理汇总了Java中java.util.logging.SocketHandler.publish方法的典型用法代码示例。如果您正苦于以下问题:Java SocketHandler.publish方法的具体用法?Java SocketHandler.publish怎么用?Java SocketHandler.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.logging.SocketHandler
的用法示例。
在下文中一共展示了SocketHandler.publish方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClose_SufficientPrivilege_NormalClose
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testClose_SufficientPrivilege_NormalClose() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.publish(new LogRecord(Level.SEVERE,
"testClose_SufficientPrivilege_NormalClose msg"));
h.close();
assertEquals("MockFormatter_Head"
+ "testClose_SufficientPrivilege_NormalClose msg"
+ "MockFormatter_Tail", thread.getReadString());
h.close();
}
示例2: testPublish_WithFilter
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_WithFilter() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.INFO);
h.setFilter(new MockFilter());
System.setErr(new PrintStream(new ByteArrayOutputStream()));
LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter");
h.setLevel(Level.INFO);
h.publish(r);
h.close();
assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread
.getReadString());
}
示例3: testPublish_Null
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_Null() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.INFO);
try {
h.publish(null);
} finally {
h.close();
// ensure the thread exits and the port becomes available again
thread.getReadString();
}
}
示例4: testPublish_EmptyMsg
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_EmptyMsg() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.INFO);
LogRecord r = new LogRecord(Level.INFO, "");
h.publish(r);
h.close();
assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread
.getReadString());
}
示例5: testPublish_NullMsg
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_NullMsg() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.INFO);
LogRecord r = new LogRecord(Level.INFO, null);
h.publish(r);
h.close();
assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread
.getReadString());
}
示例6: testPublish_NoFilter
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_NoFilter() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.INFO);
LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFilter");
h.setLevel(Level.INFO);
h.publish(r);
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);
h.close();
assertEquals("MockFormatter_Head" + "testPublish_NoFilter"
+ "testPublish_NoFilter" + "MockFormatter_Tail", thread
.getReadString());
}
示例7: testPublish_AfterClose
import java.util.logging.SocketHandler; //导入方法依赖的package包/类
public void testPublish_AfterClose() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.SocketHandler.formatter", className
+ "$MockFormatter");
p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
p.put("java.util.logging.SocketHandler.port", "6666");
LOG_MANAGER.readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
// start the server to be ready to accept log messages
ServerThread thread = new ServerThread();
thread.start();
Thread.sleep(2000);
h = new SocketHandler();
h.setLevel(Level.FINE);
assertSame(h.getLevel(), Level.FINE);
LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter");
assertTrue(h.isLoggable(r));
h.close();
// ensure the thread exits and the port becomes available again
thread.getReadString();
// assertFalse(h.isLoggable(r));
h.publish(r);
h.flush();
// assertEquals("MockFormatter_Head",
// this.errSubstituteStream.toString());
}