@@ -0,0 +1,1528 @@
+package com.nyeggen.lash.test;%0A%0Aimport java.io.File;%0Aimport java.util.Random;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0Aimport com.nyeggen.lash.AbstractDiskMap;%0Aimport com.nyeggen.lash.BucketDiskMap;%0Aimport com.nyeggen.lash.DiskMap;%0Aimport com.nyeggen.lash.serde.IntSerde;%0Aimport com.nyeggen.lash.util.MMapper;%0A%0A@RunWith(JUnit4.class)%0Apublic class TestDiskMap %7B%0A%09@Test%0A%09public void testSerdes() throws Exception%7B%0A%09%09final File tmpDir = MMapper.createTempDir();%0A%09%09final String dir = tmpDir.getCanonicalPath();%0A%09%09final AbstractDiskMap backing = new BucketDiskMap(dir);%0A%09%09final DiskMap%3CInteger, Integer%3E dmap = new DiskMap%3CInteger, Integer%3E(IntSerde.getInstance(), IntSerde.getInstance(), backing);%0A%09%09%0A%09%09final ConcurrentHashMap%3CInteger, Integer%3E hmap = new ConcurrentHashMap%3CInteger, Integer%3E();%0A%09%09final Random rng = new Random();%0A%09%09%0A%09%09//10M tries, 1M keys%0A%09%09for(int i=0; i%3C10000000; i++)%7B%0A%09%09%09final int k = rng.nextInt(1000000);%0A%09%09%09final int v = rng.nextInt(1000000);%0A%09%09%09switch (rng.nextInt(4))%7B%0A%09%09%09case 0:%0A%09%09%09%09dmap.put(k, v);%0A%09%09%09%09hmap.put(k, v);%0A%09%09%09%09break;%0A%09%09%09case 1:%0A%09%09%09%09dmap.remove(k);%0A%09%09%09%09hmap.remove(k);%0A%09%09%09%09break;%0A%09%09%09case 2:%0A%09%09%09%09dmap.replace(k, v);%0A%09%09%09%09hmap.replace(k, v);%0A%09%09%09%09break;%0A%09%09%09case 3:%0A%09%09%09%09dmap.putIfAbsent(k, v);%0A%09%09%09%09hmap.putIfAbsent(k, v);%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09for(final Integer i: dmap.keySet())%7B%0A%09%09%09assertEquals(dmap.get(i), hmap.get(i));%0A%09%09%7D%0A%09%09backing.delete();%0A%09%7D%0A%7D%0A

Test serdes and fuzz different put/remove/replace/putIfAbsent methods