public void testNoGenerations() { final BerkeleyDBTempTargetRepository targets = createTempTargetRepository(); try { assertNull(targets.getOldGeneration(0)); assertNull(targets.getNewGeneration(0)); assertFalse(targets.copyOldToNewGeneration(0, new ArrayList<Long>())); targets.nextGeneration(); } finally { targets.stop(); } }
public void testRotation() { final BerkeleyDBTempTargetRepository targets = createTempTargetRepository(); try { assertEquals(targets.locateOrStoreImpl(new MockTempTarget("Foo")), UniqueId.of("Tmp", "0")); final long t = System.nanoTime(); assertEquals(targets.locateOrStoreImpl(new MockTempTarget("Bar")), UniqueId.of("Tmp", "1")); assertTrue(targets.copyOldToNewGeneration(0, new ArrayList<Long>())); targets.nextGeneration(); assertEquals(targets.locateOrStoreImpl(new MockTempTarget("Cow")), UniqueId.of("Tmp", "2")); assertTrue(targets.copyOldToNewGeneration(t, new ArrayList<Long>())); targets.nextGeneration(); assertNull(targets.getOldGeneration(0)); assertEquals(targets.getOldGeneration(1), new MockTempTarget("Bar")); assertEquals(targets.getOldGeneration(2), new MockTempTarget("Cow")); } finally { targets.stop(); } }