本文整理汇总了Java中org.productivity.java.syslog4j.Syslog.destroyInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Syslog.destroyInstance方法的具体用法?Java Syslog.destroyInstance怎么用?Java Syslog.destroyInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.productivity.java.syslog4j.Syslog
的用法示例。
在下文中一共展示了Syslog.destroyInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateAndDestroyByProtocol
import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public void testCreateAndDestroyByProtocol() {
UDPNetSyslogConfig config = new UDPNetSyslogConfig();
config.setPort(999);
SyslogIF syslog = Syslog.createInstance("udpToDestroy",config);
assertEquals(SyslogMessageProcessor.getDefault(),syslog.getMessageProcessor());
SyslogMessageProcessorIF messageProcessor = new FakeMessageProcessor();
syslog.setMessageProcessor(messageProcessor);
assertEquals(messageProcessor,syslog.getMessageProcessor());
SyslogIF matchSyslog = Syslog.getInstance("udpToDestroy");
assertEquals(syslog,matchSyslog);
Syslog.destroyInstance("");
Syslog.destroyInstance("udpToDestroy");
try {
Syslog.getInstance("udpToDestroy");
fail("udpToDestroy should not exist");
} catch (SyslogRuntimeException sre) {
//
}
}
示例2: _testMaxActiveSockets
import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
protected int _testMaxActiveSockets(TCPNetSyslogServerConfigIF serverConfig) {
Counter c = new Counter();
serverConfig.setMaxActiveSockets(2);
serverConfig.addEventHandler(c);
SyslogServer.createThreadedInstance("tcp_maxactivesockets",serverConfig);
TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
config.setPort(8888);
SyslogIF syslog1 = Syslog.createInstance("tcp_maxactivesockets1",config);
syslog1.info("test1");
syslog1.flush();
SyslogUtility.sleep(200);
SyslogIF syslog2 = Syslog.createInstance("tcp_maxactivesockets2",config);
syslog2.info("test2");
syslog2.flush();
SyslogUtility.sleep(200);
SyslogIF syslog3 = Syslog.createInstance("tcp_maxactivesockets3",config);
syslog3.info("test3");
syslog3.flush();
SyslogUtility.sleep(200);
syslog1.shutdown();
SyslogUtility.sleep(200);
Syslog.destroyInstance("tcp_maxactivesockets1");
Syslog.destroyInstance("tcp_maxactivesockets2");
Syslog.destroyInstance("tcp_maxactivesockets3");
SyslogServer.destroyInstance("tcp_maxactivesockets");
return c.counter;
}
示例3: testFreshConnectionInterval
import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public void testFreshConnectionInterval() {
TCPNetSyslogServerConfigIF serverConfig = new TCPNetSyslogServerConfig();
serverConfig.setPort(8888);
SocketCounter counter = new SocketCounter();
serverConfig.addEventHandler(counter);
SyslogServerIF server = SyslogServer.createThreadedInstance("tcp_8888",serverConfig);
SyslogUtility.sleep(100);
TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
config.setPort(8888);
config.setFreshConnectionInterval(300);
SyslogIF syslog = Syslog.createInstance("tcp_8888",config);
for(int i=0; i<10; i++) {
syslog.info("message " + i);
SyslogUtility.sleep(100);
}
SyslogUtility.sleep(100);
SyslogServer.destroyInstance(server);
Syslog.destroyInstance(syslog);
SyslogUtility.sleep(100);
assertEquals("OpenCounter",3,counter.openCounter);
assertEquals("EventCounter",10,counter.eventCounter);
assertEquals("CloseCounter",3,counter.closeCounter);
}
示例4: testTimeout
import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public void testTimeout() {
TCPNetSyslogServerConfigIF serverConfig = new TCPNetSyslogServerConfig();
serverConfig.setTimeout(150);
serverConfig.setPort(7777);
serverConfig.addEventHandler(new TimeoutHandler());
TCPNetSyslogConfigIF clientConfig = new TCPNetSyslogConfig();
clientConfig.setPort(7777);
clientConfig.setThreaded(false);
SyslogServer.createThreadedInstance("tcp_to",serverConfig);
SyslogUtility.sleep(250);
SyslogIF syslog = Syslog.createInstance("tcp_to",clientConfig);
SyslogUtility.sleep(250);
int mark = 0;
for(int i=1; i<=10; i++) {
if (i > 5) {
mark--;
} else {
mark++;
}
int timeout = 35 * mark + 25;
syslog.info("Test " + i + " (" + timeout + "ms) Should Timeout: " + (timeout > serverConfig.getTimeout() ? "yes" : "no"));
SyslogUtility.sleep(timeout);
}
syslog.flush();
SyslogUtility.sleep(200);
SyslogServer.destroyInstance("tcp_to");
SyslogUtility.sleep(200);
Syslog.destroyInstance("tcp_to");
}