db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r573641 [1/2] - in /db/jdo/trunk/tck2/src: conf/ java/org/apache/jdo/tck/ java/org/apache/jdo/tck/mapping/
Date Fri, 07 Sep 2007 17:52:23 GMT
Author: mcaisse
Date: Fri Sep  7 10:52:21 2007
New Revision: 573641

URL: http://svn.apache.org/viewvc?rev=573641&view=rev
Log:
JDO-521 managed relationships tests

Added:
    db/jdo/trunk/tck2/src/conf/relationshipAllRelationships.conf
    db/jdo/trunk/tck2/src/conf/relationshipNoRelationships.conf
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyNoRelationships.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipNegative1To1Test.java   (with props)
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipNegative1ToManyTest.java   (with props)
Modified:
    db/jdo/trunk/tck2/src/conf/configurations.list
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java

Modified: db/jdo/trunk/tck2/src/conf/configurations.list
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/conf/configurations.list?rev=573641&r1=573640&r2=573641&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/conf/configurations.list (original)
+++ db/jdo/trunk/tck2/src/conf/configurations.list Fri Sep  7 10:52:21 2007
@@ -57,6 +57,8 @@
                  inheritance2.conf \
                  inheritance3.conf \
                  inheritance4.conf \
+                 relationshipAllRelationships.conf \
+                 relationshipNoRelationships.conf \
                  schemaAttributeClass.conf \
                  schemaAttributeOrm.conf \
                  schemaAttributePackage.conf \

Added: db/jdo/trunk/tck2/src/conf/relationshipAllRelationships.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/conf/relationshipAllRelationships.conf?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/conf/relationshipAllRelationships.conf (added)
+++ db/jdo/trunk/tck2/src/conf/relationshipAllRelationships.conf Fri Sep  7 10:52:21 2007
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+jdo.tck.description = Managed relationship tests with standard mapping, \
+ basic testdata with all relationships. 
+jdo.tck.mapping.companyfactory = 
+jdo.tck.testdata = org/apache/jdo/tck/pc/company/companyAllRelationships.xml
+jdo.tck.mapping = 0
+jdo.tck.requiredOptions =
+jdo.tck.classes = org.apache.jdo.tck.mapping.Relationship1To1AllRelationships \
+    org.apache.jdo.tck.mapping.Relationship1ToManyAllRelationships \
+    org.apache.jdo.tck.mapping.RelationshipManyToManyAllRelationships \
+

Added: db/jdo/trunk/tck2/src/conf/relationshipNoRelationships.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/conf/relationshipNoRelationships.conf?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/conf/relationshipNoRelationships.conf (added)
+++ db/jdo/trunk/tck2/src/conf/relationshipNoRelationships.conf Fri Sep  7 10:52:21 2007
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+jdo.tck.description = Managed relationship tests with standard mapping, \
+ basic testdata with no relationships. 
+jdo.tck.mapping.companyfactory =
+jdo.tck.testdata = org/apache/jdo/tck/pc/company/companyNoRelationships.xml
+jdo.tck.mapping = 0
+jdo.tck.requiredOptions =
+jdo.tck.classes = org.apache.jdo.tck.mapping.Relationship1To1NoRelationships \
+    org.apache.jdo.tck.mapping.Relationship1ToManyNoRelationships \
+    org.apache.jdo.tck.mapping.RelationshipManyToManyNoRelationships \
+    org.apache.jdo.tck.mapping.RelationshipNegative1To1Test \
+    org.apache.jdo.tck.mapping.RelationshipNegative1ToManyTest \

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java?rev=573641&r1=573640&r2=573641&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java Fri Sep  7 10:52:21 2007
@@ -187,6 +187,9 @@
      */   
     protected static final boolean closePMFAfterEachTest =
         System.getProperty("jdo.tck.closePMFAfterEachTest", "false").equalsIgnoreCase("true");
