Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.mapdb;
  
  
  import org.junit.Test;
  
  import java.io.File;
  
 import static org.junit.Assert.*;
 
 public class StoreAppendTest<E extends StoreAppendextends EngineTest<E>{
 
 
     File f = Utils.tempDbFile();
 
 
     @Override
     protected E openEngine() {
         return (E) new StoreAppend();
     }
 
     @Test
     public void compact_file_deleted(){
         File f = Utils.tempDbFile();
         StoreAppend engine = new StoreAppend(f);
         File f1 = engine.getFileFromNum(0);
         File f2 = engine.getFileFromNum(1);
         long recid = engine.put(111L, .);
         Long i=0L;
         for(;i.+1000; i+=8){
             engine.update(recidi.);
         }
         i-=8;
 
         assertTrue(f1.exists());
         assertTrue(f2.exists());
         assertEquals(iengine.get(recid.));
 
         engine.commit();
         assertTrue(f1.exists());
         assertTrue(f2.exists());
         assertEquals(iengine.get(recid.));
 
         engine.compact();
         assertFalse(f1.exists());
         assertTrue(f2.exists());
         assertEquals(iengine.get(recid.));
 
         f1.delete();
         f2.delete();
 
         engine.close();
     }
 
     @Test public void delete_files_after_close(){
         File f = Utils.tempDbFile();
         File f2 = new File(f.getPath()+".0");
         DB db = DBMaker.newAppendFileDB(f).deleteFilesAfterClose().make();
 
         db.getHashMap("test").put("aa","bb");
         db.commit();
         assertTrue(f2.exists());
         db.close();
         assertFalse(f2.exists());
     }
 
     @Test public void header_created() throws IOException {
         //check offset
         RandomAccessFile raf = new RandomAccessFile(.getFileFromNum(0),"r");
         //check header
         raf.seek(0);
         assertEquals(.raf.readLong());
         //check reserved recids
         for(int recid=1;recid<=.;recid++){
             assertEquals(0, ..getLong(recid*8));
             assertEquals(recid+.,raf.read()); //packed long
             assertEquals(0+.,raf.read()); //packed long
         }
 
         assertEquals(.+.,raf.read()); //packed long
         //check recid iteration
         assertFalse(.getFreeRecids().hasNext());
     }
 
     @Test public void put(){
         long oldPos = .;
         Volume vol = .;
         assertEquals(0, vol.getUnsignedByte(oldPos));
 
         long maxRecid = .;
         long value = 11111111111111L;
         long recid = .put(value,.);
         assertEquals(maxRecid+1, recid);
         assertEquals(.recid);
 
         assertEquals(recid+.vol.getPackedLong(oldPos));
        assertEquals(8+.vol.getPackedLong(oldPos+1));
        assertEquals(valuevol.getLong(oldPos+2));
        assertEquals(Long.valueOf(oldPos+1), ..get(recid));
        .commit();
        assertEquals(oldPos+1, ..getLong(recid*8));
    }
New to GrepCode? Check out our FAQ X