@Test public void testExportToBase64ShouldNotThrow() throws Exception { int numKeys = 1000; int numValuesPerKeys = 1000; createAndFillMap(DIRECTORY, numKeys, numValuesPerKeys).close(); Map.exportToBase64(DIRECTORY, DATAFILE); // Clear the map. Map map = new Map(DIRECTORY); // TODO Check return value, which is a pair now. Utils.Pair<Integer, Long> result = map.removeAllMatches( new Predicate() { @Override public boolean call(ByteBuffer bytes) { return true; } }); Assert.assertEquals(numKeys, result.a().intValue()); Assert.assertEquals(numKeys * numValuesPerKeys, result.b().longValue()); map.close(); // Import and check content. Map.importFromBase64(DIRECTORY, DATAFILE); map = new Map(DIRECTORY); for (int i = 0; i < numKeys; ++i) { Iterator iter = map.get(makeKey(i)); for (int j = 0; j < numValuesPerKeys; ++j) { Assert.assertTrue(iter.hasNext()); Assert.assertEquals(j, getSuffix(iter.next())); } iter.close(); } map.close(); }
@Test public void testExportToBase64FromEmptyMapShouldNotThrow() throws Exception { createAndFillMap(DIRECTORY, 0, 0).close(); Map.exportToBase64(DIRECTORY, DATAFILE); }
@Test(expected = Exception.class) public void testExportToBase64ShouldThrow() throws Exception { Map.exportToBase64(DIRECTORY, DATAFILE); }