public void testQuery() { createData(); EmbeddedObjectContainer database = Db4oEmbedded.openFile(aliasConfig(), tempFile()); database.query(B.class); database.query(A.class); database.close(); querydb(Db4oEmbedded.newConfiguration(), new int[] {1, 0}, A.class, B.class); }
public void test() { final EmbeddedConfiguration embeddedConfiguration = Db4oEmbedded.newConfiguration(); Assert.expect( IllegalArgumentException.class, new CodeBlock() { public void run() throws Throwable { embeddedConfiguration.common().objectClass(Object.class); } }); }
private EmbeddedConfiguration aliasConfig() { EmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration(); configuration .common() .addAlias( new TypeAlias( CrossPlatformServices.fullyQualifiedName(A.class), CrossPlatformServices.fullyQualifiedName(B.class))); return configuration; }
public <T, T1> void querydb( EmbeddedConfiguration config, int[] count, Class<T> class1, Class<T1> class2) { EmbeddedObjectContainer database = Db4oEmbedded.openFile(config, tempFile()); try { List<T> list = database.query(class1); Assert.areEqual( count[0], list.size(), "Unexpected result querying for " + class1.getSimpleName()); if (count[0] > 0) { // System.out.println("Querying for " + class1.getSimpleName() + " getting " + // list.get(0).getClass().getSimpleName()); } List<T1> list1 = database.query(class2); Assert.areEqual( count[1], list1.size(), "Unexpected result querying for " + class2.getSimpleName()); if (count[1] > 0) { // System.out.println("Querying for " + class2.getSimpleName() + " getting " + // list1.get(0).getClass().getSimpleName()); } } finally { database.close(); } }
private EmbeddedConfiguration config() { EmbeddedConfiguration config = Db4oEmbedded.newConfiguration(); config.file().storage(new MemoryStorage()); return config; }
private void assertName(EmbeddedConfiguration config, String expected) { EmbeddedObjectContainer db = Db4oEmbedded.openFile(config, FILE_NAME); Assert.areEqual(expected, db.toString()); db.close(); }
private void createData() { EmbeddedObjectContainer database = Db4oEmbedded.openFile(tempFile()); database.store(new A("Item1")); database.commit(); database.close(); }