Re: rollbackChanges in a unit test

From: Jim Menard (jim..o.com)
Date: Mon Jan 12 2004 - 10:11:24 EST

  • Next message: Andrus Adamchik: "Re: rollbackChanges in a unit test"

    On Jan 12, 2004, at 8:43 AM, I wrote:

    > I've written a unit test using JUnit. It's throwing a
    > NullPointerException during the call to context.rollbackChanges().
    > This only started happening when I added the code after the line "NPE
    > CAUSED BY THIS CODE?". Does anyone have any suggestions as to what I'm
    > doing wrong?

    Another hint: I see the same exception every time in SnapshotManager if
    I change tearDown() to

    public void tearDown() {
         context.deleteObject(metadata);
         context.rollbackChanges();
    }

    Is it wrong to delete objects that have not yet been committed? If so,
    then how do I test adding and deleting objects from a to-many list in
    my test code?

    This isn't just about test code: When a user edits something, I make a
    deep copy (registered with the context). The user may cause items to be
    added/deleted from the object's lists of other objects, so I will see
    the same situation in the code.

    Jim

    -- 
    Jim Menard, jim..o.com, http://www.io.com/~jimm/
    "Brought to you again by the Department of Redundancy Department."
         -- Firesign Theatre
    



    This archive was generated by hypermail 2.0.0 : Mon Jan 12 2004 - 10:11:33 EST