+
+    /** */
+    protected final boolean isTestToBePerformed = isTestToBePerformed();
     
     /** The Properties object for the PersistenceManagerFactory. */
     protected static Properties PMFPropertiesObject;
@@ -1081,6 +1084,15 @@
         messages.append(NL);
     }
     
+    /** Appends to error messages.
+     */
+    protected static synchronized void deferredAssertTrue(Boolean test,
+        String context, String message) {
+        if (!test) {
+            appendMessage(context + ": " +message);
+        }
+    }
+
     /**
      * Returns collected error messages, or <code>null</code> if there
      * are none, and clears the buffer.

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyFactoryRegistry;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+
+/*
+ * Abstract class for managed relationship tests
+ */
+public class AbstractRelationshipTest extends JDO_Test {
+    
+    /** */
+    protected List rootOids;
+    
+    /** */
+    protected final String inputFilename = System.getProperty("jdo.tck.testdata");
+    
+    protected CompanyModelReader reader = null;
+    
+    protected Map oidMap = new HashMap();
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        if (isTestToBePerformed) {
+            getPM();
+            CompanyFactoryRegistry.registerFactory(pm);
+            reader = new CompanyModelReader(inputFilename);
+            addTearDownClass(reader.getTearDownClassesFromFactory());
+            // persist test data
+            pm.currentTransaction().begin();
+            List rootList = reader.getRootList();
+            pm.makePersistentAll(rootList);
+            rootOids = new ArrayList();
+            for (Iterator i = rootList.iterator(); i.hasNext(); ) {
+                Object pc = i.next();
+                rootOids.add(pm.getObjectId(pc));
+            }
+            // DO THIS
+            // in xmlBeanFactory String[] getBeanDefinitionNames()
+            oidMap.put("emp1", pm.getObjectId(reader.getEmployee("emp1")));
+            oidMap.put("emp2", pm.getObjectId(reader.getEmployee("emp2")));
+            oidMap.put("emp4", pm.getObjectId(reader.getEmployee("emp4")));
+            oidMap.put("medicalIns1",
+                pm.getObjectId(reader.getMedicalInsurance("medicalIns1")));
+            oidMap.put("medicalIns2",
+                pm.getObjectId(reader.getMedicalInsurance("medicalIns2")));
+            oidMap.put("dept1", pm.getObjectId(reader.getDepartment("dept1")));
+            oidMap.put("dept2", pm.getObjectId(reader.getDepartment("dept2")));
+            oidMap.put("proj1", pm.getObjectId(reader.getProject("proj1")));
+            oidMap.put("proj2", pm.getObjectId(reader.getProject("proj2")));
+             
+            pm.currentTransaction().commit();
+            cleanupPM();
+        }
+    }
+    
+    protected Object getOidByName(String name) {
+        return oidMap.get((Object)name);
+    }
+    
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,419 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.util.Date;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.IEmployee;
+import org.apache.jdo.tck.pc.company.IMedicalInsurance;
+import org.apache.jdo.tck.pc.company.MedicalInsurance;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B>Relationship1To1AllRelationships
+ *<BR>
+ *<B>Keywords:</B> mapping, managed relationships
+ *<BR>
+ *<B>Assertion ID:</B> A15.3-1
+ *<BR>
+ *<B>Assertion Description: Regardless of which side changes the relationship,
+ * flush (whether done as part of commit or explicitly by the user) will modify
+ * the datastore to reflect the change and will update the memory model
+ * for consistency.</B>
+ */
+
+public class Relationship1To1AllRelationships extends AbstractRelationshipTest {
+    
+    String testMethod = null;
+    protected String ASSERTION_FAILED =
+        "Assertion A15-3.1 (Relationship1To1AllRelationships) failed: ";
+    
+    /**
+     * 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(Relationship1To1AllRelationships.class);
+    }
+    
+    Object emp1Oid = null;
+    Object emp2Oid = null;
+    Object medIns1Oid = null;
+    Object medIns2Oid = null;
+    IEmployee emp1 = null;
+    IEmployee emp2 = null;
+    IMedicalInsurance medIns1 = null;
+    IMedicalInsurance medIns2 = null;
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        super.localSetUp();
+        if (isTestToBePerformed) {
+            getPM();
+            pm.currentTransaction().begin();
+            
+            emp1Oid = getOidByName("emp1");
+            emp2Oid = getOidByName("emp2");
+            medIns1Oid = getOidByName("medicalIns1");
+            medIns2Oid = getOidByName("medicalIns2");
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            emp2 = (IEmployee)pm.getObjectById(emp2Oid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid);
+            
+            // Preconditions
+            assertTrue(ASSERTION_FAILED + testMethod +
+                ": Test aborted, precondition is false; " +
+                "expected emp.getMedicalInsurance()to be medicalIns1",
+                emp1.getMedicalInsurance() == medIns1);
+            assertTrue(ASSERTION_FAILED + testMethod +
+                ": Test aborted, precondition is false; " +
+                "expected ins.getEmployee() to be emp1",
+                medIns1.getEmployee() == emp1);
+            assertTrue(ASSERTION_FAILED + testMethod +
+                ": Test aborted, precondition is false; " +
+                "expected emp.getMedicalInsurance()to be medicalIns1",
+                emp2.getMedicalInsurance() == medIns2);
+            assertTrue(ASSERTION_FAILED + testMethod +
+                ": Test aborted, precondition is false; " +
+                "expected ins.getEmployee() to be emp1",
+                medIns2.getEmployee() == emp2);
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedSide() {
+        testMethod = "testSetToExistingFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            medIns1.setEmployee(emp2);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp2.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp1) not nulled on flush");
+            deferredAssertTrue(medIns2.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns2) not nulled on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            emp2 = (IEmployee)pm.getObjectById(emp2Oid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid);
+            deferredAssertTrue(emp2.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp1) not nulled in new pm");
+            deferredAssertTrue(medIns2.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns2) not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedBySide() {
+        testMethod = "testSetToExistingFromMappedBySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            emp1.setMedicalInsurance(medIns2);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(medIns2.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush.");
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns1) not nulled on flush.");
+            deferredAssertTrue(emp2.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp2) not nulled on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            emp2 = (IEmployee)pm.getObjectById(emp2Oid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid);
+            deferredAssertTrue(medIns2.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm.");
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns1) not nulled in new pm.");
+            deferredAssertTrue(emp2.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp2) not nulled in new pm.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNullFromMappedSide() {
+        testMethod = "testSetToNullFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            medIns1.setEmployee(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNullFromMappedBySide() {
+        testMethod = "testSetToNullFromMappedBySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            emp1.setMedicalInsurance(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            //emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(
+                medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedSide() {
+        testMethod = "testSetToNewFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            IEmployee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams",
+                new Date(0L), new Date(10000L), 125000);
+            pm.makePersistent(empNew);
+            medIns1.setEmployee(empNew);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+            pm.flush();
+            
+            assertFalse(testMethod + ": Test aborted, precondition is false; " +
+                "expected empNewOid to be non-null", empNewOid == null);
+            
+            // Postcondition
+            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp1) not nulled on flush");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            empNew = (IEmployee)pm.getObjectById(empNewOid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (emp1) not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedBySide() {
+        testMethod = "testSetToNewFromMappedBySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            IMedicalInsurance medInsNew = new MedicalInsurance(99L,
+                "Ameriblast", "B");
+            pm.makePersistent(medInsNew);
+            emp1.setMedicalInsurance(medInsNew);
+            Object medInsNewOid = pm.getObjectId((Object)medInsNew);
+            pm.flush();
+            
+            assertFalse(testMethod + ": Test aborted, precondition is false; " +
+                "expected medInsNewOid to be non-null", medInsNewOid == null);
+            
+            // Postcondition
+            deferredAssertTrue(medInsNew.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush.");
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns1) not nulled on flush.");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            medInsNew = (IMedicalInsurance)pm.getObjectById(medInsNewOid);
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(medInsNew.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (medIns1) not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    /** */
+    public void testDeleteFromMappedSide() {
+        testMethod = "testDeleteFromMappedSide";
+        if (isTestToBePerformed) {
+            // Set relationship
+            pm.deletePersistent(medIns1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (IEmployee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                emp1.getMedicalInsurance() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testDeleteFromMappedBySide() {
+        testMethod = "testDeleteFromMappedBySide";
+        if (isTestToBePerformed) {
+            // Set relationship
+            pm.deletePersistent(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(
+                medIns1.getEmployee() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.util.Date;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.MedicalInsurance;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B>Relationship1To1NoRelationships
+ *<BR>
+ *<B>Keywords:</B> mapping, managed relationships
+ *<BR>
+ *<B>Assertion ID:</B> A15.3-1
+ *<BR>
+ *<B>Assertion Description: Regardless of which side changes the relationship,
+ * flush (whether done as part of commit or explicitly by the user) will modify
+ * the datastore to reflect the change and will update the memory model
+ * for consistency.</B>
+ */
+
+public class Relationship1To1NoRelationships extends AbstractRelationshipTest {
+    
+    String testMethod = null;
+    protected String ASSERTION_FAILED =
+        "Assertion A15-3.1 (Relationship1To1NoRelationships) failed: ";
+    
+    Object emp1Oid = null;
+    Object emp2Oid = null;
+    Object medIns1Oid = null;
+    Object medIns2Oid = null;
+    Employee emp1 = null;
+    Employee emp2 = null;
+    MedicalInsurance medIns1 = null;
+    MedicalInsurance medIns2 = null;
+    
+    /**
+     * 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(Relationship1To1NoRelationships.class);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        super.localSetUp();
+        if (isTestToBePerformed) {
+            getPM();
+            pm.currentTransaction().begin();
+            
+            emp1Oid = getOidByName("emp1");
+            medIns1Oid = getOidByName("medicalIns1");
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
+            
+            // Preconditions
+            assertTrue(ASSERTION_FAILED +
+                ": Test aborted, precondition is false; " +
+                "expected emp.getMedicalInsurance()to be null",
+                emp1.getMedicalInsurance() == null);
+            assertTrue(ASSERTION_FAILED +
+                ": Test aborted, precondition is false; " +
+                "expected ins.getEmployee() to be null",
+                medIns1.getEmployee() == null);
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedSide() {
+        testMethod = "testSetToExistingFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            medIns1.setEmployee(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(
+                emp1.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedBySide() {
+        testMethod = "testSetToExistingFromMappedBySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            emp1.setMedicalInsurance(medIns1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(medIns1.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(
+                medIns1.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedSide() {
+        testMethod = "testSetToNewFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams",
+                new Date(0L), new Date(10000L), 125000);
+            pm.makePersistent(empNew);
+            medIns1.setEmployee(empNew);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            empNew = (Employee)pm.getObjectById(empNewOid);
+            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedBySide() {
+        testMethod = "testSetToNewFromMappedBySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            MedicalInsurance medInsNew = new MedicalInsurance(99L,
+                "Ameriblast", "B");
+            pm.makePersistent(medInsNew);
+            emp1.setMedicalInsurance(medInsNew);
+            Object medInsNewOid = pm.getObjectId((Object)medInsNew);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(medInsNew.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush.");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            medInsNew = (MedicalInsurance)pm.getObjectById(medInsNewOid);
+            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
+            deferredAssertTrue(medInsNew.getEmployee() == emp1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,464 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.IDepartment;
+import org.apache.jdo.tck.pc.company.IEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B>Relationship1ToManyAllRelationships
+ *<BR>
+ *<B>Keywords:</B> mapping, managed relationships
+ *<BR>
+ *<B>Assertion ID:</B> A15.3-1
+ *<BR>
+ *<B>Assertion Description: Regardless of which side changes the relationship,
+ * flush (whether done as part of commit or explicitly by the user) will modify
+ * the datastore to reflect the change and will update the memory model
+ * for consistency.</B>
+ */
+
+public class Relationship1ToManyAllRelationships extends AbstractRelationshipTest {
+    
+    String testMethod = null;
+    protected String ASSERTION_FAILED =
+        "Assertion A15-3.1 (Relationship1ToManyAllRelationships) failed: ";
+    
+    Object emp1Oid = null;
+    Object dept1Oid = null;
+    Object dept2Oid = null;
+    Employee emp1 = null;
+    Department dept1 = null;
+    Department dept2 = null;
+    
+    /**
+     * 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(Relationship1ToManyAllRelationships.class);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        super.localSetUp();
+        if (isTestToBePerformed) {
+            getPM();
+            pm.currentTransaction().begin();
+            
+            emp1Oid = getOidByName("emp1");
+            dept1Oid = getOidByName("dept1");
+            dept2Oid = getOidByName("dept2");
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            dept2 = (Department)pm.getObjectById(dept2Oid);
+            
+            // Preconditions
+            assertTrue(ASSERTION_FAILED +
+                ": Test aborted, precondition is false; " +
+                "expected emp.getDepartment()to be dept1",
+                emp1.getDepartment() == dept1);
+            assertTrue(ASSERTION_FAILED +
+                ": Test aborted, precondition is false; " +
+                "expected dept.getEmployees() to contain emp1",
+                dept1.getEmployees().contains(emp1));
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedSide() {
+        testMethod = "testSetToExistingFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            emp1.setDepartment(dept2);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(dept2.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; reference emp1 not removed "
+                + "from previous relationship (dept1.employees)");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            dept2 = (Department)pm.getObjectById(dept2Oid);
+            deferredAssertTrue(dept2.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; reference emp1 not removed "
+                + "from previous relationship (dept1.employees)");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+        
+    /** */
+    public void testAddExistingFromMappedbySide() {
+        testMethod = "testAddExistingFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Object emp4Oid = getOidByName("emp4");
+            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
+            Object dept2Oid = getOidByName("dept2");
+            Department dept2 = (Department)pm.getObjectById(dept2Oid);
+
+            dept1.addEmployee(emp4);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp4.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not unset on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp4 = (Employee)pm.getObjectById(emp4Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            dept2 = (Department)pm.getObjectById(dept2Oid);
+            deferredAssertTrue(emp4.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not unset on flush");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testReplaceFromMappedbySide() {
+        testMethod = "testReplaceFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Object emp4Oid = getOidByName("emp4");
+            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
+            Object dept2Oid = getOidByName("dept2");
+            Department dept2 = (Department)pm.getObjectById(dept2Oid);
+
+            Set emps = new HashSet();
+            emps.add(emp4);
+            dept1.setEmployees(emps);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp4.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not unset on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp4 = (Employee)pm.getObjectById(emp4Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            dept2 = (Department)pm.getObjectById(dept2Oid);
+            deferredAssertTrue(emp4.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not unset on flush");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testAddNewFromMappedbySide() {
+        testMethod = "testAddNewFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Employee empNew = new FullTimeEmployee(101, "Jenny", "Merriwether",
+                "White", new Date(500L), new Date(10000L), 135000);
+            pm.makePersistent(empNew);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+
+            dept1.addEmployee(empNew);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(empNew.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            empNew = (Employee)pm.getObjectById(empNewOid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(empNew.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testSetToNullFromMappedSide() {
+        testMethod = "testSetToNullFromMappedSide";
+        if (isTestToBePerformed) {
+            // Set relationship
+            emp1.setDepartment(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(
+                !dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNullFromMappedbySide() {
+        testMethod = "testSetToNullFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            dept1.setEmployees(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedSide() {
+        testMethod = "testSetToNewFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            IDepartment deptNew = new Department(99L, "The New Department");
+            pm.makePersistent(deptNew);
+            emp1.setDepartment(deptNew);
+            Object deptNewOid = pm.getObjectId((Object)deptNew);
+            pm.flush();
+            
+            assertFalse(testMethod + ": Test aborted, precondition is false; " +
+                "expected deptNewOid to be non-null", deptNewOid == null);
+            
+            // Postcondition
+            deferredAssertTrue(deptNew.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (dept1) not nulled on flush");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deptNew = (Department)pm.getObjectById(deptNewOid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(deptNew.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (dept1) not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testRemoveFromMappedbySide() {
+        testMethod = "testRemoveFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            dept1.removeEmployee(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testDeleteFromMappedSide() {
+        testMethod = "testDeleteFromMappedSide";
+        if (isTestToBePerformed) {
+            // Set relationship
+            pm.deletePersistent(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(
+                !dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testDeleteFromMappedbySide() {
+        testMethod = "testDeleteFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            pm.deletePersistent(dept1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B>Relationship1ToManyNoRelationships
+ *<BR>
+ *<B>Keywords:</B> mapping, managed relationships
+ *<BR>
+ *<B>Assertion ID:</B> A15.3-1
+ *<BR>
+ *<B>Assertion Description: Regardless of which side changes the relationship,
+ * flush (whether done as part of commit or explicitly by the user) will modify
+ * the datastore to reflect the change and will update the memory model
+ * for consistency.</B>
+ */
+
+public class Relationship1ToManyNoRelationships extends AbstractRelationshipTest {
+    
+    String testMethod = null;
+    protected String ASSERTION_FAILED =
+        "Assertion A15-3.1 (Relationship1ToManyNoRelationships) failed: ";
+    
+    Object emp1Oid = null;
+    Object dept1Oid = null;
+    Object dept2Oid = null;
+    Employee emp1 = null;
+    Department dept1 = null;
+    Department dept2 = null;
+    
+    /**
+     * 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(Relationship1ToManyNoRelationships.class);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        super.localSetUp();
+        if (isTestToBePerformed) {
+            getPM();
+            pm.currentTransaction().begin();
+            
+            emp1Oid = getOidByName("emp1");
+            dept1Oid = getOidByName("dept1");
+            dept2Oid = getOidByName("dept2");
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            dept2 = (Department)pm.getObjectById(dept2Oid);
+            
+            // Preconditions
+            assertTrue(ASSERTION_FAILED +
+                ": Test aborted, precondition is false; " +
+                "expected emp.getDepartment()to be dept1",
+                emp1.getDepartment() == dept1);
+            assertTrue(ASSERTION_FAILED + testMethod +
+                ": Test aborted, precondition is false; " +
+                "expected dept.getEmployees() to contain emp1",
+                dept1.getEmployees().contains(emp1));
+        }
+    }
+    
+    /** */
+    public void testSetToExistingFromMappedSide() {
+        testMethod = "testSetToExistingFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            emp1.setDepartment(dept1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(
+                dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testAddExistingFromMappedbySide() {
+        testMethod = "testSetToExistingFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Set emps = new HashSet();
+            emps.add(emp1);
+            dept1.setEmployees(emps);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(emp1.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(
+                emp1.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "In new transaction, postcondition is false; " +
+                "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedSide() {
+        testMethod = "testSetToNewFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Department deptNew = new Department(99L, "The New Department");
+            emp1.setDepartment(deptNew);
+            pm.makePersistent(deptNew);
+            Object deptNewOid = pm.getObjectId((Object)deptNew);
+            pm.flush();
+            
+            assertFalse(testMethod + ": Test aborted, precondition is false; " +
+                "expected deptNewOid to be non-null", deptNewOid == null);
+            
+            // Postcondition
+            deferredAssertTrue(deptNew.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (dept1) not nulled on flush");
+            
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deptNew = (Department)pm.getObjectById(deptNewOid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(deptNew.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(!dept1.getEmployees().contains(emp1),
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship (dept1) not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNewFromMappedbySide() {
+        testMethod = "testSetToNewFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Set emps = new HashSet();
+            Employee empNew = new FullTimeEmployee(101, "Jenny", "Merriwether",
+                "White", new Date(500L), new Date(10000L), 135000);
+            pm.makePersistent(empNew);
+            emps.add(empNew);
+            dept1.setEmployees(emps);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(empNew.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set on flush");
+            deferredAssertTrue(emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not nulled on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            empNew = (Employee)pm.getObjectById(empNewOid);
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            dept1 = (Department)pm.getObjectById(dept1Oid);
+            deferredAssertTrue(empNew.getDepartment() == dept1,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "other side of relationship not set in new pm");
+            deferredAssertTrue(emp1.getDepartment() == null,
+                ASSERTION_FAILED + testMethod,
+                "Postcondition is false; "
+                + "previous relationship not nulled in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java?rev=573641&view=auto
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java (added)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java Fri Sep  7 10:52:21 2007
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mapping;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.IEmployee;
+import org.apache.jdo.tck.pc.company.IProject;
+import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+
+/**
+ *<B>Title:</B>RelationshipManyToManyAllRelationships
+ *<BR>
+ *<B>Keywords:</B> mapping, managed relationships
+ *<BR>
+ *<B>Assertion ID:</B> A15.3-1
+ *<BR>
+ *<B>Assertion Description: Regardless of which side changes the relationship,
+ * flush (whether done as part of commit or explicitly by the user) will modify
+ * the datastore to reflect the change and will update the memory model
+ * for consistency.</B>
+ */
+
+public class RelationshipManyToManyAllRelationships
+        extends AbstractRelationshipTest {
+    
+    String testMethod = null;
+    protected String ASSERTION_FAILED =
+            "Assertion A15-3.1 (RelationshipManyToManyAllRelationships) failed: ";
+
+            Object emp1Oid = null;
+            Object proj1Oid = null;
+            Employee emp1 = null;
+            Project proj1 = null;
+            
+    /**
+     * 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(RelationshipManyToManyAllRelationships.class);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        super.localSetUp();
+        if (isTestToBePerformed) {
+             
+            getPM();
+            pm.currentTransaction().begin();
+            
+            emp1Oid = getOidByName("emp1");
+            proj1Oid = getOidByName("proj1");
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            
+            // Preconditions
+            assertTrue(testMethod +
+                    ": Test aborted, precondition is false; " +
+                    "expected emp.getProjects()to be contain proj1",
+                    emp1.getProjects().contains(proj1));
+            assertTrue(testMethod +
+                    ": Test aborted, precondition is false; " +
+                    "expected proj.getMembers() to contain emp1",
+                    proj1.getMembers().contains(emp1));
+        }
+    }
+    
+    /** */
+    public void testSetToNullFromMappedSide() {
+        testMethod = "testSetToNullFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            proj1.setMembers(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(
+                    !emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testSetToNullFromMappedbySide() {
+        testMethod = "testSetToNullFromMappedbySide";
+        if (isTestToBePerformed) {  
+            // Set relationship
+            emp1.setProjects(null);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(
+                    !proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testReplaceFromMappedSide() {
+        testMethod = "testReplaceFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            IEmployee empNew = new FullTimeEmployee(100, "Jerry", "Valentine",
+                    "Brown", new Date(500L), new Date(10000L), 125000);
+            pm.makePersistent(empNew);
+            Set members = new HashSet();
+            members.add(empNew);
+            proj1.setMembers(members);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+            pm.flush();
+
+            // Postcondition
+
+            deferredAssertTrue(empNew.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            empNew = (IEmployee)pm.getObjectById(empNewOid);
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(empNew.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testReplaceFromMappedbySide() {
+        testMethod = "testReplaceFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            IProject projNew = new Project(99L, "Skunkworks",
+                    new BigDecimal(10000.35));
+            pm.makePersistent(projNew);
+            Set projects = new HashSet();
+            projects.add(projNew);
+            emp1.setProjects(projects);
+            Object projNewOid = pm.getObjectId((Object)projNew);
+            pm.flush();
+
+            // Postcondition
+             deferredAssertTrue(projNew.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            projNew = (Project)pm.getObjectById(projNewOid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+             deferredAssertTrue(projNew.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testAddNewFromMappedSide() {
+        testMethod = "testAddNewFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Employee empNew = new FullTimeEmployee(100, "Jerry", "Valentine",
+                    "Brown", new Date(500L), new Date(10000L), 125000);
+            pm.makePersistent(empNew);
+            proj1.addMember(empNew);
+            Object empNewOid = pm.getObjectId((Object)empNew);
+            pm.flush();
+
+            // Postcondition
+
+            deferredAssertTrue(empNew.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            empNew = (Employee)pm.getObjectById(empNewOid);
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(empNew.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testAddNewFromMappedbySide() {
+        testMethod = "testAddNewFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Project projNew = new Project(99L, "Skunkworks",
+                    new BigDecimal(10000.35));
+            pm.makePersistent(projNew);
+            emp1.addProject(projNew);
+            Object projNewOid = pm.getObjectId((Object)projNew);
+            pm.flush();
+
+            // Postcondition
+             deferredAssertTrue(projNew.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            projNew = (Project)pm.getObjectById(projNewOid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+             deferredAssertTrue(projNew.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    /** */
+    public void testAddExistingFromMappedSide() {
+        testMethod = "testAddExistingFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Object emp4Oid = getOidByName("emp4");
+            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
+            proj1.addMember(emp4);
+            pm.flush();
+
+            // Postcondition
+
+            deferredAssertTrue(emp4.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp4 = (Employee)pm.getObjectById(emp4Oid);
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(emp4.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testAddExistingFromMappedbySide() {
+        testMethod = "testAddExistingFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            Object proj2Oid = getOidByName("proj2");
+            Project proj2 = (Project)pm.getObjectById(proj2Oid);
+            emp1.addProject(proj2);
+            pm.flush();
+
+            // Postcondition
+             deferredAssertTrue(proj2.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj2 = (Project)pm.getObjectById(proj2Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+             deferredAssertTrue(proj2.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set in new pm");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+
+    /** */
+    public void testRemoveFromMappedSide() {
+        testMethod = "testRemoveFromMappedSide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            proj1.removeMember(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(
+                    !emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testRemoveFromMappedbySide() {
+        testMethod = "testRemoveFromMappedbySide";
+        if (isTestToBePerformed) {
+                        
+            // Set relationship
+            emp1.removeProject(proj1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(
+                    !proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    /** */
+    public void testDeleteFromMappedSide() {
+    testMethod = "testDeleteFromMappedSide";
+        if (isTestToBePerformed) {
+            // Set relationship
+            pm.deletePersistent(proj1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            emp1 = (Employee)pm.getObjectById(emp1Oid);
+            deferredAssertTrue(
+                    !emp1.getProjects().contains(proj1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+    
+    /** */
+    public void testDeleteFromMappedbySide() {
+        testMethod = "testDeleteFromMappedbySide";
+        if (isTestToBePerformed) {
+            
+            // Set relationship
+            pm.deletePersistent(emp1);
+            pm.flush();
+            
+            // Postcondition
+            deferredAssertTrue(!proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "Postcondition is false; "
+                    + "other side of relationship not set on flush");
+            pm.currentTransaction().commit();
+            cleanupPM();
+            getPM();
+            
+            pm.currentTransaction().begin();
+            proj1 = (Project)pm.getObjectById(proj1Oid);
+            deferredAssertTrue(
+                    !proj1.getMembers().contains(emp1),
+                    ASSERTION_FAILED + testMethod,
+                    "In new transaction, postcondition is false; " +
+                    "other side of relationship is not set.");
+            pm.currentTransaction().commit();
+            
+            failOnError();
+        }
+    }
+}

Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java
------------------------------------------------------------------------------
    svn:eol-style = LF



Mime
View raw message