Cayenne CRUD tester and found bugs (1.2M4)

From: Mikaël Cluseau (nwr..wrk.dyndns.org)
Date: Fri Jun 10 2005 - 20:48:12 EDT

  • Next message: Andrus Adamchik: "CVS notifications are down"

    I'm writing an automated CRUD tester for Cayenne (I will contribute
    it ;-)). It works well but I think I have found a quite important bug...
    I do a CRUD with the same DataContext, so :

         1. I create a DataObject (mandatory attributes and relationships
            are filled with random values).
         2. I retreive it (by a refetch() followed by a resolveHollow()).
         3. I update it (reput random values in attributes).
         4. I delete it.

    The problem is on the delete :

    ...
    context.deleteObject(obj);
    assertEquals(PersistenceState.DELETED, obj.getPersistenceState()); // <= passes
    assertTrue(context.deletedObjects().contains(obj)); // <= fails
    ...

    Also :
    assertTrue(context.hasChanges()); // <= fails
    And :
    assertFalse(context.deletedObjects().isEmpty()); // <= fails

    I may fix this bug if I get some directions, because I don't understand
    everything around ObjectStore.

    My analyse concludes that the problem doesn't come from deleteObject,
    too : deleteObject() successfully sets the state to DELETED, and setting
    the object's persistence state to DELETED eventually implies
    context.deletedObjects().isEmpty() *if* the objet is correctly
    registered in context's ObjectStore.

    And, in fact (this will the the conclusion, it's 2:42 here and I need a
    sleep now :-)), adding «context.getObjectStore().addObject(obj);» made
    the deletion work as expected. So, clearly, there is a place where the
    object is removed from the ObjectStore and a quick'n'dirty fix would be
    to replace DataContext.deleteObject(...) by :

    public void deleteObject(DataObject object) throws DeleteDenyException {
        new DataContextDeleteAction(this).performDelete(object);
        getObjectStore().addObject(object);
    }

    But this fix looks like a surface hack, and I don't really like these...

    Thanks for any better direction (or fix)! :-)
    Mikael.



    This archive was generated by hypermail 2.0.0 : Fri Jun 10 2005 - 20:48:15 EDT