FileAuditor extends AbstractAuditor implements AuditorMBean { @Override public synchronized void clear() { try { auditFile.setLength(0); auditFile.seek(0); recordCount.set(0); } catch (IOException e) {} } @Inject  FileAuditor(@AuditFile File auditFile); @Override void writeEvent(UUID eventId, Calendar eventTimeStamp, String principal, AuditEvent event, Collection<? extends AuditContext> contexts); @Override synchronized Integer getEventCount(); @Override synchronized CompositeData[] getEvents(Integer eventCount); @Override synchronized CompositeData getLastEvent(); @Override synchronized void clear();  }
@Test public void testClear() { FileAuditor auditor = new FileAuditor(auditFile); auditor.audit(PRINCIPAL, UNIT_TEST_EVENT); auditor.audit(PRINCIPAL, UNIT_TEST_EVENT); auditor.clear(); assertEquals(0, auditor.getEventCount().intValue()); assertNull(auditor.getLastEvent()); }