db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r359415 - in /db/jdo/trunk/tck20: ./ test/java/org/apache/jdo/tck/api/persistencemanager/ test/java/org/apache/jdo/tck/pc/mylib/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/myli...
Date Wed, 28 Dec 2005 06:15:01 GMT
Author: clr
Date: Tue Dec 27 22:14:51 2005
New Revision: 359415

URL: http://svn.apache.org/viewcvs?rev=359415&view=rev
Log:
JDO-72 added VersionedPCPoint with version column and version-number strategy; changed OptimisticFailure
to use versioned class

Added:
    db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java
Modified:
    db/jdo/trunk/tck20/project.properties
    db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
    db/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
    db/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
    db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
    db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
    db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
    db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql

Modified: db/jdo/trunk/tck20/project.properties
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/project.properties?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/project.properties (original)
+++ db/jdo/trunk/tck20/project.properties Tue Dec 27 22:14:51 2005
@@ -172,6 +172,7 @@
     org/apache/jdo/tck/pc/inheritance/TopPersistH.java \
     org/apache/jdo/tck/pc/mylib/PCClass.java \
     org/apache/jdo/tck/pc/mylib/PCPoint.java \
+    org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java \
     org/apache/jdo/tck/pc/mylib/PCPoint2.java \
     org/apache/jdo/tck/pc/mylib/PCRect.java \
     org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java \
@@ -272,6 +273,7 @@
     org/apache/jdo/tck/pc/inheritance/TopPersistH.class \
     org/apache/jdo/tck/pc/mylib/PCClass.class \
     org/apache/jdo/tck/pc/mylib/PCPoint.class \
+    org/apache/jdo/tck/pc/mylib/VersionedPCPoint.class \
     org/apache/jdo/tck/pc/mylib/PCPoint2.class \
     org/apache/jdo/tck/pc/mylib/PCRect.class \
     org/apache/jdo/tck/pc/mylib/PrimitiveTypes.class \

Modified: db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
(original)
+++ db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
Tue Dec 27 22:14:51 2005
@@ -26,7 +26,7 @@
 import javax.jdo.PersistenceManager;
 import javax.jdo.Transaction;
 
-import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
 /**
@@ -62,11 +62,11 @@
         BatchTestRunner.run(OptimisticFailure.class);
     }
 
-    private PCPoint p1 = new PCPoint(1,1); // this will be updated in tx1, updated in tx2,
verified in tx3
-    private PCPoint p2 = new PCPoint(2,2); // this will be updated in tx1, deleted in tx2,
verified in tx3
-    private PCPoint p3 = new PCPoint(3,3); // this will be deleted in tx1, updated in tx2
-    private PCPoint p4 = new PCPoint(4,4); // this will be deleted in tx1, deleted in tx2
-    private PCPoint p5 = new PCPoint(5,5); // this will be unchanged in tx1, updated in tx2,
verified in tx3
+    private VersionedPCPoint p1 = new VersionedPCPoint(1,1); // this will be updated in tx1,
updated in tx2, verified in tx3
+    private VersionedPCPoint p2 = new VersionedPCPoint(2,2); // this will be updated in tx1,
deleted in tx2, verified in tx3
+    private VersionedPCPoint p3 = new VersionedPCPoint(3,3); // this will be deleted in tx1,
updated in tx2
+    private VersionedPCPoint p4 = new VersionedPCPoint(4,4); // this will be deleted in tx1,
deleted in tx2
+    private VersionedPCPoint p5 = new VersionedPCPoint(5,5); // this will be unchanged in
tx1, updated in tx2, verified in tx3
     private Object p1oid = null;
     private Object p2oid = null;
     private Object p3oid = null;
@@ -125,10 +125,10 @@
            
            // update/delete the instances in tx1
            tx1.begin();
-           PCPoint p1tx1 = (PCPoint)pm1.getObjectById(p1oid, true);
-           PCPoint p2tx1 = (PCPoint)pm1.getObjectById(p2oid, true);
-           PCPoint p3tx1 = (PCPoint)pm1.getObjectById(p3oid, true);
-           PCPoint p4tx1 = (PCPoint)pm1.getObjectById(p4oid, true);
+           VersionedPCPoint p1tx1 = (VersionedPCPoint)pm1.getObjectById(p1oid, true);
+           VersionedPCPoint p2tx1 = (VersionedPCPoint)pm1.getObjectById(p2oid, true);
+           VersionedPCPoint p3tx1 = (VersionedPCPoint)pm1.getObjectById(p3oid, true);
+           VersionedPCPoint p4tx1 = (VersionedPCPoint)pm1.getObjectById(p4oid, true);
            p1tx1.setX(101);
            p2tx1.setX(201);
            pm1.deletePersistent(p3tx1);
@@ -136,11 +136,11 @@
            
            // update/delete the instances in tx2
            tx2.begin();
-           PCPoint p1tx2 = (PCPoint)pm2.getObjectById(p1oid, true);
-           PCPoint p2tx2 = (PCPoint)pm2.getObjectById(p2oid, true);
-           PCPoint p3tx2 = (PCPoint)pm2.getObjectById(p3oid, true);
-           PCPoint p4tx2 = (PCPoint)pm2.getObjectById(p4oid, true);
-           PCPoint p5tx2 = (PCPoint)pm2.getObjectById(p5oid, true);
+           VersionedPCPoint p1tx2 = (VersionedPCPoint)pm2.getObjectById(p1oid, true);
+           VersionedPCPoint p2tx2 = (VersionedPCPoint)pm2.getObjectById(p2oid, true);
+           VersionedPCPoint p3tx2 = (VersionedPCPoint)pm2.getObjectById(p3oid, true);
+           VersionedPCPoint p4tx2 = (VersionedPCPoint)pm2.getObjectById(p4oid, true);
+           VersionedPCPoint p5tx2 = (VersionedPCPoint)pm2.getObjectById(p5oid, true);
            p1tx2.setX(102);
 //           pm2.deletePersistent(p2tx2); // this should fail but succeeds due to an RI bug
            p3tx2.setX(202);
@@ -203,9 +203,9 @@
            tx2 = null;
            
            tx3.begin();
-           PCPoint p1tx3 = (PCPoint)pm3.getObjectById(p1oid, true);
-           PCPoint p2tx3 = (PCPoint)pm3.getObjectById(p2oid, true);
-           PCPoint p5tx3 = (PCPoint)pm3.getObjectById(p5oid, true);
+           VersionedPCPoint p1tx3 = (VersionedPCPoint)pm3.getObjectById(p1oid, true);
+           VersionedPCPoint p2tx3 = (VersionedPCPoint)pm3.getObjectById(p2oid, true);
+           VersionedPCPoint p5tx3 = (VersionedPCPoint)pm3.getObjectById(p5oid, true);
            verify(p1tx3, 101);
            verify(p2tx3, 201);
            verify(p5tx3, 5);
@@ -223,10 +223,10 @@
     }
     
     /** */
