JEDatabase extends AbstractDatabase { public static JEDatabase getInstance(File dataDirectory) { String key = dataDirectory.getAbsolutePath(); JEDatabase instance = databaseMap.get(key); if (instance != null) { try { instance.env.sync(); return instance; } catch (DatabaseException e) { instance.env.close(); databaseMap.remove(key); } } instance = new JEDatabase(dataDirectory); databaseMap.put(key, instance); return instance; } private  JEDatabase(File dataDirectory); static JEDatabase getInstance(File dataDirectory); @Override UserFactory getUserFactory(); @Override boolean addUser(byte[] publicKey, byte[] publicHash); @Override boolean haveUser(byte[] existingUser); @Override boolean deleteUser(User existingUser); @Override byte[] getPublicKey(byte[] publicHash); @Override User getUser(byte[] publicHash); @Override boolean checkAndAddNonce(Nonce nonce, byte[] publicKey); @Override Collection<RevValue> getRecord(User user, byte[] key); @Override RevValue getRevision(User user, byte[] key, byte[] revision); @Override Collection<byte[]> getIndices(User user); @Override Collection<byte[]> getRevisions(User user, byte[] key); @Override boolean putRecord(User user, byte[] key, byte[] revision, byte[] data); @Override boolean deleteRecord(User user, byte[] key); @Override void clearOldNonces();  }
@Test public void getInstance() throws UserNotFoundException { Database newDatabase = getDatabase(); assertEquals("Get same database", database, newDatabase); assertTrue(database.addUser(publicKey, publicHash)); User user = newDatabase.getUser(publicHash); assertNotNull(user); assertTrue(database.deleteUser(user)); }