Program: 98141
Project: 98141
Buggy source:
@Test public void testGenericObjectStringIndexUpdates(){
  TestTools.defineIndex(TestClass.class,"String_Node_Str",true);
  PersistenceManager pm0=TestTools.openPM();
  pm0.currentTransaction().begin();
  TestClass t1=new TestClass();
  TestClass t2=new TestClass();
  TestClass t3=new TestClass();
  t1.setString("String_Node_Str");
  t2.setString(null);
  t3.setString("String_Node_Str");
  pm0.makePersistent(t1);
  pm0.makePersistent(t2);
  pm0.makePersistent(t3);
  long oid1=(Long)pm0.getObjectId(t1);
  long oid2=(Long)pm0.getObjectId(t2);
  long oid3=(Long)pm0.getObjectId(t3);
  pm0.currentTransaction().commit();
  TestTools.closePM();
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  ZooHandle hdl01=ZooSchema.getHandle(pm,oid1);
  ZooHandle hdl02=ZooSchema.getHandle(pm,oid2);
  ZooHandle hdl03=ZooSchema.getHandle(pm,oid3);
  hdl01.setValue("String_Node_Str",null);
  hdl02.setValue("String_Node_Str","String_Node_Str");
  hdl03.setValue("String_Node_Str","String_Node_Str");
  pm.currentTransaction().commit();
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  Query q=pm.newQuery(TestClass.class,"String_Node_Str");
  Collection<?> c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(1,c.size());
  Iterator<?> it=c.iterator();
  assertEquals(oid2,pm.getObjectId(it.next()));
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(3,c.size());
  it=c.iterator();
  assertEquals(oid1,pm.getObjectId(it.next()));
  assertEquals(oid2,pm.getObjectId(it.next()));
  assertEquals(oid3,pm.getObjectId(it.next()));
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  ZooSchema.getHandle(pm,oid1).remove();
  ZooSchema.getHandle(pm,oid2).remove();
  ZooSchema.getHandle(pm,oid3).remove();
  pm.currentTransaction().commit();
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  TestTools.closePM();
}

Fixed version (ground truth):
@Test public void testGenericObjectStringIndexUpdates(){
  TestTools.defineIndex(TestClass.class,"String_Node_Str",true);
  PersistenceManager pm0=TestTools.openPM();
  pm0.currentTransaction().begin();
  TestClass t1=new TestClass();
  TestClass t2=new TestClass();
  TestClass t3=new TestClass();
  t1.setString("String_Node_Str");
  t2.setString(null);
  t3.setString("String_Node_Str");
  pm0.makePersistent(t1);
  pm0.makePersistent(t2);
  pm0.makePersistent(t3);
  long oid1=(Long)pm0.getObjectId(t1);
  long oid2=(Long)pm0.getObjectId(t2);
  long oid3=(Long)pm0.getObjectId(t3);
  pm0.currentTransaction().commit();
  TestTools.closePM();
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  ZooHandle hdl01=ZooSchema.getHandle(pm,oid1);
  ZooHandle hdl02=ZooSchema.getHandle(pm,oid2);
  ZooHandle hdl03=ZooSchema.getHandle(pm,oid3);
  assertEquals("String_Node_Str",hdl01.getAttrString("String_Node_Str"));
  assertEquals("String_Node_Str",hdl01.getValue("String_Node_Str"));
  hdl01.setValue("String_Node_Str",null);
  hdl02.setValue("String_Node_Str","String_Node_Str");
  hdl03.setValue("String_Node_Str","String_Node_Str");
  pm.currentTransaction().commit();
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  Query q=pm.newQuery(TestClass.class,"String_Node_Str");
  Collection<?> c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(1,c.size());
  Iterator<?> it=c.iterator();
  assertEquals(oid2,pm.getObjectId(it.next()));
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(3,c.size());
  it=c.iterator();
  assertEquals(oid1,pm.getObjectId(it.next()));
  assertEquals(oid3,pm.getObjectId(it.next()));
  assertEquals(oid2,pm.getObjectId(it.next()));
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(3,c.size());
  it=c.iterator();
  assertEquals(oid1,pm.getObjectId(it.next()));
  assertEquals(oid3,pm.getObjectId(it.next()));
  assertEquals(oid2,pm.getObjectId(it.next()));
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  ZooSchema.getHandle(pm,oid1).remove();
  ZooSchema.getHandle(pm,oid2).remove();
  ZooSchema.getHandle(pm,oid3).remove();
  pm.currentTransaction().commit();
  TestTools.closePM();
  pm=TestTools.openPM();
  pm.currentTransaction().begin();
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  q=pm.newQuery(TestClass.class,"String_Node_Str");
  c=(Collection<?>)q.execute();
  assertEquals(0,c.size());
  TestTools.closePM();
}