-    protected void verify(PCPoint p, int value) {
+    protected void verify(VersionedPCPoint p, int value) {
         if (p.getX() != value) {
             fail(ASSERTION_FAILED,
-                 "PCPoint has wrong value: expected " + value + ", got " + p.getX());
+                 "VersionedPCPoint has wrong value: expected " + value + ", got " + p.getX());
         }
     }
 }

Added: db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java?rev=359415&view=auto
==============================================================================
--- db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java (added)
+++ db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java Tue Dec
27 22:14:51 2005
@@ -0,0 +1,122 @@
+/*
+ * 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.pc.mylib;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+* A simple class with two fields for application identity
+*
+* @author Marina Vatkina
+*/
+public class VersionedPCPoint implements Serializable {
+    
+    
+    private static long counter = new Date().getTime();
+    private static long newId() {
+        synchronized (PCPoint.class) {
+            return counter++;
+        }
+    }
+    private long id = newId();
+    public int x;
+    public Integer y;
+
+    public VersionedPCPoint() {
+    }
+
+    public VersionedPCPoint(int x, int y) {
+        this.x = x;
+        this.y = new Integer(y);
+    }
+
+    public VersionedPCPoint(int x, Integer y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    public String toString() {
+        String rc = null;
+	Object obj = this;
+        try {
+	    rc = obj.getClass().getName();
+            //rc = Util.getClassName(this) + name();
+        } catch (NullPointerException ex) {
+            rc = "NPE getting PCPoint's values";
+        }
+        return rc;
+    }
+
+    public void setX(int x) {
+        this.x = x;
+    }
+
+    public int getX() {
+        return x;
+    }
+
+    public void setY(Integer y) {
+        this.y = y;
+    }
+
+    public Integer getY() {
+        return y;
+    }
+    
+    public String name() {
+        return " x: " + getX() + ", y: " + getY().intValue();
+    }
+
+    public static class Oid implements Serializable {
+        public long id;
+
+        /** The name of the class of the target object.
+        */
+        public static String targetClassName = 
+                "org.apache.jdo.tck.pc.mylib.VersionedPCPoint"; 
+
+        public Oid() {
+        }
+
+        public Oid(String s) { id = Long.parseLong(justTheId(s)); }
+
+        public String toString() { return getTargetClassName() + ": "  + id;}
+
+        public int hashCode() { return (int)id ; }
+
+        public boolean equals(Object other) {
+            if (other != null && (other instanceof Oid)) {
+                Oid k = (Oid)other;
+                return k.id == this.id;
+            }
+            return false;
+        }
+        
+        protected static String justTheId(String str) {
+            return str.substring(str.indexOf(':') + 1);
+        }
+
+        /** Return the target class name.
+         * @return the target class name.
+         */
+        public String getTargetClassName() {
+            return targetClassName;
+        } 
+
+    }   
+}

Modified: db/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
(original)
+++ db/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/package.jdo
Tue Dec 27 22:14:51 2005
@@ -3,11 +3,14 @@
 <jdo>
   <package name="org.apache.jdo.tck.pc.mylib">
 
-    <!-- This will not be required once the JDOModel is fixed so that
-         the defaults defined in section 18.4 of the spec are working
-    -->
     <class name="PCPoint"
            identity-type="application" objectid-class="org.apache.jdo.tck.pc.mylib.PCPoint$Oid">
+      <field name="id" primary-key="true"/>
+    </class>
+
+    <class name="VersionedPCPoint"
+           identity-type="application" objectid-class="org.apache.jdo.tck.pc.mylib.VersionedPCPoint$Oid">
+      <version strategy="version-number" column="VERSION"/>
       <field name="id" primary-key="true"/>
     </class>
 

Modified: db/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
(original)
+++ db/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/package.jdo
Tue Dec 27 22:14:51 2005
@@ -3,10 +3,11 @@
 <jdo>
   <package name="org.apache.jdo.tck.pc.mylib">
 
-    <!-- This will not be required once the JDOModel is fixed so that
-         the defaults defined in section 18.4 of the spec are working
-    -->
     <class name="PCPoint" identity-type="datastore"/>
+
+    <class name="VersionedPCPoint" identity-type="datastore">
+      <version strategy="version-number" column="VERSION"/>
+    </class>
 
     <class name="PCPoint2" identity-type="datastore">
       <field name="clearCalled" persistence-modifier="none"/>

Modified: db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
(original)
+++ db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
Tue Dec 27 22:14:51 2005
@@ -9,6 +9,12 @@
       <field name="y" column="Y"/>
     </class>
 
+    <class name="VersionedPCPoint" table="VersionedPCPoint">
+      <field name="id" column="ID" primary-key="true"/>
+      <field name="x" column="X"/>
+      <field name="y" column="Y"/>
+    </class>
+
     <class name="PCPoint2" table="PCPoint2">
       <field name="id" column="ID" primary-key="true"/>
       <field name="x" column="X"/>

Modified: db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
(original)
+++ db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
Tue Dec 27 22:14:51 2005
@@ -10,6 +10,13 @@
       <field name="y" column="Y"/>
     </class>
 
+    <class name="VersionedPCPoint" table="VersionedPCPoint">
+      <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+      <field name="id" column="ID"/>
+      <field name="x" column="X"/>
+      <field name="y" column="Y"/>
+    </class>
+
     <class name="PCPoint2" table="PCPoint2">
       <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
       <field name="id" column="ID"/>

Modified: db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql (original)
+++ db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql Tue Dec 27 22:14:51 2005
@@ -11,6 +11,7 @@
 
 DROP TABLE PCRect;
 DROP TABLE PCPoint;
+DROP TABLE VersionedPCPoint;
 DROP TABLE PCPoint2;
 DROP TABLE PrimitiveTypes;
 DROP TABLE PCClass;
@@ -20,6 +21,14 @@
     X INTEGER NOT NULL,
     Y INTEGER,
     CONSTRAINT PCPNT_CONST PRIMARY KEY (ID)
+);
+
+CREATE TABLE VersionedPCPoint (
+    ID BIGINT,
+    X INTEGER NOT NULL,
+    Y INTEGER,
+    VERSION INTEGER,
+    CONSTRAINT VERSIONED_PCPNT_CONST PRIMARY KEY (ID)
 );
 
 CREATE TABLE PCPoint2 (

Modified: db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql?rev=359415&r1=359414&r2=359415&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql (original)
+++ db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql Tue Dec 27 22:14:51 2005
@@ -11,6 +11,7 @@
 
 DROP TABLE PCRect;
 DROP TABLE PCPoint;
+DROP TABLE VersionedPCPoint;
 DROP TABLE PCPoint2;
 DROP TABLE PrimitiveTypes;
 DROP TABLE PCClass;
@@ -21,6 +22,15 @@
     X INTEGER NOT NULL,
     Y INTEGER,
     CONSTRAINT PCPNT_CONST PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+CREATE TABLE VersionedPCPoint (
+    DATASTORE_IDENTITY BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY,
+    ID BIGINT,
+    X INTEGER NOT NULL,
+    Y INTEGER,
+    VERSION INTEGER,
+    CONSTRAINT VERSIONED_PCPNT_CONST PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
 CREATE TABLE PCPoint2 (



Mime
View raw message