db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject svn commit: r366283 - in /db/jdo/trunk/tck20/test: conf/ java/org/apache/jdo/tck/api/jdohelper/ java/org/apache/jdo/tck/pc/shoppingcart/ orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/ orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcar...
Date Thu, 05 Jan 2006 21:25:48 GMT
Author: madams
Date: Thu Jan  5 13:25:43 2006
New Revision: 366283

URL: http://svn.apache.org/viewcvs?rev=366283&view=rev
Log:
JDO-272 Update to fix bugs & config problems.

Added:
    db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
      - copied, changed from r366223, db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
    db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
      - copied, changed from r366223, db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
Removed:
    db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
    db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
Modified:
    db/jdo/trunk/tck20/test/conf/alltests.conf
    db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java
    db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java
    db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema8.sql
    db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema8.sql

Modified: db/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/conf/alltests.conf?rev=366283&r1=366282&r2=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ db/jdo/trunk/tck20/test/conf/alltests.conf Thu Jan  5 13:25:43 2006
@@ -154,9 +154,6 @@
 org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientFieldsPreservedUnchanged
\
 org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientHasNoEffectOnTransientInstances
\
 org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientNotSubjectToRollback \
-org.apache.jdo.tck.api.jdohelper.IsDetached \
-org.apache.jdo.tck.api.persistencemanager.detach.SetDetachAllOnCommit \
-org.apache.jdo.tck.api.persistencemanager.detach.GetDetachAllOnCommit \
 org.apache.jdo.tck.api.persistencemanagerfactory.AfterCloseGetPMThrowsException \
 org.apache.jdo.tck.api.persistencemanagerfactory.AfterCloseSetMethodsThrowException \
 org.apache.jdo.tck.api.persistencemanagerfactory.AfterGetPersistenceManagerNoSetMethodsSucceed
\

Modified: db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java?rev=366283&r1=366282&r2=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java (original)
+++ db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java Thu Jan
 5 13:25:43 2006
@@ -21,6 +21,7 @@
 import org.apache.jdo.tck.util.BatchTestRunner;
 
 import javax.jdo.JDOHelper;
+import javax.jdo.Transaction;
 
 /**
  * <B>Title:</B> Test IsDetached
@@ -52,7 +53,7 @@
         pm.currentTransaction().begin();
 
         assertFalse(ASSERTION_FAILED + "null object is detached", JDOHelper.isDetached(null));
-        assertFalse(ASSERTION_FAILED + "transient object is detached", JDOHelper.isDetached(new
Cart()));
+        assertFalse(ASSERTION_FAILED + "transient object is detached", JDOHelper.isDetached(new
Cart("bob")));
         assertFalse(ASSERTION_FAILED + "object of class marked not detachabled is detached",
JDOHelper.isDetached(new Undetachable()));
 
         pm.currentTransaction().commit();
@@ -60,21 +61,24 @@
 
     public void testDetachableIsDetachedTrue() {
         pm = getPM();
-        pm.currentTransaction().begin();
-
-        Cart c = new Cart();
-        Object oid = pm.getObjectId(c);
+        Transaction txn = pm.currentTransaction();
 
-        pm.makePersistent(c);
-        pm.currentTransaction().commit();
-
-        pm.currentTransaction().begin();
-
-        c = (Cart) pm.getObjectById(oid);
-        Cart detached = (Cart) pm.detachCopy(c);
-
-        assertTrue(JDOHelper.isDetached(detached));
-
-        pm.currentTransaction().commit();
+        Cart c, detached;
+        Object oid;
+        txn.begin();
+        {
+            c = new Cart("bob");
+            pm.makePersistent(c);
+            oid = pm.getObjectId(c);
+        }
+        txn.commit();
+
+        txn.begin();
+        {
+            c = (Cart) pm.getObjectById(oid);
+            detached = (Cart) pm.detachCopy(c);
+            assertTrue(JDOHelper.isDetached(detached));
+        }
+        txn.commit();
     }
 }

Modified: db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java?rev=366283&r1=366282&r2=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java (original)
+++ db/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java Thu Jan  5 13:25:43
2006
@@ -16,11 +16,7 @@
 package org.apache.jdo.tck.pc.shoppingcart;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
+import java.util.*;
 
 /** This class represents an online shopping cart.  It has a list of entries of
  * type CartEntry.
@@ -40,14 +36,18 @@
     protected String customerId;
 
     /** The list of entries in this cart */
-    protected List entries = new ArrayList(); // element-type CartEntry
+    protected Set entries = new HashSet(); // element-type CartEntry
 
