@@ -0,0 +1,3068 @@
+package org.mapdb;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Random;%0Aimport java.util.concurrent.atomic.AtomicLong;%0A%0Aimport static org.junit.Assert.*;%0A%0A@RunWith(Parameterized.class)%0A%0Apublic class WALTruncate %7B%0A%0A%0A    final int commitNum;%0A    final int cutPointSeed;%0A%0A    public WALTruncate(int commitNum, int cutPointSeed) %7B%0A        this.commitNum = commitNum;%0A        this.cutPointSeed = cutPointSeed;%0A    %7D%0A%0A    @Parameterized.Parameters%0A    public static List%3CObject%5B%5D%3E params() throws IOException %7B%0A        List ret = new ArrayList();%0A        int inc = TT.shortTest()?200:20;%0A%0A        for(int commitNum=1;commitNum%3C1000;commitNum+=inc)%7B%0A            for(int cutPointSeed=0;cutPointSeed%3C600;cutPointSeed+=inc)%7B%0A                ret.add(new Object%5B%5D%7BcommitNum, cutPointSeed%7D);%0A            %7D%0A        %7D%0A%0A        return ret;%0A    %7D%0A%0A    @Test public void test()%7B%0A        File f = TT.tempDbFile();%0A        WriteAheadLog wal = new WriteAheadLog(f.getPath());%0A%0A        for(int i=0;i%3CcommitNum;i++)%7B%0A            for(int j=0;j%3C6;j++)%7B%0A                wal.walPutLong(111L, i);%0A            %7D%0A            wal.commit();%0A        %7D%0A%0A        int cutPoint = new Random(cutPointSeed).nextInt((int) wal.curVol.length());%0A        wal.curVol.sync();%0A        wal.curVol.clear(cutPoint, wal.curVol.length());%0A        File f2 = wal.curVol.getFile();%0A        wal.close();%0A%0A        wal = new WriteAheadLog(f.getPath());%0A        final AtomicLong i = new AtomicLong();%0A        final AtomicLong c = new AtomicLong();%0A        wal.open(new WriteAheadLog.WALReplay() %7B%0A            @Override%0A            public void beforeReplayStart() %7B%0A%0A            %7D%0A%0A            @Override%0A            public void writeLong(long offset, long value) %7B%0A                assertEquals(111L, offset);%0A                assertEquals(i.get(), value);%0A                assertTrue(c.getAndIncrement()%3C6);%0A            %7D%0A%0A            @Override%0A            public void writeRecord(long recid, long walId, Volume vol, long volOffset, int length) %7B%0A                fail();%0A            %7D%0A%0A            @Override%0A            public void writeByteArray(long offset, long walId, Volume vol, long volOffset, int length) %7B%0A                fail();%0A            %7D%0A%0A            @Override%0A            public void beforeDestroyWAL() %7B%0A                fail();%0A            %7D%0A%0A            @Override%0A            public void commit() %7B%0A                assertEquals(6, c.get());%0A                c.set(0);%0A                i.incrementAndGet();%0A            %7D%0A%0A            @Override%0A            public void rollback() %7B%0A                fail();%0A            %7D%0A%0A            @Override%0A            public void writeTombstone(long recid) %7B%0A                fail();%0A            %7D%0A%0A            @Override%0A            public void writePreallocate(long recid) %7B%0A                fail();%0A            %7D%0A        %7D);%0A%0A        assertEquals(0,c.get());%0A%0A        f.delete();%0A        f2.delete();%0A    %7D%0A%7D%0A

Add crash test