示例#1
0
  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) {
          break; // shorten test
        }
        /*
          System.out.println(record.getRecordNumber()
          + ": Event ID: " + record.getEventId()
          + ", Event Type: " + record.getType()
          + ", Event Source: " + record.getSource());
        */
      }
    } finally {
      iter.close();
    }
  }