Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.mapdb;
  
  
  import org.junit.Test;
  
  import java.io.File;
  import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 public class Serialization2Test extends TestFile {
 
 
     @Test public void test2() throws IOException {
         DB db = DBMaker.newFileDB(index).cacheDisable().asyncWriteDisable().transactionDisable().make();
 
         Serialization2Bean processView = new Serialization2Bean();
 
         Map<ObjectObjectmap =  db.getHashMap("test2");
 
         map.put("abc"processView);
 
         db.commit();
 
         Serialization2Bean retProcessView = (Serialization2Bean)map.get("abc");
         assertEquals(processViewretProcessView);
 
         db.close();
     }
 
 
     @Test public void test2_engine() throws IOException {
         DB db = DBMaker.newFileDB(index).cacheDisable().asyncWriteDisable().make();
 
         Serialization2Bean processView = new Serialization2Bean();
 
         long recid = db.engine.put(processView, (Serializer<Object>) db.getDefaultSerializer());
 
         db.commit();
 
         Serialization2Bean retProcessView = (Serialization2Beandb.engine.get(reciddb.getDefaultSerializer());
         assertEquals(processViewretProcessView);
 
         db.close();
     }
 
 
     @Test  public void test3() throws IOException {
 
 
         Serialized2DerivedBean att = new Serialized2DerivedBean();
         DB db = DBMaker.newFileDB(index).cacheDisable().asyncWriteDisable().make();
 
         Map<ObjectObjectmap =  db.getHashMap("test");
 
         map.put("att"att);
         db.commit();
         db.close();
         db = DBMaker.newFileDB(index).cacheDisable().asyncWriteDisable().make();
         map =  db.getHashMap("test");
 
 
         Serialized2DerivedBean retAtt = (Serialized2DerivedBeanmap.get("att");
         assertEquals(attretAtt);
     }
 
 
 
     static class AAA implements Serializable {
 		
     	private static final long serialVersionUID = 632633199013551846L;
 		
 		String test  = "aa";
     }
 
 
     @Test  public void testReopenWithDefrag(){
 
         File f = Utils.tempDbFile();
 
         DB db = DBMaker.newFileDB(f)
                 .transactionDisable()
                 .asyncWriteDisable()
                 .cacheDisable()
                 .checksumEnable()
                 .make();
 
         Map<Integer,AAAmap = db.getTreeMap("test");
         map.put(1,new AAA());
 
         db.compact();
         db.close();
 
         db = DBMaker.newFileDB(f)
                 .transactionDisable()
                .asyncWriteDisable()
                .cacheDisable()
                .checksumEnable()
                .make();
        map = db.getTreeMap("test");
        assertNotNull(map.get(1));
        assertEquals(map.get(1)."aa");
        db.close();
    }
New to GrepCode? Check out our FAQ X