Esempio n. 1
0
 @Test
 public void shouldLogExceptionsButContinueDumpingRepositories()
     throws InterruptedException, IOException {
   EntryRepo repoFoo = mock(EntryRepo.class);
   EntryRepo repoBar = mock(EntryRepo.class);
   factory.getRepos().put("foo_subset__size", repoFoo);
   factory.getRepos().put("bar_subset__size", repoBar);
   when(repoFoo.isDirty()).thenReturn(true);
   when(repoFoo.diskDump()).thenThrow(new RuntimeException("test exception"));
   when(repoBar.isDirty()).thenReturn(true);
   when(repoBar.diskDump()).thenReturn("bar-data");
   logFixture.startListening();
   factory.run();
   logFixture.stopListening();
   logFixture.assertHeard("disk dump of foo_subset__size failed");
   verify(repoFoo).diskDump();
   verify(repoBar).diskDump();
 }
Esempio n. 2
0
 @Test
 public void shouldHaveATimerThatPurgesOldVersions() throws ClassNotFoundException, IOException {
   final VersioningEntryRepo repo1 = mock(VersioningEntryRepo.class);
   final VersioningEntryRepo repo2 = mock(VersioningEntryRepo.class);
   final VersioningEntryRepo repo3 = mock(VersioningEntryRepo.class);
   doThrow(new IOException("test exception")).when(repo2).purgeOldVersions(12);
   findOrCreateRepo(repo1, "foo");
   findOrCreateRepo(repo2, "bar");
   findOrCreateRepo(repo3, "baz");
   logFixture.startListening();
   factory.purgeVersionsOlderThan(12);
   logFixture.stopListening();
   verify(repo1).purgeOldVersions(12);
   verify(repo2).purgeOldVersions(12);
   verify(repo3).purgeOldVersions(12);
   logFixture.assertHeard(
       "failed to delete older versions for repo identified by 'bar_LATEST_foo__bar'");
   logFixture.assertHeardException(new IOException("test exception"));
 }