当前位置: 首页>>代码示例>>Java>>正文


Java SocketHandler.publish方法代码示例

本文整理汇总了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();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:SocketHandlerTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:SocketHandlerTest.java

示例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();
	}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:SocketHandlerTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SocketHandlerTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SocketHandlerTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:36,代码来源:SocketHandlerTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:SocketHandlerTest.java


注:本文中的java.util.logging.SocketHandler.publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。