db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r329926 - in /incubator/jdo/trunk: api20/src/java/javax/jdo/ tck20/test/conf/ tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/
Date Mon, 31 Oct 2005 23:04:41 GMT
Author: clr
Date: Mon Oct 31 15:04:30 2005
New Revision: 329926

URL: http://svn.apache.org/viewcvs?rev=329926&view=rev
Log:
JDO-188 Added tests for getObjectIds

Modified:
    incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java
    incubator/jdo/trunk/tck20/test/conf/alltests.conf
    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/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/InstanceLifecycleListenerLoad.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java

Modified: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java?rev=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java (original)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java Mon Oct 31 15:04:30 2005
@@ -30,6 +30,9 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
@@ -257,7 +260,47 @@
             return implHelper.nonBinaryCompatibleGet(pc, getObjectId);
         }
     }
-    
+
+    /** Get object ids for a collection of instances. For each instance
+     * in the parameter, the getObjectId method is called. This method
+     * returns one identity instance for each element 
+     * in the parameter. The order of iteration of the returned
+     * Collection exactly matches the order of iteration of the
+     * parameter Collection.
+     * @param pcs the persistence-capable instances
+     * @return the object ids of the parameters
+     * @see #getObjectId(Object pc)
+     * @see #getObjectIds(Object[] pcs)
+     * @since 2.0
+     */
+    public static Collection getObjectIds(Collection pcs) {
+        ArrayList result = new ArrayList();
+        for (Iterator it = pcs.iterator(); it.hasNext();) {
+            result.add(getObjectId(it.next()));
+        }
+        return result;
+    }
+
+    /** Get object ids for an array of instances. For each instance
+     * in the parameter, the getObjectId method is called. This method
+     * returns one identity instance for each element 
+     * in the parameter. The order of instances of the returned
+     * array exactly matches the order of instances of the
+     * parameter array.
+     * @param pcs the persistence-capable instances
+     * @return the object ids of the parameters
+     * @see #getObjectId(Object pc)
+     * @see #getObjectIds(Collection pcs)
+     * @since 2.0
+     */
+    public static Object[] getObjectIds(Object[] pcs) {
+        Object[] result = new Object[pcs.length];
+        for (int i = 0; i < pcs.length; ++i) {
+            result[i] = getObjectId(pcs[i]);
+        }
+        return result;
+    }
+
     /** Return a copy of the JDO identity associated with the parameter instance.
      *
      * @see PersistenceCapable#jdoGetTransactionalObjectId()

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.conf?rev=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.conf Mon Oct 31 15:04:30 2005
@@ -23,6 +23,7 @@
 org.apache.jdo.tck.api.jdohelper.GetObjectIdForNull \
 org.apache.jdo.tck.api.jdohelper.GetObjectIdForTransient \
 org.apache.jdo.tck.api.jdohelper.GetObjectIdNotPersistenceCapable \
+org.apache.jdo.tck.api.jdohelper.GetObjectIds \
 org.apache.jdo.tck.api.jdohelper.GetPersistenceManager \
 org.apache.jdo.tck.api.jdohelper.GetPersistenceManagerForNull \
 org.apache.jdo.tck.api.jdohelper.GetPersistenceManagerForTransient \

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java
Mon Oct 31 15:04:30 2005
@@ -208,7 +208,8 @@
      * Unregister the LifecycleListener.
      */
     protected void localTearDown() {
-        removeListener();
+        removeListener(); // no callbacks for teardown
+        super.localTearDown();
     }
 
     /** 

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java
Mon Oct 31 15:04:30 2005
@@ -169,9 +169,9 @@
         static int counter = (int)(new Date().getTime());
 
         public void jdoPreAttach() {
-            if (listener == null)
-                return;
-            listener.notifyEvent(listener.PRE_ATTACH_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.PRE_ATTACH_CALLBACK);
+            }
         }
         public void jdoPostAttach(Object obj) {
             postAttachCalled = true;

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java
Mon Oct 31 15:04:30 2005
@@ -155,7 +155,9 @@
         static int counter = (int)(new Date().getTime());
 
         public void jdoPreClear() {
-            listener.notifyEvent(listener.PRE_CLEAR_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.PRE_CLEAR_CALLBACK);
+            }
         }
     }
 

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java
Mon Oct 31 15:04:30 2005
@@ -157,7 +157,9 @@
         static int counter = (int)(new Date().getTime());
 
         public void jdoPreDelete() {
-            listener.notifyEvent(listener.PRE_DELETE_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.PRE_DELETE_CALLBACK);
+            }
         }
     }
 

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java
Mon Oct 31 15:04:30 2005
@@ -168,9 +168,9 @@
         }
  
         public void jdoPreDetach() {
-            if (listener == null)
-                return;
-            listener.notifyEvent(listener.PRE_DETACH_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.PRE_DETACH_CALLBACK);
+            }
         }
         public void jdoPostDetach(Object obj) {
             postDetachCalled = true;

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java
Mon Oct 31 15:04:30 2005
@@ -145,7 +145,9 @@
         static int counter = (int)(new Date().getTime());
 
         public void jdoPostLoad() {
-            listener.notifyEvent(listener.POST_LOAD_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.POST_LOAD_CALLBACK);
+            }
         }
     }
 

Modified: 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=329926&r1=329925&r2=329926&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java
Mon Oct 31 15:04:30 2005
@@ -151,7 +151,9 @@
         static int counter = (int)(new Date().getTime());
 
         public void jdoPreStore() {
-            listener.notifyEvent(listener.PRE_STORE_CALLBACK);
+            if (listener != null) {
+                listener.notifyEvent(listener.PRE_STORE_CALLBACK);
+            }
         }
     }
 



Mime
View raw message