-    public Cart() {
-        this(nextId());
+    /** For JDO compliance only; not for public consumption. */
+    protected Cart() {}
+
+    public Cart(String customerId) {
+        this(nextId(), customerId);
     }
 
-    protected Cart(long id) {
+    protected Cart(long id, String customerId) {
         setId(id);
+        setCustomerId(customerId);
     }
 
     public long getId() {
@@ -80,102 +80,6 @@
         this.customerId = customerId;
     }
 
-    public void add(int arg0, CartEntry arg1) {
-        entries.add(arg0, arg1);
-    }
-
-    public boolean add(CartEntry arg0) {
-        return entries.add(arg0);
-    }
-
-    public boolean addAll(int arg0, Collection arg1) {
-        Iterator i = arg1.iterator();
-        while (i.hasNext()) {
-            CartEntry entry = (CartEntry) i.next();
-        }
-        return entries.addAll(arg0, arg1);
-    }
-
-    public boolean addAll(Collection arg0) {
-        Iterator i = arg0.iterator();
-        while (i.hasNext()) {
-            CartEntry entry = (CartEntry) i.next();
-        }
-        return entries.addAll(arg0);
-    }
-
-    public void clear() {
-        entries.clear();
-    }
-
-    public boolean contains(CartEntry o) {
-        return entries.contains(o);
-    }
-
-    public boolean containsAll(Collection arg0) {
-        return entries.containsAll(arg0);
-    }
-
-    public CartEntry get(int index) {
-        return (CartEntry) entries.get(index);
-    }
-
-    public int indexOf(CartEntry o) {
-        return entries.indexOf(o);
-    }
-
-    public boolean isEmpty() {
-        return entries.isEmpty();
-    }
-
-    public Iterator iterator() {
-        return entries.iterator();
-    }
-
-    public int lastIndexOf(CartEntry o) {
-        return entries.lastIndexOf(o);
-    }
-
-    public ListIterator listIterator() {
-        return entries.listIterator();
-    }
-
-    public ListIterator listIterator(int index) {
-        return entries.listIterator(index);
-    }
-
-    public Object remove(int index) {
-        return entries.remove(index);
-    }
-
-    public boolean remove(CartEntry o) {
-        return entries.remove(o);
-    }
-
-    public boolean removeAll(Collection arg0) {
-        Iterator i = arg0.iterator();
-        while (i.hasNext()) {
-            CartEntry entry = (CartEntry) i.next();
-        }
-        return entries.removeAll(arg0);
-    }
-
-    public boolean retainAll(Collection arg0) {
-        return entries.retainAll(arg0);
-    }
-
-    public Object set(int arg0, CartEntry arg1) {
-        return entries.set(arg0, arg1);
-    }
-
-    public int entrySize() {
-        return entries.size();
-    }
-
-    public List subList(int fromIndex, int toIndex) {
-        return entries.subList(fromIndex, toIndex);
-    }
-    
     public boolean equals(Object that) {
         if (this == that) {
             return true;
@@ -188,7 +92,7 @@
         }
         return equals((Cart) that);
     }
-    
+
     public boolean equals(Cart that) {
         if (this == that) {
             return true;
@@ -198,7 +102,7 @@
         }
         return this.id == that.id;
     }
-    
+
     public int hashCode() {
         return (int) id;
     }

Copied: db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
(from r366223, db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm)
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm?p2=db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm&p1=db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm&r1=366223&r2=366283&rev=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
(original)
+++ db/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
Thu Jan  5 13:25:43 2006
@@ -16,8 +16,8 @@
         <class name="CartEntry" table="CART_ENTRIES">
             <field name="id" column="ID"/>
             <field name="quantity" column="QUANTITY"/>
-            <field name="product" column="SKU"/>
-            <field name="cart" column="CART_ID"/>
+            <field name="product" column="SKU" foreign-key="true"/>
+            <field name="cart" column="CART_ID" foreign-key="true"/>
         </class>
 
         <class name="Product" table="PRODUCTS">
@@ -26,7 +26,7 @@
         </class>
 
         <class name="Undetachable" table="UNDETACHABLES">
-            <field name="id" column="UNDETACHABLE_ID"/>
+            <field name="id" column="ID"/>
             <field name="foo" column="FOO"/>
             <field name="bar" column="BAR"/>
         </class>

Copied: db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
(from r366223, db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm)
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm?p2=db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm&p1=db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm&r1=366223&r2=366283&rev=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby.orm
(original)
+++ db/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/shoppingcart/package-derby8.orm
Thu Jan  5 13:25:43 2006
@@ -8,25 +8,33 @@
     <package name="org.apache.jdo.tck.pc.shoppingcart">
 
         <class name="Cart" table="CARTS">
-            <field name="id" column="CART_ID" primary-key="true"/>
+            <datastore-identity strategy="increment" column="DATASTORE_ID"/>
+
+            <field name="id" column="CART_ID"/>
             <field name="customerId" column="CUSTOMER_ID"/>
             <field name="entries" mapped-by="cart"/>
         </class>
 
         <class name="CartEntry" table="CART_ENTRIES">
-            <field name="id" column="ID" primary-key="true"/>
+            <datastore-identity strategy="increment" column="DATASTORE_ID"/>
+
+            <field name="id" column="ID"/>
             <field name="quantity" column="QUANTITY"/>
             <field name="product" column="SKU" foreign-key="true"/>
             <field name="cart" column="CART_ID" foreign-key="true"/>
         </class>
 
         <class name="Product" table="PRODUCTS">
-            <field name="sku" column="SKU" primary-key="true"/>
+            <datastore-identity strategy="uuid-hex" column="DATASTORE_ID"/>
+
+            <field name="sku" column="SKU"/>
             <field name="description" column="DESCRIPTION"/>
         </class>
 
         <class name="Undetachable" table="UNDETACHABLES">
-            <field name="id" column="UNDETACHABLE_ID" primary-key="true"/>
+            <datastore-identity strategy="increment" column="DATASTORE_ID"/>
+
+            <field name="id" column="ID"/>
             <field name="foo" column="FOO"/>
             <field name="bar" column="BAR"/>
         </class>

Modified: db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema8.sql
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema8.sql?rev=366283&r1=366282&r2=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema8.sql (original)
+++ db/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema8.sql Thu Jan  5 13:25:43
2006
@@ -12,7 +12,7 @@
 
 CREATE TABLE CARTS (
     CART_ID BIGINT NOT NULL,
-    CUSTOMER_ID INTEGER NOT NULL,
+    CUSTOMER_ID VARCHAR(128) NOT NULL,
 
     CONSTRAINT CARTS_PK PRIMARY KEY (CART_ID)
 );
@@ -26,6 +26,7 @@
 
 CREATE TABLE CART_ENTRIES (
     ID BIGINT NOT NULL,
+    QUANTITY INTEGER DEFAULT 0,
     CART_ID BIGINT NOT NULL,
     SKU VARCHAR(48) NOT NULL,
 

Modified: db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema8.sql
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema8.sql?rev=366283&r1=366282&r2=366283&view=diff
==============================================================================
--- db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema8.sql (original)
+++ db/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema8.sql Thu Jan  5 13:25:43 2006
@@ -11,33 +11,46 @@
 DROP TABLE UNDETACHABLES;
 
 CREATE TABLE CARTS (
+
+    DATASTORE_ID BIGINT NOT NULL,
     CART_ID BIGINT NOT NULL,
-    CUSTOMER_ID INTEGER NOT NULL,
+    CUSTOMER_ID VARCHAR(128) NOT NULL,
 
-    CONSTRAINT CARTS_PK PRIMARY KEY (CART_ID)
+    CONSTRAINT CARTS_PK PRIMARY KEY (DATASTORE_ID),
+    CONSTRAINT CARTS_UK UNIQUE      (CART_ID)
 );
 
 CREATE TABLE PRODUCTS (
+
+    DATASTORE_ID VARCHAR(48) NOT NULL,
     SKU VARCHAR(48) NOT NULL,
     DESCRIPTION VARCHAR(128),
 
-    CONSTRAINT PRODUCTS_PK PRIMARY KEY (SKU)
+    CONSTRAINT PRODUCTS_PK  PRIMARY KEY  (DATASTORE_ID),
+    CONSTRAINT PRODUCTS_UK  UNIQUE       (SKU)
 );
 
 CREATE TABLE CART_ENTRIES (
+
+    DATASTORE_ID BIGINT NOT NULL,
     ID BIGINT NOT NULL,
+    QUANTITY INTEGER DEFAULT 0,
     CART_ID BIGINT NOT NULL,
     SKU VARCHAR(48) NOT NULL,
 
-    CONSTRAINT CART_ENTRIES_PK  PRIMARY KEY (ID),
+    CONSTRAINT CART_ENTRIES_PK  PRIMARY KEY (DATASTORE_ID),
+    CONSTRAINT CART_ENTRIES_UK  UNIQUE      (ID),
     CONSTRAINT CARTS_FK         FOREIGN KEY (CART_ID)   REFERENCES CARTS,
     CONSTRAINT PRODUCTS_FK      FOREIGN KEY (SKU)       REFERENCES PRODUCTS
 );
 
 CREATE TABLE UNDETACHABLES (
+
+    DATASTORE_ID BIGINT NOT NULL,
     ID BIGINT NOT NULL,
     FOO INTEGER,
     BAR INTEGER,
 
-    CONSTRAINT UNDETACHABLES_PK PRIMARY KEY (ID)
+    CONSTRAINT UNDETACHABLES_PK PRIMARY KEY (DATASTORE_ID),
+    CONSTRAINT UNDETACHABLES_UK UNIQUE      (ID)
 );



Mime
View raw message