Skip to content

Commit

Permalink
Tests and fix for issue #131 (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaeschke committed Nov 28, 2021
1 parent 19d11a3 commit b26f2d1
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions tst/org/zoodb/test/jdo/Test_038_SchemaAutoCreate.java
Expand Up @@ -17,6 +17,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.jdo.Extent;
Expand Down Expand Up @@ -677,15 +678,15 @@ public void testSchemaAutoCreationBug_Issue_131_QueryFailure() {
pm.currentTransaction().begin();

Query q0 = pm.newQuery(TestClassTiny.class);
Collection c0 = (Collection) q0.execute();
Collection<?> c0 = (Collection<?>) q0.execute();
assertEquals(0, c0.size());

TestClassTiny t = new TestClassTiny();
t.setInt(42);
pm.makePersistent(t);

Query q1 = pm.newQuery(TestClassTiny.class);
Collection c1 = (Collection) q1.execute();
Collection<?> c1 = (Collection<?>) q1.execute();
assertEquals(1, c1.size());

pm.currentTransaction().commit();
Expand All @@ -698,15 +699,15 @@ public void testSchemaAutoCreationBug_Issue_131_QueryFailure_WithFilter() {
pm.currentTransaction().begin();

Query q0 = pm.newQuery(TestClassTiny.class, "_int == 42");
Collection c0 = (Collection) q0.execute();
Collection<?> c0 = (Collection<?>) q0.execute();
assertEquals(0, c0.size());

TestClassTiny t = new TestClassTiny();
t.setInt(42);
pm.makePersistent(t);

Query q1 = pm.newQuery(TestClassTiny.class, "_int == 42");
Collection c1 = (Collection) q1.execute();
Collection<?> c1 = (Collection<?>) q1.execute();
assertEquals(1, c1.size());

pm.currentTransaction().commit();
Expand All @@ -719,7 +720,7 @@ public void testSchemaAutoCreationBug_Issue_131_QueryFailure_WithIndex() {
pm.currentTransaction().begin();

Query q0 = pm.newQuery(TestClassTiny.class, "_int == 42");
Collection c0 = (Collection) q0.execute();
Collection<?> c0 = (Collection<?>) q0.execute();
assertEquals(0, c0.size());

TestClassTiny t = new TestClassTiny();
Expand All @@ -730,13 +731,39 @@ public void testSchemaAutoCreationBug_Issue_131_QueryFailure_WithIndex() {
schema.createIndex("_int", true);

Query q1 = pm.newQuery(TestClassTiny.class, "_int == 42");
Collection c1 = (Collection) q1.execute();
Collection<?> c1 = (Collection<?>) q1.execute();
assertEquals(1, c1.size());

pm.currentTransaction().commit();
TestTools.closePM();
}

@Test
public void testSchemaAutoCreationBug_Issue_131_QueryFailure_Extent() {
PersistenceManager pm = TestTools.openPM(props);
pm.currentTransaction().begin();

Extent<TestClassTiny> e0 = pm.getExtent(TestClassTiny.class);
Iterator<TestClassTiny> i0 = e0.iterator();
assertFalse(i0.hasNext());

TestClassTiny t = new TestClassTiny();
t.setInt(42);
pm.makePersistent(t);

ZooClass schema = ZooJdoHelper.schema(pm).getClass(TestClassTiny.class);
schema.createIndex("_int", true);

Extent<TestClassTiny> e1 = pm.getExtent(TestClassTiny.class);
Iterator<TestClassTiny> i1 = e1.iterator();
assertTrue(i1.hasNext());
i1.next();
assertFalse(i1.hasNext());

pm.currentTransaction().commit();
TestTools.closePM();
}

}

class TestClassWithArray extends ZooPC {
Expand Down

0 comments on commit b26f2d1

Please sign in to comment.