db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r189600 - in /incubator/jdo/trunk/tck20/test: conf/ java/org/apache/jdo/tck/lifecycle/ java/org/apache/jdo/tck/pc/lifecycle/ jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ sql/derby/
Date Wed, 08 Jun 2005 16:03:55 GMT
Author: mcaisse
Date: Wed Jun  8 09:03:53 2005
New Revision: 189600

URL: http://svn.apache.org/viewcvs?rev=189600&view=rev
Log:
JDO-13 submitted by Michael Watzek

Modified:
    incubator/jdo/trunk/tck20/test/conf/alltests.list
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo
    incubator/jdo/trunk/tck20/test/sql/derby/schema1.sql

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.list
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.list?rev=189600&r1=189599&r2=189600&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.list (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.list Wed Jun  8 09:03:53 2005
@@ -171,6 +171,7 @@
 org.apache.jdo.tck.lifecycle.MultiplePMsReturnInstancesRepresentingSamePC \
 org.apache.jdo.tck.lifecycle.ObjectIdNotModifiedWhenObjectIdInstanceModified \
 org.apache.jdo.tck.lifecycle.PMReturnsIdenticalInstancesForEqualObjIds \
+org.apache.jdo.tck.lifecycle.PMsCanSharePCClassesButNotPCInstances \
 org.apache.jdo.tck.lifecycle.StateTransitions \
 org.apache.jdo.tck.lifecycle.TransientTransactionalStateCommit \
 org.apache.jdo.tck.lifecycle.TransientTransactionalStateRollback \

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java?rev=189600&r1=189599&r2=189600&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java
Wed Jun  8 09:03:53 2005
@@ -16,8 +16,19 @@
  
 package org.apache.jdo.tck.lifecycle;
 
-import java.util.*;
-import javax.jdo.*;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jdo.Extent;
+import javax.jdo.JDOException;
+import javax.jdo.JDOFatalException;
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Transaction;
+
+import junit.framework.AssertionFailedError;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj;
@@ -74,14 +85,16 @@
         addTearDownClass(StateTransitionObj.class);
     }
     
-    public void test() {
+    public void testSharedPC() {
         // test shared PC - only one PM should succeed to insert the shared PC
         threads = 0;
         attempts = 0;
         insertedCount = 0;
         insertedCountExpected = 1;
         insertObjects(true);
-        
+    }
+
+    public void testNonSharedPC() {
         // test non-shared PCs - each PM should succeed to insert its own non-shared PC
         threads = 0;
         attempts = 0;
@@ -125,6 +138,19 @@
                 logger.debug("interrupted while waiting for threads to finish");
             }
         }
+        
+        Collection exceptions = threadGroup.getAllUncaughtExceptions();
+        for (Iterator i = exceptions.iterator(); i.hasNext(); ) {
+            Map.Entry entry = (Map.Entry) i.next();
+            Thread thread = (Thread)entry.getKey();
+            Throwable throwable = (Throwable)entry.getValue();
+            String message = "Uncaught exception " + throwable + " in thread " + thread;
+            if( throwable instanceof AssertionFailedError )
+                fail(ASSERTION_FAILED, message);
+            else
+                throw new JDOFatalException(message, throwable);
+        }
+        
     }
 
     synchronized void signal() {
@@ -176,10 +202,10 @@
                         throw ex;
                 }
                 finally {
+                    incrAttempts();
                     if (tx != null && tx.isActive())
                         tx.rollback();
                 }
-                incrAttempts();
 
                 while (!attemptsComplete()) {
                     try {
@@ -201,11 +227,13 @@
                 int objCount = 0;
                 if (debug)
                     logger.debug("getting Extent of " + instanceClass.getName());
+                tx.begin();
                 Extent e = pm.getExtent(instanceClass, false);
                 for (Iterator i = e.iterator(); i.hasNext();) {
                     Object instance = (Object)i.next();
                     objCount++;
                 }
+                tx.commit();
 
                 //Verify that the number of inserted objects matches the number of objects
in the extent
                 if (insertedCount!=objCount)

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java?rev=189600&r1=189599&r2=189600&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java
Wed Jun  8 09:03:53 2005
@@ -17,16 +17,23 @@
 
 package org.apache.jdo.tck.pc.lifecycle;
 
+import java.io.Serializable;
+
 public class StateTransitionObj {
+    private static int counter = 0;
+    
+    private int      id;
     private int      int_field;
     private transient int nonmanaged_field;
     
     public StateTransitionObj()
     {
+        id = ++counter;
         int_field = 0;
     }
     public StateTransitionObj(int v)
     {
+        this();
         int_field = v;
     }
     public int readField()
@@ -46,4 +53,73 @@
     {
         nonmanaged_field = value;
     }
+    /**
+     * @return Returns the id.
+     */
+    public int getId() {
+        return id;
+    }
+    /**
+     * @param id The id to set.
+     */
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    /**
+     * The class to be used as the application identifier
+     * for the <code>StateTransitionObj</code> class.
+     */
+    public static class Oid implements Serializable, Comparable {
+
+        /**
+         * This field is part of the identifier and should match in name
+         * and type with a field in the <code>StateTransitionObj</code> class.
+         */
+        public int id;
+
+        /** The required public no-arg constructor. */
+        public Oid() { }
+
+        /**
+         * Initialize the identifier.
+         * @param companyid The id of the company.
+         */
+        public Oid(int id) {
+            this.id = id;
+        }
+        
+        public Oid(String s) { id = Integer.parseInt(justTheId(s)); }
+
+        public String toString() { return this.getClass().getName() + ": "  + id;}
+
+        
+        /** */
+        public boolean equals(Object obj) {
+            if (obj==null || !this.getClass().equals(obj.getClass())) 
+                return false;
+            Oid o = (Oid) obj;
+            if (this.id != o.id) 
+                return false;
+            return true;
+        }
+
+        /** */
+        public int hashCode() {
+            return id;
+        }
+        
+        protected static String justTheId(String str) {
+            return str.substring(str.indexOf(':') + 1);
+        }
+
+        /** */
+        public int compareTo(Object obj) {
+            // may throw ClassCastException which the user must handle
+            Oid other = (Oid) obj;
+            return id - other.id;
+        }
+        
+    }
+
 }

Modified: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo?rev=189600&r1=189599&r2=189600&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo
(original)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo
Wed Jun  8 09:03:53 2005
@@ -3,8 +3,10 @@
 <jdo>
   <package name="org.apache.jdo.tck.pc.lifecycle">
 
-      <class name="StateTransitionObj" identity-type="application">
-          <field name="int_field" primary-key="true"/>
-      </class>
+    <class name="StateTransitionObj" 
+           identity-type="application"
+           objectid-class="org.apache.jdo.tck.pc.lifecycle.StateTransitionObj$Oid">
+        <field name="id" primary-key="true"/>
+    </class>
   </package>
 </jdo>

Modified: incubator/jdo/trunk/tck20/test/sql/derby/schema1.sql
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/sql/derby/schema1.sql?rev=189600&r1=189599&r2=189600&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/sql/derby/schema1.sql (original)
+++ incubator/jdo/trunk/tck20/test/sql/derby/schema1.sql Wed Jun  8 09:03:53 2005
@@ -7082,7 +7082,7 @@
 CREATE TABLE STATETRANSITIONOBJ (
     ID INTEGER NOT NULL,
     INT_FIELD INTEGER NOT NULL,
-    CONSTRAINT ICNP_PK PRIMARY KEY (ID)
+    CONSTRAINT STOBJ_PK PRIMARY KEY (ID)
 );
 
 disconnect;



Mime
View raw message