db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r158179 [15/61] - in incubator/jdo/trunk/tck11: ./ assertions/ iut_jars/ test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/jdo/ test/java/org/apache/jdo/tck/ test/java/org/apache/jdo/tck/api/ test/java/org/apache/jdo/tck/api/instancecallbacks/ test/java/org/apache/jdo/tck/api/jdohelper/ test/java/org/apache/jdo/tck/api/persistencemanager/ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ test/java/org/apache/jdo/tck/enhancement/ test/java/org/apache/jdo/tck/extents/ test/java/org/apache/jdo/tck/lifecycle/ test/java/org/apache/jdo/tck/lifecycle/nontransactional/ test/java/org/apache/jdo/tck/models/ test/java/org/apache/jdo/tck/models/embedded/ test/java/org/apache/jdo/tck/models/fieldtypes/ test/java/org/apache/jdo/tck/models/inheritance/ test/java/org/apache/jdo/tck/pc/ test/java/org/apache/jdo/tck/pc/company/ test/java/org/apache/jdo/tck/pc/fieldtypes/ test/java/org/apache/jdo/tck/pc/inheritance/ test/java/org/apache/jdo/tck/pc/instancecallbacks/ test/java/org/apache/jdo/tck/pc/lifecycle/ test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/ test/java/org/apache/jdo/tck/query/operators/ test/java/org/apache/jdo/tck/transactions/ test/java/org/apache/jdo/tck/util/ test/jdo/ test/jdo/applicationidentity/ test/jdo/applicationidentity/org/ test/jdo/applicationidentity/org/apache/ test/jdo/applicationidentity/org/apache/jdo/ test/jdo/applicationidentity/org/apache/jdo/tck/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ test/jdo/datastoreidentity/ test/jdo/datastoreidentity/org/ test/jdo/datastoreidentity/org/apache/ test/jdo/datastoreidentity/org/apache/jdo/ test/jdo/datastoreidentity/org/apache/jdo/tck/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/
Date Sat, 19 Mar 2005 01:09:46 GMT
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveshort;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type short.
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of the primitive type <code>short</code>.
+ */
+
+public class TestFieldsOfPrimitiveshort extends JDO_Test {
+    
+   /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-3 (TestFieldsOfPrimitiveshort) 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(TestFieldsOfPrimitiveshort.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, n;
+            short value;
+            tx.begin();
+            FieldsOfPrimitiveshort pi = new FieldsOfPrimitiveshort();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for( i = 0, value = 10; i < n; ++i){
+                pi.set( i, value);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
+            checkValues(oid, (short)10); // check if persistent fields have values set
+
+            // Provide new set of values
+            for( i = 0, value = 32000; i < n; ++i){
+                pi.set(i, value);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, (short)32000);
+            pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, short startValue){
+        int i;
+        FieldsOfPrimitiveshort pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            if( !FieldsOfPrimitiveshort.isPersistent[i] ) continue;
+            short val = pi.get(i);
+            if( val != startValue ){
+                fail(ASSERTION_FAILED,
+                        "Incorrect value for " + FieldsOfPrimitiveshort.fieldSpecs[i] +
+                        ", expected value " + startValue +
+                        ", value is " + val);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.FieldsOfShort;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type Short.
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-12.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of the immutable object class
+<code>java.lang.Short</code>, and may choose to support them as
+Second Class Objects or First Class Objects.
+ */
+
+
+public class TestFieldsOfShort extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-12 (TestFieldsOfShort) 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(TestFieldsOfShort.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, n;
+            Short firstValue = new Short(Short.MIN_VALUE);
+            Short secondValue = new Short(Short.MAX_VALUE);
+            tx.begin();
+            FieldsOfShort pi = new FieldsOfShort();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for( i = 0; i < n; ++i){
+                pi.set( i, firstValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            pi = (FieldsOfShort) pm.getObjectById(oid, true);
+            checkValues(oid, firstValue); // check if persistent fields have values set
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                pi.set(i, secondValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (FieldsOfShort) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, Short startValue){
+        int i;
+        Short value;
+        FieldsOfShort pi = (FieldsOfShort) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0, value = startValue; i < n; ++i){
+            if( !FieldsOfShort.isPersistent[i] ) continue;
+            Short val = pi.get(i);
+            if(!val.equals(startValue) ){
+                fail(ASSERTION_FAILED,
+                        "Incorrect value for " + FieldsOfShort.fieldSpecs[i] +
+                        ", expected value " + startValue.toString() +
+                        ", value is " + val.toString());
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleClass;
+import org.apache.jdo.tck.pc.fieldtypes.SimpleClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of fields of PersistenceCapable class types
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-30.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of <code>PersistenceCapable</code>
+class types as First Class Objects.
+ */
+
+public class TestFieldsOfSimpleClass extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-30 (TestFieldsOfSimpleClass) 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(TestFieldsOfSimpleClass.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, n;
+            SimpleClass firstValue = new SimpleClass(100, "Hello");
+            SimpleClass secondValue = new SimpleClass(2000, "Hello World");
+            tx.begin();
+            FieldsOfSimpleClass pi = new FieldsOfSimpleClass();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for( i = 0; i < n; ++i){
+                pi.set( i, firstValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
+            checkValues(oid, firstValue); // check if persistent fields have values set
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                pi.set(i, secondValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, SimpleClass startValue){
+        int i;
+        FieldsOfSimpleClass pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            if( !FieldsOfSimpleClass.isPersistent[i] ) continue;
+            SimpleClass val = pi.get(i);
+            if(!val.equals(startValue) ){
+                fail(ASSERTION_FAILED,
+                        "Incorrect value for " + FieldsOfSimpleClass.fieldSpecs[i]);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleInterface;
+import org.apache.jdo.tck.pc.fieldtypes.SimpleClass;
+import org.apache.jdo.tck.pc.fieldtypes.SimpleInterface;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of interfaces as field type.
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-32.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of interface types, and may choose
+to support them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestFieldsOfSimpleInterface extends JDO_Test {
+    
+   /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-32 (TestFieldsOfSimpleInterface) 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(TestFieldsOfSimpleInterface.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, n;
+            SimpleInterface firstValue = new SimpleClass(100, "Hello");
+            SimpleInterface secondValue = new SimpleClass(2000, "Hello World");
+            tx.begin();
+            FieldsOfSimpleInterface pi = new FieldsOfSimpleInterface();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for( i = 0; i < n; ++i){
+                pi.set( i, firstValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
+            checkValues(oid, firstValue); // check if persistent fields have values set
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                pi.set(i, secondValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, SimpleInterface startValue){
+        int i;
+        FieldsOfSimpleInterface pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            if( !FieldsOfSimpleInterface.isPersistent[i] ) continue;
+            SimpleInterface val = pi.get(i);
+            if(!val.equals(startValue)){
+                fail(ASSERTION_FAILED,
+                        "Incorrect value for " + FieldsOfSimpleInterface.fieldSpecs[i]); 
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.FieldsOfString;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type String.
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-17.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of the immutable object class
+<code>java.lang.String</code>, and may choose to support them as
+Second Class Objects or First Class Objects.
+ */
+
+
+public class TestFieldsOfString extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-17 (TestFieldsOfString) 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(TestFieldsOfString.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, n;
+            String firstValue = new String("Hello");
+            String secondValue = new String("Hello World");
+            tx.begin();
+            FieldsOfString pi = new FieldsOfString();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for( i = 0; i < n; ++i){
+                pi.set( i, firstValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            pi = (FieldsOfString) pm.getObjectById(oid, true);
+            checkValues(oid, firstValue); // check if persistent fields have values set
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                pi.set(i, secondValue);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (FieldsOfString) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, String startValue){
+        int i;
+        String value;
+        FieldsOfString pi = (FieldsOfString) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0, value = startValue; i < n; ++i){
+            if( !FieldsOfString.isPersistent[i] ) continue;
+            String val = pi.get(i);
+            if(!val.equals(startValue) ){
+                fail(ASSERTION_FAILED,
+                        "Incorrect value for " + FieldsOfString.fieldSpecs[i] +
+                        ", expected value " + value +
+                        ", value is " + val.toString());
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.HashMapStringKeyCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type HashMap, varying value type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-24.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the HashMap optional feature is supported, then JDO implementation must
+support fields of the mutable object class <code>HashMap</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestHashMapStringKeyCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-24 (TestHashMapStringKeyCollections) 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(TestHashMapStringKeyCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) 
+    {
+        if (!isHashMapSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature HashMap");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+        
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            HashMapStringKeyCollections pi = new HashMapStringKeyCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                HashMap map = new HashMap();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+            pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                HashMap map = new HashMap();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i, j;
+
+        HashMapStringKeyCollections pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            HashMap compareWith = new HashMap();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            
+            for (j = 0; j< keys.size(); j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            HashMap val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " +HashMapStringKeyCollections.fieldSpecs[i]);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.HashMapStringValueCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type HashMap, varying key type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-24.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the HashMap optional feature is supported, then JDO implementation must
+support fields of the mutable object class <code>HashMap</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+public class TestHashMapStringValueCollections extends JDO_Test {
+
+   /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-24 (TestHashMapStringValueCollections) 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(TestHashMapStringValueCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) 
+    {
+        if (!isHashMapSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature HashMap");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try { 
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue = 
+                    new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue = 
+                    new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            HashMapStringValueCollections pi = new HashMapStringValueCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashMapStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                HashMap map = new HashMap();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+            pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashMapStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                HashMap map = new HashMap();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int ret = 0;
+        int i, j;
+
+        HashMapStringValueCollections pi = 
+            (HashMapStringValueCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                HashMapStringValueCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            HashMap compareWith = new HashMap();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            
+            for (j = 0; j< keys.size(); j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            HashMap val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + HashMapStringValueCollections.fieldSpecs[i]);
+            }
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Hashtable;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.HashSetCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type HashSet
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-22.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must support fields of the mutable object class
+<code>java.util.HashSet</code>, and may choose to support them as
+Second Class Objects or First Class Objects.
+ */
+
+
+public class TestHashSetCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-22 (TestHashSetCollections) 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(TestHashSetCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm)
+    {
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, n;
+            FirstSetOfTestValuesForCollection firstValue = new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue = new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            HashSetCollections pi = new HashSetCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
+                pi.set( i, new HashSet((Collection)firstValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            checkValues(oid, firstValue); // check if persistent fields have values set
+            pi = (HashSetCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
+                pi.set( i, new HashSet((Collection)secondValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (HashSetCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i;
+
+        HashSetCollections pi = (HashSetCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
+            HashSet compareWith = new HashSet((Collection)startValue.get(valueType));
+
+            HashSet val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + HashSetCollections.fieldSpecs[i]);
+            }
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.HashtableStringKeyCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type Hashtable, varying value type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-25.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the Hashtable optional feature is supported, then JDO implementation must
+support fields of the mutable object class <code>Hashtable</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestHashtableStringKeyCollections extends JDO_Test {
+   
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-25 (TestHashtableStringKeyCollections) 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(TestHashtableStringKeyCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) 
+    {
+        if (!isHashtableSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature Hashtable");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            HashtableStringKeyCollections pi = new HashtableStringKeyCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Hashtable map = new Hashtable();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+            pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Hashtable map = new Hashtable();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue){
+        int i, j;
+
+        HashtableStringKeyCollections pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            Hashtable compareWith = new Hashtable();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            
+            for (j = 0; j< keys.size(); j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            Hashtable val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED, 
+                     "Incorrect value for " + HashtableStringKeyCollections.fieldSpecs[i]);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.HashtableStringValueCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type Hashtable, varying key type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-25.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the Hashtable optional feature is supported, then JDO implementation must
+support fields of the mutable object class <code>Hashtable</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestHashtableStringValueCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-25 (TestHashtableStringValueCollections) 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(TestHashtableStringValueCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (!isHashtableSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature Hashtable");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            HashtableStringValueCollections pi = new HashtableStringValueCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Hashtable map = new Hashtable();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+            pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Hashtable map = new Hashtable();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i, j;
+
+        HashtableStringValueCollections pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            Hashtable compareWith = new Hashtable();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            
+            for (j = 0; j< keys.size(); j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            Hashtable val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + HashtableStringValueCollections.fieldSpecs[i]);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.LinkedListCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type LinkedList
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-26.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the LinkedList optional feature is supported, then JDO implementation
+must support fields of the mutable object class <code>LinkedList</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestLinkedListCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-26 (TestLinkedListCollections) 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(TestLinkedListCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) 
+    {
+        if (!isLinkedListSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature LinkedList");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            LinkedListCollections pi = new LinkedListCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
+                pi.set( i, new LinkedList((Collection)firstValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            checkValues(oid, firstValue); // check if persistent fields have values set
+            pi = (LinkedListCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
+                pi.set( i, new LinkedList((Collection)secondValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (LinkedListCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i;
+
+        LinkedListCollections pi = (LinkedListCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
+            LinkedList compareWith = new LinkedList((Collection)startValue.get(valueType));
+
+            LinkedList val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + LinkedListCollections.fieldSpecs[i]);
+            }
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.ListCollections;
+import org.apache.jdo.tck.transactions.Commit;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type List
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-36.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the List optional feature is supported, then JDO implementations must
+support fields of the interface type <code>List</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestListCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-36 (Commit) 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(Commit.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (!isListSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature List");
+            return;
+        }
+
+        if (!isLinkedListSupported() && !isArrayListSupported()) {
+            fail(ASSERTION_FAILED,
+                 "JDO Implementation supports List, but neither ArrayList nor LinkedList.");
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            ListCollections pi = new ListCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
+                pi.set( i, new LinkedList((Collection)firstValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            checkValues(oid, firstValue); // check if persistent fields have values set
+            pi = (ListCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values
+            for( i = 0; i < n; ++i){
+                String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
+                pi.set( i, new LinkedList((Collection)secondValue.get(valueType)));
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            checkValues(oid, secondValue);
+            pi = (ListCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i;
+
+        ListCollections pi = (ListCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+        for( i = 0; i < n; ++i){
+            String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
+            List compareWith = new LinkedList((Collection)startValue.get(valueType));
+
+            List val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + ListCollections.fieldSpecs[i]);
+            }
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.MapStringKeyCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type Map, varying value type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-35.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the Map optional feature is supported, then JDO implementations
+must support fields of the interface type <code>Map</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+public class TestMapStringKeyCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-35 (TestMapStringKeyCollections) 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(TestMapStringKeyCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (!isMapSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature Map");
+            return;
+        }
+        if (!isHashMapSupported() && !isTreeMapSupported()) {
+            fail(ASSERTION_FAILED,
+                 "JDO Implementation supports Map, but neither HashMap nor TreeMap.");
+        }
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue =
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue =
+                new SecondSetOfTestValuesForCollection();
+
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            MapStringKeyCollections pi = new MapStringKeyCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Map map = new HashMap();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+            pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Map map = new HashMap();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i, j;
+
+        MapStringKeyCollections pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            Map compareWith = new HashMap();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            int sz = keys.size();
+            for (j = 0; j < sz; j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            Map val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + MapStringKeyCollections.fieldSpecs[i]);
+            }
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.models.fieldtypes;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.fieldtypes.MapStringValueCollections;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Support of field type Map, varying key type
+ *<BR>
+ *<B>Keywords:</B> model
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.3-35.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the Map optional feature is supported, then JDO implementations
+must support fields of the interface type <code>Map</code>,
+supporting them as Second Class Objects or First Class Objects.
+ */
+
+
+public class TestMapStringValueCollections extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.3-35 (TestMapStringValueCollections) 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(TestMapStringValueCollections.class);
+    }   
+
+    /** */
+    public void test() {
+        pm = getPM();
+         
+        runTest(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (!isMapSupported()) {
+            if (debug)
+                logger.debug("JDO Implementation does not support the optional feature Map");
+            return;
+        }
+        if (!isHashMapSupported() && !isTreeMapSupported()) {
+            fail(ASSERTION_FAILED,
+                 "JDO Implementation supports Map, but neither HashMap nor TreeMap.");
+        }
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            int i, j, n;
+            FirstSetOfTestValuesForCollection firstValue = 
+                new FirstSetOfTestValuesForCollection();
+            SecondSetOfTestValuesForCollection secondValue = 
+                new SecondSetOfTestValuesForCollection();
+
+            int ret = 0;
+            // turn on datastore transactions
+            tx.setOptimistic(false);
+            tx.begin();
+            MapStringValueCollections pi = new MapStringValueCollections();
+            pi.identifier = 1;
+            pm.makePersistent(pi);
+            Object oid = pm.getObjectId(pi);
+            n = pi.getLength();
+            // Provide initial set of values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    MapStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Map map = new HashMap();
+                Vector keys = (Vector) firstValue.get(fieldType);
+                Vector values = (Vector) secondValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+
+                pi.set(i, map);
+            }
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+
+            Hashtable firstSet = new Hashtable();
+            firstSet.put("keys", firstValue);
+            firstSet.put("values", secondValue);
+
+            checkValues(oid, firstSet); // check if persistent fields have values set
+            pi = (MapStringValueCollections) pm.getObjectById(oid, true);
+
+            // Provide new set of values     -- reverse the keys and values
+            for(i = 0; i < n; ++i){
+                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    MapStringValueCollections.fieldSpecs[i]);
+                String fieldType = (String)fieldSpecs.get(0);
+                String valueType = (String)fieldSpecs.get(1);
+                Map map = new HashMap();
+                Vector keys = (Vector) secondValue.get(fieldType);
+                Vector values = (Vector) firstValue.get(valueType);
+
+                for (j = 0; j< keys.size(); j++) {
+                    map.put(keys.get(j), values.get(j));
+                }
+                pi.set(i, map);
+            }
+
+            tx.commit();
+            // cache will be flushed
+            pi = null;
+            System.gc();
+
+            tx.begin();
+            // check new values
+            Hashtable secondSet = new Hashtable();
+            secondSet.put("keys", secondValue);
+            secondSet.put("values", firstValue);
+
+            checkValues(oid, secondSet);
+            pi = (MapStringValueCollections) pm.getObjectById(oid, true);
+            pm.deletePersistent(pi);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    private void checkValues(Object oid, Hashtable startValue)
+    {
+        int i, j;
+
+        MapStringValueCollections pi = 
+            (MapStringValueCollections) pm.getObjectById(oid, true);
+        int n = pi.getLength();
+
+        Hashtable keySet = (Hashtable) startValue.get("keys");
+        Hashtable valueSet = (Hashtable) startValue.get("values");
+
+        for( i = 0; i < n; ++i){
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                MapStringValueCollections.fieldSpecs[i]);
+            String fieldType = (String)fieldSpecs.get(0);
+            String valueType = (String)fieldSpecs.get(1);
+            Map compareWith = new HashMap();
+
+            Vector keys = (Vector) keySet.get(fieldType);
+            Vector values = (Vector) valueSet.get(valueType);
+            int sz = keys.size();
+            for (j = 0; j < sz; j++) {
+                compareWith.put(keys.get(j), values.get(j));
+            }
+
+            Map val = pi.get(i);
+
+            if(!val.equals(compareWith)){
+                fail(ASSERTION_FAILED,
+                     "Incorrect value for " + MapStringValueCollections.fieldSpecs[i]);
+            }
+        }
+    }
+
+}



Mime
View raw message