DiskPersistence implements SQLitePersistence<O, A>, Closeable { @Override public long getBytesUsed() { Connection connection = null; try { connection = getConnection(null, noQueryOptions()); return DBQueries.getDatabaseSize(connection); } finally { DBUtils.closeQuietly(connection); } } protected  DiskPersistence(SimpleAttribute<O, A> primaryKeyAttribute, File file, Properties overrideProperties); @Override SimpleAttribute<O, A> getPrimaryKeyAttribute(); File getFile(); @Override Connection getConnection(Index<?> index, QueryOptions queryOptions); @Override boolean supportsIndex(Index<O> index); @Override void close(); @Override long getBytesUsed(); @Override void compact(); @Override void expand(long numBytes); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override ObjectStore<O> createObjectStore(); @Override SQLiteDiskIdentityIndex<A, O> createIdentityIndex(); @Override void openRequestScopeResources(QueryOptions queryOptions); @Override void closeRequestScopeResources(QueryOptions queryOptions); static File createTempFile(); static DiskPersistence<O, A> onPrimaryKey(SimpleAttribute<O, A> primaryKeyAttribute); static DiskPersistence<O, A> onPrimaryKeyInFile(SimpleAttribute<O, A> primaryKeyAttribute, File file); static DiskPersistence<O, A> onPrimaryKeyInFileWithProperties(SimpleAttribute<O, A> primaryKeyAttribute, File file, Properties overrideProperties);  }
@Test public void testGetBytesUsed() { DiskPersistence<Car, Integer> persistence = DiskPersistence.onPrimaryKey(Car.CAR_ID); @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(persistence); cars.addAll(CarFactory.createCollectionOfCars(50)); long bytesUsed = persistence.getBytesUsed(); Assert.assertTrue("Bytes used should be greater than zero: " + bytesUsed, bytesUsed > 0); Assert.assertTrue("Failed to delete temp file:" + persistence.getFile(), persistence.getFile().delete()); }