LevelDB implements AutoCloseable { public void close() { checkDatabaseOpen(); LevelDBNative.leveldb_close(levelDB); levelDB = null; } LevelDB(String levelDBDirectory, LevelDBOptions options); void close(); byte[] get(byte[] key, LevelDBReadOptions readOptions); void put(byte[] key, byte[] value, LevelDBWriteOptions writeOptions); void write(LevelDBWriteBatch writeBatch, LevelDBWriteOptions writeOptions); void delete(byte[] key, LevelDBWriteOptions writeOptions); String property(String property); long[] approximateSizes(Range ...ranges); void compactRange(byte[] startKey, byte[] limitKey); static void repair(String levelDBDirectory, LevelDBOptions options); static void destroy(String levelDBDirectory, LevelDBOptions options); static int majorVersion(); static int minorVersion();  }
@Test public void open_and_close() { try(LevelDBOptions options = new LevelDBOptions()) { options.setCreateIfMissing(true); LevelDB levelDB = new LevelDB(testFolder.getRoot().getAbsolutePath(), options); levelDB.close(); } }
@Test public void open_and_close_twice() { try(LevelDBOptions options = new LevelDBOptions()) { options.setCreateIfMissing(true); LevelDB levelDB = new LevelDB(testFolder.getRoot().getAbsolutePath(), options); levelDB.close(); } }