db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r325833 - in /incubator/jdo/trunk/tck20: ./ test/java/org/apache/jdo/tck/api/instancecallbacks/ test/jdo/applicationidentity/org/apache/jdo/tck/api/ test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/ test/jdo/datastoreid...
Date Mon, 17 Oct 2005 03:29:15 GMT
Author: clr
Date: Sun Oct 16 20:29:07 2005
New Revision: 325833

URL: http://svn.apache.org/viewcvs?rev=325833&view=rev
Log:
JDO-155 Add lifecycle tests

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm
Modified:
    incubator/jdo/trunk/tck20/maven.xml
    incubator/jdo/trunk/tck20/project.properties
    incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
    incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql

Modified: incubator/jdo/trunk/tck20/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/maven.xml?rev=325833&r1=325832&r2=325833&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/maven.xml (original)
+++ incubator/jdo/trunk/tck20/maven.xml Sun Oct 16 20:29:07 2005
@@ -398,8 +398,8 @@
             <not>
                 <uptodate targetfile="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}.jar">
                     <srcfiles dir="${basedir}/test/jdo/${jdo.tck.identitytype}"
-                          includes="org/apache/jdo/tck/pc/**/*.jdo, 
-                                    org/apache/jdo/tck/pc/**/jdoTest.properties"/>
+                          includes="org/apache/jdo/tck/**/*.jdo, 
+                                    org/apache/jdo/tck/**/jdoTest.properties"/>
                     <srcfiles dir="${basedir}/test/java"
                           includes="${jdo.tck.pcclasses.sources},
                                     ${jdo.tck.paclasses.sources}"/>

Modified: incubator/jdo/trunk/tck20/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/project.properties?rev=325833&r1=325832&r2=325833&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/project.properties (original)
+++ incubator/jdo/trunk/tck20/project.properties Sun Oct 16 20:29:07 2005
@@ -96,6 +96,12 @@
 # jpox dependencies
 
 jdo.tck.pcclasses.sources = \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java \
     org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java \
     org/apache/jdo/tck/pc/company/Address.java \
     org/apache/jdo/tck/pc/company/Company.java \
@@ -188,6 +194,12 @@
     org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldDate.java
 
 jdo.tck.pcclasses.files = \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach$PC.class \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear$PC.class \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete$PC.class \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach$PC.class \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad$PC.class \
+    org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore$PC.class \
     org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.class \
     org/apache/jdo/tck/pc/company/Address.class \
     org/apache/jdo/tck/pc/company/Company.class \
@@ -316,6 +328,7 @@
     org/apache/jdo/tck/api/instancecallbacks/TestParts.class
 
 jdo.tck.jdometadata.files = \
