@Override protected DurableDataLog createDurableDataLog(Object sharedContext) { Preconditions.checkArgument(sharedContext instanceof InMemoryDurableDataLog.EntryCollection); return new InMemoryDurableDataLog((InMemoryDurableDataLog.EntryCollection) sharedContext, executorService()); }
/** * Tests the constructor of InMemoryDurableDataLog. The constructor takes in an EntryCollection and this verifies * that information from a previous instance of an InMemoryDurableDataLog is still accessible. */ @Test(timeout = 5000) public void testConstructor() throws Exception { InMemoryDurableDataLog.EntryCollection entries = new InMemoryDurableDataLog.EntryCollection(); TreeMap<LogAddress, byte[]> writeData; // Create first log and write some data to it. try (DurableDataLog log = new InMemoryDurableDataLog(entries, executorService())) { log.initialize(TIMEOUT); writeData = populate(log, WRITE_COUNT); } // Close the first log, and open a second one, with the same EntryCollection in the constructor. try (DurableDataLog log = new InMemoryDurableDataLog(entries, executorService())) { log.initialize(TIMEOUT); // Verify it contains the same entries. verifyReads(log, writeData); } } }
@Before public void setUp() { this.factory = new InMemoryDurableDataLogFactory(executorService()); }