本文整理汇总了Java中org.productivity.java.syslog4j.SyslogIF.flush方法的典型用法代码示例。如果您正苦于以下问题:Java SyslogIF.flush方法的具体用法?Java SyslogIF.flush怎么用?Java SyslogIF.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.productivity.java.syslog4j.SyslogIF
的用法示例。
在下文中一共展示了SyslogIF.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPCISyslogMessage
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testPCISyslogMessage() {
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
message = new PCISyslogMessage("a","b",new Date(),"c","d","e").createMessage();
syslog.info("[TEST] " + message);
events.add("[TEST] " + message);
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例2: assertSyslog
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
protected void assertSyslog(SyslogIF syslog, String[] expectedMessages) {
SplitSyslog splitSyslog = (SplitSyslog) syslog;
List lastMessages = splitSyslog.getLastMessages();
if (lastMessages.size() < 1) {
fail("No messages received");
}
for(int i=0; i<lastMessages.size(); i++) {
String lastMessage = ((String) lastMessages.get(i)).substring(21 + this.localNameLength);
assertEquals(expectedMessages[i],lastMessage);
}
syslog.flush();
}
示例3: testTruncate
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testTruncate() {
setMessageLength(10);
SyslogIF syslog = Syslog.getInstance("split");
syslog.getConfig().setTruncateMessage(true);
syslog.info("T");
syslog.info("Test 1234");
syslog.info("Test 12345");
syslog.info("Test 654321");
syslog.info("Test 12345 For now is the time for all good men to come to the aid of their country");
assertSyslog(syslog,new String[] {"T", "Test 1234", "Test 12345", "Test 65432", "Test 12345" } );
syslog.flush();
}
示例4: flush
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void flush() throws SyslogRuntimeException {
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
SyslogIF syslog = Syslog.getInstance(protocol);
syslog.flush();
}
}
示例5: testHTMLEntityEscapeMessageModifier
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testHTMLEntityEscapeMessageModifier() {
SyslogMessageModifierIF messageModifier = new HTMLEntityEscapeSyslogMessageModifier();
String nullHtml = messageModifier.modify(null,0,0,null);
assertNull(nullHtml);
String emptyHtml = messageModifier.modify(null,0,0,"");
assertEquals("",emptyHtml);
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
syslog.getConfig().addMessageModifier(HTMLEntityEscapeSyslogMessageModifier.createDefault());
// SEND HTML
message = "[TEST] <html>&\"test\"&'" + "\t" + "</html>" + (char) 255;
syslog.info(message);
events.add("[TEST] <html>&"test"&'	</html>ÿ");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例6: _testMaxActiveSockets
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的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;
}
示例7: testStringCase
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testStringCase() {
// CHECK OUT OF BOUNDS
try {
new StringCaseSyslogMessageModifier((byte) 3);
fail("Should not be able to construct with an invalid byte value");
} catch (SyslogRuntimeException sre) {
assertTrue(true);
}
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
ArrayList list = new ArrayList();
((AbstractSyslogConfig) syslog.getConfig()).setMessageModifiers(list);
// UPPER SET UP
list.add(StringCaseSyslogMessageModifier.UPPER);
// UPPER
message = "[TEST] abcDEF Abc deF eFg";
syslog.debug(message);
events.add(message.toUpperCase());
// LOWER SET UP
syslog.getConfig().removeAllMessageModifiers();
syslog.getConfig().addMessageModifier(StringCaseSyslogMessageModifier.LOWER);
// LOWER
message = "[TEST] ABCdef aBC DEf EfG";
syslog.warn(message);
events.add(message.toLowerCase());
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例8: testSequential
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testSequential() {
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
// SET UP
SequentialSyslogMessageModifier sequentialModifier = SequentialSyslogMessageModifier.createDefault();
syslog.getConfig().addMessageModifier(sequentialModifier);
assertEquals(sequentialModifier.getConfig().getFirstNumber(),SequentialSyslogMessageModifierConfig.createDefault().getFirstNumber());
// ZERO
message = "[TEST] Sequence Test";
syslog.info(message);
events.add(message + " #0000");
// ONE
message = "[TEST] Sequence Test";
syslog.info(message);
events.add(message + " #0001");
// NINE THOUSAND NINE HUNDRED NIGHTY EIGHT
sequentialModifier.setNextSequence(SyslogConstants.LEVEL_INFO,9998);
message = "[TEST] Sequence Test";
syslog.info(message);
events.add(message + " #9998");
// NINE THOUSAND NINE HUNDRED NIGHTY NINE
message = "[TEST] Sequence Test";
syslog.info(message);
events.add(message + " #9999");
// ZERO
message = "[TEST] Sequence Test";
syslog.info(message);
events.add(message + " #0000");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例9: testChecksum
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testChecksum() {
try {
new ChecksumSyslogMessageModifier(null);
fail("Should not allow an empty config into a modifier");
} catch (SyslogRuntimeException sre) {
assertTrue(true);
}
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
// CRC32 SET UP
syslog.getConfig().addMessageModifier(ChecksumSyslogMessageModifier.createCRC32());
// CRC32
message = "[TEST] This Line Will Have a CRC32 Checksum";
syslog.info(message);
events.add(message + " {F8E7A4E4}");
// ADLER32 SET UP
syslog.getConfig().removeAllMessageModifiers();
ChecksumSyslogMessageModifier adler32Modifier = ChecksumSyslogMessageModifier.createADLER32();
syslog.getConfig().addMessageModifier(adler32Modifier);
// ADLER32
message = "[TEST] This Line Will Have an ADLER32 Checksum";
syslog.info(message);
events.add(message + " {5AD70EE4}");
// ADLER32 SET UP with LOWER FIRST
syslog.getConfig().insertMessageModifier(0,StringCaseSyslogMessageModifier.LOWER);
// ADLER32 with LOWER FIRST
message = "[TEST] This Line Will Have an ADLER32 Checksum";
syslog.info(message);
events.add(message.toLowerCase() + " {8A1710A4}");
// ADLER32
adler32Modifier.getConfig().setChecksum(new Adler32());
message = "[TEST] This Line Will Have an ADLER32 Checksum 2";
syslog.info(message);
events.add(message.toLowerCase() + " {ABD110F6}");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例10: testContinousChecksum
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testContinousChecksum() {
try {
new ChecksumSyslogMessageModifier(null);
fail("Should not allow an empty config into a modifier");
} catch (SyslogRuntimeException sre) {
assertTrue(true);
}
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
// CRC32 SET UP
ChecksumSyslogMessageModifierConfig config = ChecksumSyslogMessageModifierConfig.createCRC32();
assertFalse(config.isContinuous());
config.setContinuous(true);
assertTrue(config.isContinuous());
ChecksumSyslogMessageModifier modifier = new ChecksumSyslogMessageModifier(config);
syslog.getConfig().addMessageModifier(modifier);
// CRC32 Message #1
message = "[TEST] This Line Will Have a CRC32 Checksum 1";
syslog.info(message);
events.add(message + " {6E2A9F99}");
// CRC32 Message #2
message = "[TEST] This Line Will Have a CRC32 Checksum 2";
syslog.info(message);
events.add(message + " {7E736783}");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例11: testMac
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testMac() {
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
// HmacSHA1 SET UP
String base64Key = "fb7Jl0VGnzY5ehJCabcf7bSZ5Vk=";
SyslogMessageModifierIF messageModifier = MacSyslogMessageModifier.createHmacSHA1(base64Key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA1
message = "[TEST] This Line Will Have an HmacSHA1 Hash";
syslog.info(message);
events.add(message + " {6CIz39WE8wgxwpsqPievrtDWaXM=}");
// HmacSHA256 SET UP
base64Key = "+v2mHoOx6QGLqYFa/Tx0J7BkXSK4HEVMtGHtG66vQ54=";
syslog.getConfig().removeAllMessageModifiers();
messageModifier = MacSyslogMessageModifier.createHmacSHA256(base64Key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA256
message = "[TEST] This Line Will Have an HmacSHA256 Hash";
syslog.info(message);
events.add(message + " {sEpaXO6fvnO7szaJSjcqoIVl0C180/oWSP0rs6RFfB8=}");
// HmacSHA512 SET UP
base64Key = "w5sn5tOHpk/jBTWAQ4doTlSbtE1GQZC2RCe2/ayTy67zscXFEdlT/Zwsm5GFrjOwxlZITrAaq+s2KFCNpBTDig==";
syslog.getConfig().removeAllMessageModifiers();
messageModifier = MacSyslogMessageModifier.createHmacSHA512(base64Key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA512
message = "[TEST] This Line Will Have an HmacSHA512 Hash";
syslog.info(message);
events.add(message + " {Ddx+6JegzcifzT5H82BISGeGQ9FCA5biW51qItH9y95tJvFnFv+0+Tx/Kv0HAms2jv6iq08tlL7IFI1gMUWBtA==}");
// HmacMD5 SET UP
syslog.getConfig().removeAllMessageModifiers();
base64Key = "fb7Jl0VGnzY5ehJCdeff7bSZ5Vk=";
messageModifier = MacSyslogMessageModifier.createHmacMD5(base64Key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacMD5
message = "[TEST] This Line Will Have an HmacMD5 Hash";
syslog.info(message);
events.add(message + " {Z+BBv07/AlQ55a6d88OuGg==}");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例12: testMacWithKeys
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testMacWithKeys() {
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
syslog.getConfig().removeAllMessageModifiers();
// HmacSHA1 SET UP
Key key = createKey("fb7Jl0VGnzY5ehJCabcf7bSZ5Vk=","SHA1");
SyslogMessageModifierIF messageModifier = MacSyslogMessageModifier.createHmacSHA1(key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA1
message = "[TEST] This Line Will Have an HmacSHA1 Hash";
syslog.info(message);
events.add(message + " {6CIz39WE8wgxwpsqPievrtDWaXM=}");
// HmacSHA256 SET UP
key = createKey("+v2mHoOx6QGLqYFa/Tx0J7BkXSK4HEVMtGHtG66vQ54=","SHA256");
syslog.getConfig().removeAllMessageModifiers();
messageModifier = MacSyslogMessageModifier.createHmacSHA256(key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA256
message = "[TEST] This Line Will Have an HmacSHA256 Hash";
syslog.info(message);
events.add(message + " {sEpaXO6fvnO7szaJSjcqoIVl0C180/oWSP0rs6RFfB8=}");
// HmacSHA512 SET UP
key = createKey("w5sn5tOHpk/jBTWAQ4doTlSbtE1GQZC2RCe2/ayTy67zscXFEdlT/Zwsm5GFrjOwxlZITrAaq+s2KFCNpBTDig==","SHA512");
syslog.getConfig().removeAllMessageModifiers();
messageModifier = MacSyslogMessageModifier.createHmacSHA512(key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacSHA512
message = "[TEST] This Line Will Have an HmacSHA512 Hash";
syslog.info(message);
events.add(message + " {Ddx+6JegzcifzT5H82BISGeGQ9FCA5biW51qItH9y95tJvFnFv+0+Tx/Kv0HAms2jv6iq08tlL7IFI1gMUWBtA==}");
// HmacMD5 SET UP
syslog.getConfig().removeAllMessageModifiers();
key = createKey("fb7Jl0VGnzY5ehJCdeff7bSZ5Vk=","MD5");
messageModifier = MacSyslogMessageModifier.createHmacMD5(key);
syslog.getConfig().addMessageModifier(messageModifier);
// HmacMD5
message = "[TEST] This Line Will Have an HmacMD5 Hash";
syslog.info(message);
events.add(message + " {Z+BBv07/AlQ55a6d88OuGg==}");
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例13: testUnixSyslog
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testUnixSyslog() {
if (Boolean.getBoolean(SyslogConstants.DISABLE_UNIX_PROPERTY)) {
assertTrue(true);
return;
}
SyslogIF syslog = Syslog.getInstance(SyslogConstants.UNIX_SOCKET);
UnixSocketSyslogConfig config = (UnixSocketSyslogConfig) syslog.getConfig();
config.setPath("/tmp/syslog4j.sock");
config.setType(UnixSocketSyslogConfig.SOCK_STREAM);
syslog.info(this.getClass().getName() + ": unix_socket " + System.currentTimeMillis());
syslog.flush();
SyslogUtility.sleep(1000);
}
示例14: testUnixSyslog
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testUnixSyslog() {
if (Boolean.getBoolean(SyslogConstants.DISABLE_UNIX_PROPERTY)) {
assertTrue(true);
return;
}
SyslogIF syslog = Syslog.getInstance(SyslogConstants.UNIX_SYSLOG);
syslog.getConfig().setFacility(SyslogIF.FACILITY_KERN);
syslog.error(this.getClass().getName() + ": unix_syslog " + System.currentTimeMillis());
syslog.flush();
syslog.shutdown();
AbstractSyslog abstractSyslog = (AbstractSyslog) syslog;
assertNull(abstractSyslog.getWriter());
abstractSyslog.returnWriter(null);
}
示例15: _testSendReceive
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void _testSendReceive(boolean sortEvents, boolean sortRecordedEvents){
List events = new ArrayList();
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
for(int i=0; i<getMessageCount(); i++) {
String message = "[TEST] " + i + " / " + System.currentTimeMillis();
syslog.info(message);
events.add(message);
}
SyslogUtility.sleep(200);
syslog.flush();
verifySendReceive(events,sortEvents,sortRecordedEvents);
}