+    org/apache/jdo/tck/api/instancecallbacks/package.jdo \
     org/apache/jdo/tck/pc/company/package.jdo \
     org/apache/jdo/tck/pc/fieldtypes/AllTypes.jdo \
     org/apache/jdo/tck/pc/fieldtypes/ArrayCollections.jdo \

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,511 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.AttachLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+import javax.jdo.listener.CreateLifecycleListener;
+import javax.jdo.listener.DeleteLifecycleListener;
+import javax.jdo.listener.DetachLifecycleListener;
+import javax.jdo.listener.DirtyLifecycleListener;
+import javax.jdo.listener.LoadLifecycleListener;
+import javax.jdo.listener.StoreLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Abstract test AbstractInstanceLifecycleListener
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener lifecycle listener callback
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-1, A12.15-2, A12.15-3, A12.15-4, A12.15-5, 
+ * A12.15-6, A12.15-7, A12.15-8, A12.15-9, A12.15-10, A12.15-11, A12.15-12, 
+ * A12.15-13, A12.15-14, 
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-1 void postCreate(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is created, 
+ * during makePersistent. It is called after the instance transitions 
+ * to persistent-new.
+ * A12.15-2 void postLoad(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is loaded. 
+ * It is called after the jdoPostLoad method is invoked on the instance.
+ * A12.15-3 void preStore(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is stored, 
+ * for example during flush or commit. It is called 
+ * before the jdoPreStore method is invoked on the instance.
+ * A12.15-4 void postStore(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is stored,
+ * for example during flush or commit. It is called 
+ * after the jdoPreStore method is invoked on the instance. 
+ * An object identity for a per?sistent-new instance must have been assigned
+ * to the instance when this callback is invoked.
+ * A12.15-5 void preClear(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is cleared, for example during afterCompletion. It is called 
+ * before the jdoPreClear method is invoked on the instance.
+ * A12.15-6 void postClear(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is cleared, for example during afterCom?pletion. It is called 
+ * after the jdoPreClear method is invoked on the instance and the fields 
+ * have been cleared by the JDO implementation.
+ * A12.15-7 void preDelete(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is deleted, during deletePersistent. It is called before 
+ * the state transition and before the jdoPreDelete method 
+ * is invoked on the instance.
+ * A12.15-8 void postDelete(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is deleted, during deletePersistent. It is called 
+ * after the jdoPreDelete method is invoked on the instance
+ * and after the state transition.
+ * A12.15-9 void preDirty(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent clean instance 
+ * is first made dirty, during an operation that modifies 
+ * the value of a persistent or transactional field. It is called
+ * before the field value is changed.
+ * A12.15-10 void postDirty(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent clean instance 
+ * is first made dirty, during an operation that modifies 
+ * the value of a persistent or transactional field. It is called
+ * after the field value was changed.
+ * A12.15-11 void preDetach(InstanceLifecycleEvent event); 
+ * This method is called before a persistent instance is copied 
+ * for detachment.
+ * A12.15-12 void postDetach(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is copied 
+ * for detachment. 
+ * The source instance is the detached copy; the target instance
+ * is the persistent instance.
+ * A12.15-13 void preAttach(InstanceLifecycleEvent event); 
+ * This method is called before a detached instance is attached. 
+ * The source instance is the detached instance].
+ * A12.15-14 void postAttach(InstanceLifecycleEvent event);
+ * This method is called after a detached instance is attached. 
+ * The source instance is the corresponding persistent instance in the cache;
+ * the target instance is the detached instance.
+ *
+ * This is the abstract base class for the lifecycle listener test classes.
+ * It contains constants, variables, and methods used by each listener test
+ * class. This class implements the setup and teardown methods used by each
+ * concrete test class.
+ *
+ * This class also includes the listener base class that is extended by
+ * each specific listener. 
+ *
+ * The strategy of each test case is the same. A specific listener is
+ * implemented that responds only to events for that specific test; a
+ * specific persistence-capable class is also implemented, that responds
+ * only to callbacks for the specific test. A sequence of operations that
+ * stimulates the callbacks is executed. During these operations, listener
+ * events and callbacks are collected by the listener instance. Finally,
+ * the actual events and callbacks that were collected are analyzed and
+ * differences are reported.
+ */
+
+public abstract class AbstractInstanceLifecycleListener extends JDO_Test {
+
+    /** */
+    protected static final String ASSERTION1_FAILED = 
+        "Assertion A12.15-1 (TestInstanceLifecycleListenerCreate) failed: ";
+    protected static final String ASSERTION2_FAILED = 
+        "Assertion A12.15-2 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION3_FAILED = 
+        "Assertion A12.15-3 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION4_FAILED = 
+        "Assertion A12.15-4 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION5_FAILED = 
+        "Assertion A12.15-5 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION6_FAILED = 
+        "Assertion A12.15-6 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION7_FAILED = 
+        "Assertion A12.15-7 (TestInstanceLifecycleListenerDelete) failed: ";
+    protected static final String ASSERTION8_FAILED = 
+        "Assertion A12.15-8 (TestInstanceLifecycleListenerDelete) failed: ";
+    protected static final String ASSERTION9_FAILED = 
+        "Assertion A12.15-9 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION10_FAILED = 
+        "Assertion A12.15-10 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION11_FAILED = 
+        "Assertion A12.15-11 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION12_FAILED = 
+        "Assertion A12.15-12 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION13_FAILED = 
+        "Assertion A12.15-13 (TestInstanceLifecycleListener) failed: ";
+    protected static final String ASSERTION14_FAILED = 
+        "Assertion A12.15-14 (TestInstanceLifecycleListener) failed: ";
+
+    /** 
+     * The listener to be used for the test. This method is implemented
+     * by the subclasses to use the proper listener.
+     */
+    protected abstract InstanceLifecycleListenerImpl getListener();
+
+    /** 
+     * The classes to be used for the test. This method is implemented
+     * by the subclasses to use the proper classes. The classes returned
+     * by this method are used for two purposes: they are used to register
+     * listeners; and they are used as the teardown classes whose instances
+     * are removed from the datastore at the end of the test.
+     */
+    protected abstract Class[] getPersistentClasses();
+
+    /** 
+     * Register a new InstanceLifecycleListenerImpl with the 
+     * PersistenceManager.
+     */
+    protected void addListener() {
+        getPM();
+        pm.addInstanceLifecycleListener(getListener(), getPersistentClasses());
+    }
+    
+    /**
+     * Unregister the InstanceLifecycleListenerImpl with the 
+     * PersistenceManager.
+     */
+    protected void removeListener() {
+        getPM();
+        pm.removeInstanceLifecycleListener(getListener());
+    }
+
+    /** 
+     * Set up for lifecycle tests:
+     * Register the LifecycleListener; add PCPoint to tearDownClasses.
+     */
+    protected void localSetUp() {
+        addListener();
+        addTearDownClass(getPersistentClasses());
+    }
+
+    /**
+     * Clean up after lifecycle tests:
+     * Unregister the LifecycleListener.
+     */
+    protected void localTearDown() {
+        removeListener();
+    }
+
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager. This is the base class that is extended 
+     * by each test.
+     */
+    protected abstract static class InstanceLifecycleListenerImpl 
+            implements AttachLifecycleListener, ClearLifecycleListener,
+            CreateLifecycleListener, DeleteLifecycleListener,
+            DetachLifecycleListener, DirtyLifecycleListener,
+            LoadLifecycleListener, StoreLifecycleListener {
+
+        protected InstanceLifecycleListenerImpl() {}
+
+        protected Object expectedSource = null;
+        protected Object expectedTarget = null;
+        
+        public void setExpectedSource(Object source) {
+            expectedSource = source;
+        }
+
+        public void setExpectedTarget(Object target) {
+            expectedTarget = target;
+        }
+
+        /** 
+         * This is the list names of locations for listener events and 
+         * callbacks. Each instance of an event or callback has a specific 
+         * name that is associated with the value. The values
+         * are used during collection of events and both names and values
+         * are used for reporting results.
+         */
+        private static List locations = new ArrayList();
+
+        /** These are indexes into the sequence array. Each index
+         * represents the position in the sequence array for the
+         * corresponding callback or listener event.
+         */
+        public static final int PRE_ATTACH_CALLBACK;
+        public static final int POST_ATTACH_CALLBACK;
+        public static final int PRE_ATTACH_LISTENER;
+        public static final int POST_ATTACH_LISTENER;
+        public static final int PRE_CLEAR_CALLBACK;
+        public static final int PRE_CLEAR_LISTENER;
+        public static final int POST_CLEAR_LISTENER;
+        public static final int POST_CREATE_LISTENER;
+        public static final int PRE_DELETE_CALLBACK;
+        public static final int PRE_DELETE_LISTENER;
+        public static final int POST_DELETE_LISTENER;
+        public static final int PRE_DETACH_CALLBACK;
+        public static final int POST_DETACH_CALLBACK;
+        public static final int PRE_DETACH_LISTENER;
+        public static final int POST_DETACH_LISTENER;
+        public static final int PRE_DIRTY_LISTENER;
+        public static final int POST_DIRTY_LISTENER;
+        public static final int POST_LOAD_CALLBACK;
+        public static final int POST_LOAD_LISTENER;
+        public static final int PRE_STORE_CALLBACK;
+        public static final int PRE_STORE_LISTENER;
+        public static final int POST_STORE_LISTENER;
+
+        /**
+         * Initialize the list of names and the associated values. For each
+         * listener event and callback, add the name and then assign the value.
+         */
+        static {
+            int index = 0;
+            locations.add("PRE_ATTACH_LISTENER");
+            PRE_ATTACH_LISTENER = index++;
+            locations.add("PRE_ATTACH_CALLBACK");
+            PRE_ATTACH_CALLBACK = index++;
+            locations.add("POST_ATTACH_CALLBACK");
+            POST_ATTACH_CALLBACK = index++;
+            locations.add("POST_ATTACH_LISTENER");
+            POST_ATTACH_LISTENER = index++;
+            locations.add("PRE_CLEAR_LISTENER");
+            PRE_CLEAR_LISTENER = index++;
+            locations.add("PRE_CLEAR_CALLBACK");
+            PRE_CLEAR_CALLBACK = index++;
+            locations.add("POST_CLEAR_LISTENER");
+            POST_CLEAR_LISTENER = index++;
+            locations.add("POST_CREATE_LISTENER");
+            POST_CREATE_LISTENER = index++;
+            locations.add("PRE_DELETE_LISTENER");
+            PRE_DELETE_LISTENER = index++;
+            locations.add("PRE_DELETE_CALLBACK");
+            PRE_DELETE_CALLBACK = index++;
+            locations.add("POST_DELETE_LISTENER");
+            POST_DELETE_LISTENER = index++;
+            locations.add("POST_DETACH_CALLBACK");
+            POST_DETACH_CALLBACK = index++;
+            locations.add("PRE_DETACH_LISTENER");
+            PRE_DETACH_LISTENER = index++;
+            locations.add("PRE_DETACH_CALLBACK");
+            PRE_DETACH_CALLBACK = index++;
+            locations.add("POST_DETACH_LISTENER");
+            POST_DETACH_LISTENER = index++;
+            locations.add("PRE_DIRTY_LISTENER");
+            PRE_DIRTY_LISTENER = index++;
+            locations.add("POST_DIRTY_LISTENER");
+            POST_DIRTY_LISTENER = index++;
+            locations.add("POST_LOAD_CALLBACK");
+            POST_LOAD_CALLBACK = index++;
+            locations.add("POST_LOAD_LISTENER");
+            POST_LOAD_LISTENER = index++;
+            locations.add("PRE_STORE_LISTENER");
+            PRE_STORE_LISTENER = index++;
+            locations.add("PRE_STORE_CALLBACK");
+            PRE_STORE_CALLBACK = index++;
+            locations.add("POST_STORE_LISTENER");
+            POST_STORE_LISTENER = index++;
+        }
+
+        private int[] actual = new int[locations.size()];
+
+        /** Track the current sequence of callbacks.
+         */
+        private int current = 0;
+
+        public void notifyEvent(int event) {
+            actual[event] = ++current;
+        }
+
+        /**
+         * Initialize the expected ordering of callbacks and listeners.
+         * Each entry in the sequence is one of the PRE_ or POST_XXX_LISTENER
+         * or _CALLBACK above. The order in the sequence is the expected
+         * calling order.
+         */
+        private static int[] newExpected(int[] sequence) {
+            int order = 0;
+            int[] result = new int[locations.size()];
+            for (int i = 0; i < sequence.length; ++i) {
+                result[sequence[i]] = ++order;
+            }
+            return result;
+        }
+
+        /** 
+         * The error message buffer to report exceptions.
+         */
+        protected StringBuffer messages = new StringBuffer();
+        
+        protected void checkEventType(String where, int expected, int actual) {
+            if (expected != actual) {
+                messages.append(where + "wrong event type: " +
+                        "expected <" + expected +
+                        ">, actual <" + actual + ">\n");
+            }
+        }
+        
+        protected void checkEventSource(String where, Object eventSource) {
+            if (expectedSource != eventSource) {
+                messages.append(where + "wrong event source: " +
+                        "expected <" + expectedSource +
+                        ">, actual <" + eventSource + ">\n");
+            }            
+        }
+
+        protected void checkEventTarget(String where, Object eventTarget) {
+            if (expectedTarget != eventTarget) {
+                messages.append(where + "wrong event target: " +
+                        "expected <" + expectedTarget +
+                        ">, actual <" + eventTarget + ">\n");
+            }            
+        }
+
+        protected void checkTrue(String where, boolean condition) {
+            if (!condition) {
+                messages.append(where + "was not true.\n");
+            }
+        }
+
+        protected void checkSame(String where, 
+                Object expected, Object actual) {
+            if (expected != actual) {
+                messages.append(where + 
+                        "expected <" + expected +
+                        ">, actual <" + actual + ">\n");
+            }            
+        }
+
+        protected void checkPersistent(String where, Object obj) {
+            if (!JDOHelper.isPersistent(obj)) {
+                messages.append(where + "object should be persistent.\n");
+            }
+        }
+
+        protected void checkNotPersistent(String where, Object obj) {
+            if (JDOHelper.isPersistent(obj)) {
+                messages.append(where + "object should not be persistent.\n");
+            }
+        }
+
+        protected void checkDirty(String where, Object obj) {
+            if (!JDOHelper.isDirty(obj)) {
+                messages.append(where + "object should be dirty.\n");
+            }
+        }
+
+        protected void checkNotDirty(String where, Object obj) {
+            if (JDOHelper.isDirty(obj)) {
+                messages.append(where + "object should not be dirty.\n");
+            }
+        }
+
+        protected void checkNew(String where, Object obj) {
+            if (!JDOHelper.isNew(obj)) {
+                messages.append(where + "object should be new.\n");
+            }
+        }
+
+        protected void checkNotNew(String where, Object obj) {
+            if (JDOHelper.isNew(obj)) {
+                messages.append(where + "object should not be new.\n");
+            }
+        }
+
+        protected void checkDeleted(String where, Object obj) {
+            if (!JDOHelper.isDeleted(obj)) {
+                messages.append(where + "object should be deleted.\n");
+            }
+        }
+
+        protected void checkNotDeleted(String where, Object obj) {
+            if (JDOHelper.isDeleted(obj)) {
+                messages.append(where + "object should not be deleted.\n");
+            }
+        }
+
+        /** 
+         * Verify the actual sequence of callbacks and listeners
+         * against the expected. Each of the expected and actual are
+         * int arrays in which each listener and callback have one
+         * position in the array and the value of the array at that
+         * position is the order, starting with 1, of the callback.
+         * If the callback or listener was never invoked, the value
+         * is 0.
+         */
+        public void verifyCallbacks(String where, int[] expected) {
+            int[] expectedSequence = newExpected(expected);
+            for (int index = 0; index < locations.size(); ++index) {
+                if (expectedSequence[index] != actual[index]) {
+                    messages.append("\nSequence verification failed for " +
+                            locations.get(index) + 
+                            "; expected: <" + expectedSequence[index] +
+                            "> actual: <" + actual[index] +
+                            ">\n");
+                }
+            }
+            if (messages.length() > 0) {
+                fail(where + "\n" + messages.toString());
+            }
+        }
+
+        public void postAttach(InstanceLifecycleEvent event) {
+        }
+
+        public void postClear(InstanceLifecycleEvent event) {
+        }
+
+        public void postCreate(InstanceLifecycleEvent event) {
+        }
+
+        public void postDelete(InstanceLifecycleEvent event) {
+        }
+
+        public void postDetach(InstanceLifecycleEvent event) {
+        }
+
+        public void postDirty(InstanceLifecycleEvent event) {
+        }
+
+        public void postLoad(InstanceLifecycleEvent event) {
+        }
+
+        public void postStore(InstanceLifecycleEvent event) {
+        }
+
+        public void preAttach(InstanceLifecycleEvent event) {
+        }
+
+        public void preClear(InstanceLifecycleEvent event) {
+        }
+
+        public void preDelete(InstanceLifecycleEvent event) {
+        }
+
+        public void preDetach(InstanceLifecycleEvent event) {
+        }
+
+        public void preDirty(InstanceLifecycleEvent event) {
+        }
+
+        public void preStore(InstanceLifecycleEvent event) {
+        }
+        
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.AttachCallback;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test TestInstanceLifecycleListenerAttach
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener preAttach postAttach
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-13 A12.15-14
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-13 void preAttach(InstanceLifecycleEvent event); 
+ * This method is called before a detached instance is attached. 
+ * The source instance is the detached instance].
+ * A12.15-14 void postAttach(InstanceLifecycleEvent event);
+ * This method is called after a detached instance is attached. 
+ * The source instance is the corresponding persistent instance in the cache;
+ * the target instance is the detached instance.
+ */
+
+public class InstanceLifecycleListenerAttach 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerAttachImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerAttach.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and detaches it.
+     * The instance is attached in a new transaction, which causes
+     * the attach callbacks and listeners to be called.
+     */
+    public void testAttach() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(pc);
+        PC detached = (PC)pm.detachCopy(pc);
+        pm.currentTransaction().commit();
+        pm.currentTransaction().begin();
+        listener.setExpectedSource(detached);
+        // attachCopy should cause the attach listeners to be called
+        PC attached = (PC)pm.attachCopy(detached, false);
+        pm.currentTransaction().commit();
+
+        // now check the callback and listener were called
+        listener.verifyCallbacks(ASSERTION13_FAILED, new int[] {
+                listener.PRE_ATTACH_LISTENER,
+                listener.PRE_ATTACH_CALLBACK,
+                listener.POST_ATTACH_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerAttachImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preAttach(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_ATTACH_LISTENER);
+            checkEventType(ASSERTION13_FAILED,
+                    InstanceLifecycleEvent.ATTACH, event.getEventType());
+            checkEventSource(ASSERTION13_FAILED, event.getSource());
+        }
+
+        public void postAttach(InstanceLifecycleEvent event) {
+            notifyEvent(POST_ATTACH_LISTENER);
+            checkEventType(ASSERTION14_FAILED,
+                    InstanceLifecycleEvent.ATTACH, event.getEventType());
+            checkPersistent(ASSERTION14_FAILED + "in postAttach, source ",
+                    event.getSource());
+            checkTrue(ASSERTION14_FAILED + 
+                    "in postAttach, source wasPostAttachCalled() ",
+                    ((PC)event.getSource()).wasPostAttachCalled());
+            checkSame(ASSERTION14_FAILED + "in postAttach, target ",
+                    expectedSource, event.getTarget());
+        }
+
+    }
+
+    /** The persistence-capable class that implements the attach callback.
+     */
+    public static class PC implements AttachCallback {
+        transient InstanceLifecycleListenerImpl listener;
+
+        transient boolean postAttachCalled = false;
+        public boolean wasPostAttachCalled() {
+            return postAttachCalled;
+        }
+        
+        transient Object postAttachObject = null;
+        public Object getPostAttachObject() {
+            return postAttachObject;
+        }
+
+        int id; 
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        public void jdoPreAttach() {
+            if (listener == null)
+                return;
+            listener.notifyEvent(listener.PRE_ATTACH_CALLBACK);
+        }
+        public void jdoPostAttach(Object obj) {
+            postAttachCalled = true;
+            postAttachObject = obj;
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.ClearCallback;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test TestInstanceLifecycleListenerClear
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener hollow preClear postClear
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-5 A12.15-6
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-5 void preClear(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is cleared, for example during afterCompletion. It is called 
+ * before the jdoPreClear method is invoked on the instance.
+ * A12.15-6 void postClear(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is cleared, for example during afterCompletion. It is called 
+ * after the jdoPreClear method is invoked on the instance and the fields 
+ * have been cleared by the JDO implementation.
+ */
+
+public class InstanceLifecycleListenerClear 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerClearImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerClear.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and commits it.
+     * Since the RetainValues flag is set to false, the persistent
+     * fields will be cleared, and the pre-clear listener,
+     * pre-clear callback, and post-clear listener will be called.
+     */
+    public void testClear() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+        listener.setExpectedSource(pc);
+
+        // commit should cause the clear listeners to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.currentTransaction().setRetainValues(false);
+        pm.makePersistent(pc);
+        pm.currentTransaction().commit();
+
+        // now check the callback and listeners were called
+        listener.verifyCallbacks(ASSERTION5_FAILED, new int[] {
+                listener.PRE_CLEAR_LISTENER,
+                listener.PRE_CLEAR_CALLBACK,
+                listener.POST_CLEAR_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerClearImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preClear(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_CLEAR_LISTENER);
+            checkEventType(ASSERTION5_FAILED, 
+                    InstanceLifecycleEvent.CLEAR, event.getEventType());
+            checkEventSource(ASSERTION5_FAILED, event.getSource());
+            checkPersistent(ASSERTION5_FAILED + " in preClear, ", 
+                    expectedSource);
+        }
+
+        public void postClear(InstanceLifecycleEvent event) {
+            notifyEvent(POST_CLEAR_LISTENER);
+            checkEventType(ASSERTION6_FAILED, 
+                    InstanceLifecycleEvent.CLEAR, event.getEventType());
+            checkEventSource(ASSERTION6_FAILED, event.getSource());
+            checkPersistent(ASSERTION6_FAILED + " in postClear, ",
+                    expectedSource);
+        }
+
+    }
+
+    /** The persistence-capable class that implements the clear callback.
+     */
+    public static class PC implements ClearCallback {
+        transient InstanceLifecycleListenerImpl listener;
+        int id; 
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        public void jdoPreClear() {
+            listener.notifyEvent(listener.PRE_CLEAR_CALLBACK);
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.AttachLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+import javax.jdo.listener.CreateLifecycleListener;
+import javax.jdo.listener.DeleteLifecycleListener;
+import javax.jdo.listener.DetachLifecycleListener;
+import javax.jdo.listener.LoadLifecycleListener;
+import javax.jdo.listener.StoreLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test TestInstanceLifecycleListener
+ * <BR>
+ * <B>Keywords:</B> addLifeCycleListener removeLifeCycleListener
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-1
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-1 void postCreate(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is created, 
+ * during makePersistent. It is called after the instance transitions 
+ * to persistent-new.
+ */
+
+public class InstanceLifecycleListenerCreate 
+        extends AbstractInstanceLifecycleListener {
+
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerCreateImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PCPoint.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerCreate.class);
+    }
+
+    /** */
+    public void testCreate() {
+
+        // set up the persistent instance
+        PCPoint point = new PCPoint(12, 15);
+        listener.setExpectedSource(point);
+
+        // makePersistent should cause the create listener to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(point);
+        pm.currentTransaction().commit();
+
+        // verify that the listener was called
+        listener.verifyCallbacks(ASSERTION1_FAILED, new int[] {
+                listener.POST_CREATE_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener class to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerCreateImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void postCreate(InstanceLifecycleEvent event) {
+            notifyEvent(POST_CREATE_LISTENER);
+            checkEventType(ASSERTION1_FAILED,
+                    InstanceLifecycleEvent.CREATE, event.getEventType());
+            checkEventSource(ASSERTION1_FAILED, event.getSource());
+            checkPersistent(ASSERTION1_FAILED + " in postCreate, ",
+                    expectedSource);
+            checkNew(ASSERTION1_FAILED + " in postCreate, ",
+                    expectedSource);
+        }
+
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.DeleteCallback;
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.DeleteLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test TestInstanceLifecycleListenerDelete
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener deletePersistent preDelete postDelete
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-7 A12.15-8
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-7 void preDelete(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is deleted, during deletePersistent. It is called before 
+ * the state transition and before the jdoPreDelete method 
+ * is invoked on the instance.
+ * A12.15-8 void postDelete(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance 
+ * is deleted, during deletePersistent. It is called 
+ * after the jdoPreDelete method is invoked on the instance
+ * and after the state transition.
+ */
+
+public class InstanceLifecycleListenerDelete 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerDeleteImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerDelete.class);
+    }
+
+    /**
+     * This test creates a new persistent instance, and deletes it.
+     * The pre-delete listener, pre-delete callback, and post-delete
+     * listener will be called.
+     */
+    public void testDelete() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+        listener.setExpectedSource(pc);
+
+        // deletePersistent should cause the delete listeners to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(pc);
+        pm.deletePersistent(pc);
+        pm.currentTransaction().commit();
+
+        // now check the callback and listeners were called
+        listener.verifyCallbacks(ASSERTION7_FAILED, (new int[] {
+                listener.PRE_DELETE_LISTENER,
+                listener.PRE_DELETE_CALLBACK,
+                listener.POST_DELETE_LISTENER}));
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerDeleteImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preDelete(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_DELETE_LISTENER);
+            checkEventType(ASSERTION7_FAILED,
+                    InstanceLifecycleEvent.DELETE, event.getEventType());
+            checkEventSource(ASSERTION7_FAILED, event.getSource());
+            checkPersistent(ASSERTION7_FAILED + " in preDelete, ",
+                    expectedSource);
+            checkNotDeleted(ASSERTION7_FAILED + " in preDelete, ",
+                    expectedSource);
+        }
+
+        public void postDelete(InstanceLifecycleEvent event) {
+            notifyEvent(POST_DELETE_LISTENER);
+            checkEventType(ASSERTION8_FAILED,
+                    InstanceLifecycleEvent.DELETE, event.getEventType());
+            checkEventSource(ASSERTION8_FAILED, event.getSource());
+            checkPersistent(ASSERTION8_FAILED + " in postDelete, ",
+                    expectedSource);
+            checkDeleted(ASSERTION8_FAILED + " in postDelete, ",
+                    expectedSource);
+        }
+    }
+
+    /** The persistence-capable class that implements the delete callback.
+     */
+    public static class PC implements DeleteCallback {
+        transient InstanceLifecycleListenerImpl listener;
+        int id; 
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        public void jdoPreDelete() {
+            listener.notifyEvent(listener.PRE_DELETE_CALLBACK);
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.DetachCallback;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test InstanceLifecycleListenerDetach
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener preDetach postDetach
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-11 A12.15-12
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-11 void preDetach(InstanceLifecycleEvent event); 
+ * This method is called before a persistent instance is copied 
+ * for detachment.
+ * A12.15-12 void postDetach(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is copied 
+ * for detachment. 
+ * The source instance is the detached copy; the target instance
+ * is the persistent instance.
+ */
+
+public class InstanceLifecycleListenerDetach 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerDetachImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerLoad.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and commits it.
+     * Since the RetainValues flag is set to false, the persistent
+     * fields will be cleared, and the pre-clear listener,
+     * pre-clear callback, and post-clear listener will be called.
+     */
+    public void testDetach() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+        listener.setExpectedSource(pc);
+
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(pc);
+        // detachCopy should cause the detach listeners to be called
+        PC detached = (PC)pm.detachCopy(pc);
+        pm.currentTransaction().commit();
+
+        // now check the callback and listener were called
+        listener.verifyCallbacks(ASSERTION11_FAILED, new int[] {
+                listener.PRE_DETACH_LISTENER,
+                listener.PRE_DETACH_CALLBACK,
+                listener.POST_DETACH_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerDetachImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preDetach(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_DETACH_LISTENER);
+            checkEventType(ASSERTION11_FAILED,
+                    InstanceLifecycleEvent.DETACH, event.getEventType());
+            checkEventSource(ASSERTION11_FAILED, event.getSource());
+            checkPersistent(ASSERTION11_FAILED + "in preDetach, source ",
+                    event.getSource());
+        }
+
+        public void postDetach(InstanceLifecycleEvent event) {
+            notifyEvent(POST_DETACH_LISTENER);
+            checkEventType(ASSERTION12_FAILED,
+                    InstanceLifecycleEvent.DETACH, event.getEventType());
+            checkSame(ASSERTION12_FAILED + "in postDetach, target ",
+                    expectedSource, event.getTarget());
+            checkNotPersistent(ASSERTION12_FAILED + "in postDetach, source ",
+                    event.getSource());
+            checkPersistent(ASSERTION12_FAILED + "in postDetach, target ",
+                    event.getTarget());
+            checkTrue(ASSERTION12_FAILED + 
+                    "in postDetach, source wasPostDetachCalled() ",
+                    ((PC)event.getSource()).wasPostDetachCalled());
+        }
+
+    }
+
+    /** The persistence-capable class that implements the load callback.
+     */
+    public static class PC implements DetachCallback {
+        transient InstanceLifecycleListenerImpl listener;
+        int id; 
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        transient boolean postDetachCalled = false;
+        public boolean wasPostDetachCalled() {
+            return postDetachCalled;
+        }
+
+        transient Object postDetachObject = null;
+        public Object getPostDetachObject() {
+            return postDetachObject;
+        }
+ 
+        public void jdoPreDetach() {
+            if (listener == null)
+                return;
+            listener.notifyEvent(listener.PRE_DETACH_CALLBACK);
+        }
+        public void jdoPostDetach(Object obj) {
+            postDetachCalled = true;
+            postDetachObject = obj;
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test InstanceLifecycleListenerDirty
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener preDirty postDirty
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-9 A12.15-10
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-9 void preDirty(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent clean instance 
+ * is first made dirty, during an operation that modifies 
+ * the value of a persistent or transactional field. It is called
+ * before the field value is changed.
+ * A12.15-10 void postDirty(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent clean instance 
+ * is first made dirty, during an operation that modifies 
+ * the value of a persistent or transactional field. It is called
+ * after the field value was changed.
+ */
+
+public class InstanceLifecycleListenerDirty 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerDirtyImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PCPoint.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerDirty.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and commits it.
+     * A new transaction is started and a persistent field is modified.
+     * This will call the dirty listeners.
+     */
+    public void testDirty() {
+
+        // set up the persistent instance
+        PCPoint pc = new PCPoint(100, 200);
+        listener.setExpectedSource(pc);
+
+        // setY should cause the dirty listeners to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(pc);
+        pm.currentTransaction().commit();
+        pm.currentTransaction().begin();
+        pc.setY(new Integer(666));
+        pm.currentTransaction().commit();
+
+        // now check the callback and listener were called
+        listener.verifyCallbacks(ASSERTION10_FAILED, new int[] {
+                listener.PRE_DIRTY_LISTENER,
+                listener.POST_DIRTY_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerDirtyImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preDirty(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_DIRTY_LISTENER);
+            checkEventType(ASSERTION9_FAILED,
+                    InstanceLifecycleEvent.DIRTY, event.getEventType());
+            checkEventSource(ASSERTION9_FAILED, event.getSource());
+            checkPersistent(ASSERTION9_FAILED + " in preDirty, ",
+                    expectedSource);
+            checkNotDirty(ASSERTION9_FAILED + " in preDirty, ",
+                    expectedSource);
+        }
+
+        public void postDirty(InstanceLifecycleEvent event) {
+            notifyEvent(POST_DIRTY_LISTENER);
+            checkEventType(ASSERTION10_FAILED,
+                    InstanceLifecycleEvent.DIRTY, event.getEventType());
+            checkEventSource(ASSERTION10_FAILED, event.getSource());
+            checkPersistent(ASSERTION10_FAILED + " in postDirty,",
+                    expectedSource);
+            checkDirty(ASSERTION9_FAILED + " in postDirty, ",
+                    expectedSource);
+        }
+
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.LoadCallback;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test InstanceLifecycleListenerLoad
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener postLoad
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-2
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-2 void postLoad(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is loaded. 
+ * It is called after the jdoPostLoad method is invoked on the instance.
+ */
+
+public class InstanceLifecycleListenerLoad 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerLoadImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerLoad.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and commits it.
+     * In a new transaction, a value is accessed, which causes the
+     * instance to be loaded.
+     */
+    public void testLoad() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+        listener.setExpectedSource(pc);
+
+        // field access should cause the load listeners to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.currentTransaction().setRetainValues(false);
+        pm.makePersistent(pc);
+        pm.currentTransaction().commit();
+        pm.currentTransaction().begin();
+        pc.getValue();
+        pm.currentTransaction().commit();
+
+        // now check the callback and listener were called
+        listener.verifyCallbacks(ASSERTION2_FAILED, new int[] {
+                listener.POST_LOAD_CALLBACK,
+                listener.POST_LOAD_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerLoadImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void postLoad(InstanceLifecycleEvent event) {
+            notifyEvent(POST_LOAD_LISTENER);
+            checkEventType(ASSERTION2_FAILED,
+                    InstanceLifecycleEvent.LOAD, event.getEventType());
+            checkEventSource(ASSERTION2_FAILED, event.getSource());
+            checkPersistent(ASSERTION2_FAILED + " in postLoad, ",
+                    expectedSource);
+            checkNotNew(ASSERTION2_FAILED + " in postLoad, ",
+                    expectedSource);
+        }
+
+    }
+
+    /** The persistence-capable class that implements the load callback.
+     */
+    public static class PC implements LoadCallback {
+        transient InstanceLifecycleListenerImpl listener;
+        int id; 
+        int value;
+        public int getValue() {
+            return value;
+        }
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        public void jdoPostLoad() {
+            listener.notifyEvent(listener.POST_LOAD_CALLBACK);
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java Sun Oct 16 20:29:07 2005
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.listener.StoreCallback;
+
+import javax.jdo.JDOHelper;
+
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+
+import org.apache.jdo.tck.JDO_Test;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ * <B>Title:</B> Test InstanceLifecycleListenerLoad
+ * <BR>
+ * <B>Keywords:</B> LifeCycleListener preStore postStore
+ * <BR>
+ * <B>Assertion IDs:</B> A12.15-3 A12.15-4
+ * <BR>
+ * <B>Assertion Description: </B>
+ * A12.15-3 void preStore(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is stored, 
+ * for example during flush or commit. It is called 
+ * before the jdoPreStore method is invoked on the instance.
+ * A12.15-4 void postStore(InstanceLifecycleEvent event); 
+ * This method is called whenever a persistent instance is stored,
+ * for example during flush or commit. It is called 
+ * after the jdoPreStore method is invoked on the instance. 
+ * An object identity for a per?sistent-new instance must have been assigned
+ * to the instance when this callback is invoked.
+ */
+
+public class InstanceLifecycleListenerStore 
+        extends AbstractInstanceLifecycleListener {
+
+    
+    /**
+     * The InstanceLifecycleListener used for this test
+     */
+    InstanceLifecycleListenerImpl listener = 
+            new InstanceLifecycleListenerStoreImpl();
+
+    /** Return the listener.
+     */
+    protected InstanceLifecycleListenerImpl getListener() {
+        return listener;
+    }
+
+    /**
+     * The persistent classes used for this test.
+     */
+    private static Class[] persistentClasses = new Class[] {PC.class};
+
+    /** Return the persistent classes.
+     */
+    protected Class[] getPersistentClasses() {
+        return persistentClasses;
+    }
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(InstanceLifecycleListenerStore.class);
+    }
+
+    /** 
+     * This test creates a new persistent instance and commits it.
+     * The store callback and listeners will be called.
+     */
+    public void testStore() {
+
+        // set up the persistent instance
+        PC pc = new PC(listener);
+        listener.setExpectedSource(pc);
+
+        // commit should cause the store listeners to be called
+        getPM();
+        pm.currentTransaction().begin();
+        pm.makePersistent(pc);
+        pm.currentTransaction().commit();
+
+        // now check the callback and listener were called
+        listener.verifyCallbacks(ASSERTION2_FAILED, new int[] {
+                listener.PRE_STORE_LISTENER,
+                listener.PRE_STORE_CALLBACK,
+                listener.POST_STORE_LISTENER});
+    }
+    
+    /** 
+     * The LifeCycleListener to be registered with the 
+     * PersistenceManager.
+     */
+    private static class InstanceLifecycleListenerStoreImpl 
+            extends InstanceLifecycleListenerImpl {
+
+        public void preStore(InstanceLifecycleEvent event) {
+            notifyEvent(PRE_STORE_LISTENER);
+            checkEventType(ASSERTION3_FAILED,
+                    InstanceLifecycleEvent.STORE, event.getEventType());
+            checkEventSource(ASSERTION3_FAILED, event.getSource());
+            checkPersistent(ASSERTION3_FAILED + " in preStore, ",
+                    expectedSource);
+        }
+
+        public void postStore(InstanceLifecycleEvent event) {
+            notifyEvent(POST_STORE_LISTENER);
+            checkEventType(ASSERTION4_FAILED,
+                    InstanceLifecycleEvent.STORE, event.getEventType());
+            checkEventSource(ASSERTION4_FAILED, event.getSource());
+            checkPersistent(ASSERTION4_FAILED + " in postStore, ",
+                    expectedSource);
+        }
+
+    }
+
+    /** The persistence-capable class that implements the load callback.
+     */
+    public static class PC implements StoreCallback {
+        transient InstanceLifecycleListenerImpl listener;
+        int id; 
+        public PC() {
+        }
+        public PC(InstanceLifecycleListenerImpl listener) {
+            id = counter++;
+            this.listener = listener;
+        }
+        static int counter = (int)(new Date().getTime());
+
+        public void jdoPreStore() {
+            listener.notifyEvent(listener.PRE_STORE_CALLBACK);
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo Sun Oct 16 20:29:07 2005
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains the persistence information for persistence-capable classes 
+-->
+<jdo> 
+    <package name="org.apache.jdo.tck.api.instancecallbacks">
+        <class name="InstanceLifecycleListenerAttach$PC" detachable="true">
+            <field name="id" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerClear$PC">
+            <field name="id" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerDelete$PC">
+            <field name="id" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerDetach$PC" detachable="true">
+            <field name="id" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerLoad$PC">
+            <field name="id" primary-key="true"/>
+            <field name="value"/>
+        </class>
+        <class name="InstanceLifecycleListenerStore$PC">
+            <field name="id" primary-key="true"/>
+        </class>
+    </package>
+</jdo>

Added: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package.jdo Sun Oct 16 20:29:07 2005
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains the persistence information for persistence-capable classes 
+-->
+<jdo> 
+    <package name="org.apache.jdo.tck.api.instancecallbacks">
+        <class name="InstanceLifecycleListenerAttach$PC" 
+                identity-type="datastore" detachable="true">
+            <field name="id"/>
+        </class>
+        <class name="InstanceLifecycleListenerClear$PC" 
+                identity-type="datastore">
+            <field name="id"/>
+        </class>
+        <class name="InstanceLifecycleListenerDelete$PC" 
+                identity-type="datastore">
+            <field name="id"/>
+        </class>
+        <class name="InstanceLifecycleListenerDetach$PC" 
+                identity-type="datastore" detachable="true">
+            <field name="id"/>
+        </class>
+        <class name="InstanceLifecycleListenerLoad$PC" 
+                identity-type="datastore">
+            <field name="id"/>
+            <field name="value"/>
+        </class>
+        <class name="InstanceLifecycleListenerStore$PC" 
+                identity-type="datastore">
+            <field name="id"/>
+        </class>
+    </package>
+</jdo>

Added: incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm (added)
+++ incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm Sun Oct 16 20:29:07 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE orm PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 2.0//EN" "http://java.sun.com/dtd/orm_2_0.dtd">
+<!--
+This file contains the schema information when an implementation
+has application identity.
+-->
+<orm>
+    <package name="org.apache.jdo.tck.api.instancecallbacks">
+
+        <class name="InstanceLifecycleListenerAttach$PC" 
+                table="LIFECYCLELISTENERATTACH">
+            <field name="id" column="ID" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerClear$PC" 
+                table="LIFECYCLELISTENERCLEAR">
+            <field name="id" column="ID" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerDelete$PC" 
+                table="LIFECYCLELISTENERDELETE">
+            <field name="id" column="ID" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerDetach$PC" 
+                table="LIFECYCLELISTENERDETACH">
+            <field name="id" column="ID" primary-key="true"/>
+        </class>
+        <class name="InstanceLifecycleListenerLoad$PC" 
+                table="LIFECYCLELISTENERLOAD">
+            <field name="id" column="ID" primary-key="true"/>
+            <field name="value" column="VALUE"/>
+        </class>
+        <class name="InstanceLifecycleListenerStore$PC" 
+                table="LIFECYCLELISTENERSTORE">
+            <field name="id" column="ID" primary-key="true"/>
+        </class>
+    </package>
+</orm>

Added: incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm?rev=325833&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm (added)
+++ incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/api/instancecallbacks/package-derby.orm Sun Oct 16 20:29:07 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE orm PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 2.0//EN" "http://java.sun.com/dtd/orm_2_0.dtd">
+<!--
+This file contains the schema information when an implementation
+has datastore identity.
+-->
+<orm>
+    <package name="org.apache.jdo.tck.api.instancecallbacks">
+
+        <class name="InstanceLifecycleListenerAttach$PC" 
+                table="LIFECYCLELISTENERATTACH">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+        <class name="InstanceLifecycleListenerClear$PC" 
+                table="LIFECYCLELISTENERCLEAR">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+        <class name="InstanceLifecycleListenerDelete$PC" 
+                table="LIFECYCLELISTENERDELETE">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+        <class name="InstanceLifecycleListenerDetach$PC" 
+                table="LIFECYCLELISTENERDETACH">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+        <class name="InstanceLifecycleListenerLoad$PC" 
+                table="LIFECYCLELISTENERLOAD">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+            <field name="value" column="VALUE"/>
+        </class>
+        <class name="InstanceLifecycleListenerStore$PC" 
+                table="LIFECYCLELISTENERSTORE">
+            <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <field name="id" column="ID"/>
+        </class>
+    </package>
+</orm>

Modified: incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql?rev=325833&r1=325832&r2=325833&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql (original)
+++ incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql Sun Oct 16 20:29:07 2005
@@ -7374,4 +7374,51 @@
     CONSTRAINT STOBJ_PK PRIMARY KEY (ID)
 );
 
+-------------------------
+--lifecycle-callbacks
+-------------------------
+
+DROP TABLE LIFECYCLELISTENERATTACH;
+
+CREATE TABLE LIFECYCLELISTENERATTACH (
+    ID INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_ATTACH_PK PRIMARY KEY (ID)
+);
+
+DROP TABLE LIFECYCLELISTENERCLEAR;
+
+CREATE TABLE LIFECYCLELISTENERCLEAR (
+    ID INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_CLEAR_PK PRIMARY KEY (ID)
+);
+
+DROP TABLE LIFECYCLELISTENERDELETE;
+
+CREATE TABLE LIFECYCLELISTENERDELETE (
+    ID INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_DELETE_PK PRIMARY KEY (ID)
+);
+
+DROP TABLE LIFECYCLELISTENERDETACH;
+
+CREATE TABLE LIFECYCLELISTENERDETACH (
+    ID INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_DETACH_PK PRIMARY KEY (ID)
+);
+
+DROP TABLE LIFECYCLELISTENERLOAD;
+
+CREATE TABLE LIFECYCLELISTENERLOAD (
+    ID INTEGER NOT NULL,
+    VALUE INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_LOAD_PK PRIMARY KEY (ID)
+);
+
+DROP TABLE LIFECYCLELISTENERSTORE;
+
+CREATE TABLE LIFECYCLELISTENERSTORE (
+    ID INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_STORE_PK PRIMARY KEY (ID)
+);
+
 disconnect;

Modified: incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql?rev=325833&r1=325832&r2=325833&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql (original)
+++ incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql Sun Oct 16 20:29:07 2005
@@ -7380,4 +7380,57 @@
     CONSTRAINT STOBJ_PK PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
+-------------------------
+--lifecycle-callbacks
+-------------------------
+
+DROP TABLE LIFECYCLELISTENERATTACH;
+
+CREATE TABLE LIFECYCLELISTENERATTACH (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER,
+    CONSTRAINT LIFECYCLE_ATTACH_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+DROP TABLE LIFECYCLELISTENERCLEAR;
+
+CREATE TABLE LIFECYCLELISTENERCLEAR (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER,
+    CONSTRAINT LIFECYCLE_CLEAR_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+DROP TABLE LIFECYCLELISTENERDELETE;
+
+CREATE TABLE LIFECYCLELISTENERDELETE (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER,
+    CONSTRAINT LIFECYCLE_DELETE_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+DROP TABLE LIFECYCLELISTENERDETACH;
+
+CREATE TABLE LIFECYCLELISTENERDETACH (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER,
+    CONSTRAINT LIFECYCLE_DETACH_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+DROP TABLE LIFECYCLELISTENERLOAD;
+
+CREATE TABLE LIFECYCLELISTENERLOAD (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER NOT NULL,
+    VALUE INTEGER NOT NULL,
+    CONSTRAINT LIFECYCLE_LOAD_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+DROP TABLE LIFECYCLELISTENERSTORE;
+
+CREATE TABLE LIFECYCLELISTENERSTORE (
+    DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID INTEGER,
+    CONSTRAINT LIFECYCLE_STORE_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
 disconnect;



Mime
View raw message