0, directory.list().length);
}
@Test
public void testOnlyDeleteSome() throws IOException, InterruptedException {
EventCollectorAdmin admin = (EventCollectorAdmin) eventCollector.getAdmin();
Assert.assertNotNull(admin);
PersistentEventManager eventManager = (PersistentEventManager)eventCollector.getEventManager();
eventManager.addRemoteEvents(TransientEventManagerTest.createRemoteServiceEvents(10));
waitForFileCount(10, eventManager.getPersistentEventDirectory());
Assert.assertEquals("Expected 10 events, got "+eventManager.getNumberOfCollectedEvents(),
10, eventManager.getNumberOfCollectedEvents());
List<RemoteServiceEvent> eventsToDelete = new ArrayList<RemoteServiceEvent>();
eventsToDelete.addAll(eventManager.getEvents());
for(int i=0; i<3; i++)
eventsToDelete.remove(0);
int deleted = admin.delete(eventsToDelete);
Assert.assertEquals("Expected 7, got "+deleted, 7, deleted);
Assert.assertEquals("Expected 3 events, got "+eventManager.getNumberOfCollectedEvents(),
3, eventManager.getNumberOfCollectedEvents());
File directory = eventManager.getPersistentEventDirectory();
Assert.assertEquals("Expected 3 event files, got "+directory.list().length,
3, directory.list().length);
/* Now delete the rest */
eventsToDelete.clear();
eventsToDelete.addAll(eventManager.getEvents());
deleted = admin.delete(eventsToDelete);
Assert.assertEquals("Expected 3, got "+deleted, 3, deleted);
Assert.assertEquals("Expected 0 events, got "+eventManager.getNumberOfCollectedEvents(),
0, eventManager.getNumberOfCollectedEvents());
Assert.assertEquals("Expected 0 event files, got "+directory.list().length,
0, directory.list().length);