use of com.sun.jna.platform.win32.Advapi32Util.EventLogIterator in project jna by java-native-access.
the class Advapi32UtilTest method testEventLogIteratorBackwards.
public void testEventLogIteratorBackwards() {
EventLogIterator iter = new EventLogIterator(null, "Application", WinNT.EVENTLOG_BACKWARDS_READ);
try {
int max = 100;
int lastId = -1;
while (iter.hasNext()) {
EventLogRecord record = iter.next();
/*
System.out.println(record.getRecordNumber()
+ ": Event ID: " + record.getEventId()
+ ", Event Type: " + record.getType()
+ ", Event Source: " + record.getSource());
*/
assertTrue(record.getRecordNumber() < lastId || lastId == -1);
lastId = record.getRecordNumber();
if (max-- <= 0) {
// shorten test
break;
}
}
} finally {
iter.close();
}
}
use of com.sun.jna.platform.win32.Advapi32Util.EventLogIterator in project jna by java-native-access.
the class Advapi32UtilTest method testEventLogIteratorForwards.
public void testEventLogIteratorForwards() {
EventLogIterator iter = new EventLogIterator("Application");
try {
int max = 100;
int lastId = 0;
while (iter.hasNext()) {
EventLogRecord record = iter.next();
assertTrue(record.getRecordNumber() > lastId);
lastId = record.getRecordNumber();
assertNotNull(record.getType().name());
assertNotNull(record.getSource());
if (record.getRecord().DataLength.intValue() > 0) {
assertEquals(record.getData().length, record.getRecord().DataLength.intValue());
} else {
assertNull(record.getData());
}
if (record.getRecord().NumStrings.intValue() > 0) {
assertEquals(record.getStrings().length, record.getRecord().NumStrings.intValue());
} else {
assertNull(record.getStrings());
}
if (max-- <= 0) {
// shorten test
break;
}
/*
System.out.println(record.getRecordNumber()
+ ": Event ID: " + record.getEventId()
+ ", Event Type: " + record.getType()
+ ", Event Source: " + record.getSource());
*/
}
} finally {
iter.close();
}
}
Aggregations