svn commit: r160090 [3/63] - in incubator/jdo/trunk: ./ tck20/ tck20/assertions/ tck20/iut_jars/ tck20/test/ tck20/test/conf/ tck20/test/java/ tck20/test/java/org/ tck20/test/java/org/apache/ tck20/test/java/org/apache/jdo/ tck20/test/java/org/apache/jdo/tck/ tck20/test/java/org/apache/jdo/tck/api/ tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/api/jdohelper/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/close/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/extent/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/flags/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/getobject/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/ tck20/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ tck20/test/java/org/apache/jdo/tck/enhancement/ tck20/test/java/org/apache/jdo/tck/extents/ tck20/test/java/org/apache/jdo/tck/lifecycle/ tck20/test/java/org/apache/jdo/tck/lifecycle/nontransactional/ tck20/test/java/org/apache/jdo/tck/models/ tck20/test/java/org/apache/jdo/tck/models/embedded/ tck20/test/java/org/apache/jdo/tck/models/fieldtypes/ tck20/test/java/org/apache/jdo/tck/models/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/ tck20/test/java/org/apache/jdo/tck/pc/company/ tck20/test/java/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/java/org/apache/jdo/tck/pc/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/pc/lifecycle/ tck20/test/java/org/apache/jdo/tck/pc/mylib/ tck20/test/java/org/apache/jdo/tck/query/ tck20/test/java/org/apache/jdo/tck/query/operators/ tck20/test/java/org/apache/jdo/tck/transactions/ tck20/test/java/org/apache/jdo/tck/util/ tck20/test/jdo/ tck20/test/jdo/applicationidentity/ tck20/test/jdo/applicationidentity/org/ tck20/test/jdo/applicationidentity/org/apache/ tck20/test/jdo/applicationidentity/org/apache/jdo/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/jdo/datastoreidentity/ tck20/test/jdo/datastoreidentity/org/ tck20/test/jdo/datastoreidentity/org/apache/ tck20/test/jdo/datastoreidentity/org/apache/jdo/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/ tck20/test/orm/applicationidentity/ tck20/test/orm/applicationidentity/org/ tck20/test/orm/applicationidentity/org/apache/ tck20/test/orm/applicationidentity/org/apache/jdo/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/datastoreidentity/ tck20/test/orm/datastoreidentity/org/ tck20/test/orm/datastoreidentity/org/apache/ tck20/test/orm/datastoreidentity/org/apache/jdo/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/sql/ tck20/test/sql/derby/

4 Apr 2005 19:43:53 -0000

Added: incubator/jdo/trunk/tck20/test/conf/enhancement-test.properties
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/enhancement-test.properties?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/enhancement-test.properties (added)
+++ incubator/jdo/trunk/tck20/test/conf/enhancement-test.properties Mon Apr  4 
12:41:23 2005
@@ -0,0 +1,19 @@
+#
+# 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.
+
+org.apache.jdo.tck.pc.inheritance=AllPersist,AllPersist2,AllPersist3,AllPersist4,FieldSameName,FieldSameName2,FieldSameName3,FieldSameName4,TopNonPersistB,TopNonPersistE,TopNonPersistF,TopNonPersistH,TopPersist,TopPersistE,TopPersistF,TopPersistH
+org.apache.jdo.tck.pc.company=Address,Company,DentalInsurance,Department,Employee,FullTimeEmployee,Insurance,MedicalInsurance,PartTimeEmployee,Person,Project
+org.apache.jdo.tck.pc.instancecallbacks=InstanceCallbackClass,InstanceCallbackNonPersistFdsClass
+

Propchange: incubator/jdo/trunk/tck20/test/conf/enhancement-test.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jdo/trunk/tck20/test/conf/jdori.properties
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/jdori.properties?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/jdori.properties (added)
+++ incubator/jdo/trunk/tck20/test/conf/jdori.properties Mon Apr  4 12:41:23 
2005
@@ -0,0 +1,29 @@
+# -------------------------------------------------------------------
+# P R O J E C T  P R O P E R T I E S
+# -------------------------------------------------------------------
+#
+# PMF Properties
+javax.jdo.PersistenceManagerFactoryClass=org.jpox.PersistenceManagerFactoryImpl
+org.apache.jdo.ConnectionCreate=true
+javax.jdo.option.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
+javax.jdo.option.ConnectionURL=jdbc:derby:jdotckdb
+javax.jdo.option.ConnectionUserName=tckuser
+javax.jdo.option.ConnectionPassword=tckuser
+javax.jdo.option.Optimistic=false
+javax.jdo.option.RetainValues=false
+javax.jdo.option.RestoreValues=false
+javax.jdo.option.Mapping=derby
+
+# Allow selection of JDBC jar - see below
+#maven.jar.override=on
+
+# User Interface
+#maven.xdoc.date=left
+#maven.xdoc.date.format=dd MMMM yyyy HH:mm
+#maven.xdoc.version=${pom.currentVersion}
+
+log4j.configuration=file:${basedir}/test/conf/logging.properties
+maven.jpox.verbose=true
+
+org.jpox.validateTables=true
+org.jpox.validateConstraints=true

Propchange: incubator/jdo/trunk/tck20/test/conf/jdori.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jdo/trunk/tck20/test/conf/logging.properties
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/logging.properties?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/logging.properties (added)
+++ incubator/jdo/trunk/tck20/test/conf/logging.properties Mon Apr  4 12:41:23 
2005
@@ -0,0 +1,66 @@
+#
+# 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.
+
+#
+# This is a sample properties file to configure standard JDK 1.4 logging for 
+# the JDO TCK test cases. Below you find an entry for each of the JDO TCK
+# logger instances. Please uncomment the line and adapt the log level to your
+# needs, in case to want to enable a particular logger.
+#
+# The following describes the mapping between the log level of JDK 1.4 logging
+# and apache commns logging:
+#   JDK 1.4        Apache 
+#   FINEST         trace 
+#   FINE, FINER    debug 
+#   INFO, CONFIG   info
+#   WARNING        warn
+#   SEVERE         error, fatal
+#
+
+######################
+# JDO TCK test cases
+######################
+
+#org.apache.jdo.tck.level = FINE
+
+######################
+# JDK 1.4 logging properties
+######################
+
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = FINEST
+
+
+######################
+# JPOX logging properties
+######################
+
+# Define the destination and format of our logging
+log4j.appender.A1=org.apache.log4j.FileAppender
+log4j.appender.A1.File=jpox.log
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - 
%m%n
+
+# JPOX Categories
+log4j.category.JPOX.JDO=INFO, A1
+log4j.category.JPOX.Cache=INFO, A1
+log4j.category.JPOX.MetaData=INFO, A1
+log4j.category.JPOX.General=INFO, A1
+log4j.category.JPOX.Utility=INFO, A1
+log4j.category.JPOX.Transaction=INFO, A1
+log4j.category.JPOX.RDBMS=DEBUG, A1
+
+log4j.category.JPOX.Enhancer=INFO, A1
+log4j.category.JPOX.SchemaTool=INFO, A1

Propchange: incubator/jdo/trunk/tck20/test/conf/logging.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jdo/trunk/tck20/test/conf/simplelog.properties
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/simplelog.properties?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/simplelog.properties (added)
+++ incubator/jdo/trunk/tck20/test/conf/simplelog.properties Mon Apr  4 
12:41:23 2005
@@ -0,0 +1,35 @@
+#
+# 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.
+
+#
+# This is a sample properties file to configure apache commons logging 
SimpleLog
+# implementation for the JDO TCK test cases. Below you find an entry for each 
of
+# the JDO TCK logger instances. Please uncomment the line and adapt the log 
+# level to your needs, in case to want to enable a particular logger.
+#
+
+######################
+# JDO TCK test cases
+######################
+
+#org.apache.commons.logging.simplelog.log.org.apache.jdo.tck = debug
+
+######################
+# default logging level
+######################
+
+org.apache.commons.logging.simplelog.defaultlog = error
+
+

Propchange: incubator/jdo/trunk/tck20/test/conf/simplelog.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java Mon 
Apr  4 12:41:23 2005
@@ -0,0 +1,529 @@
+/*
+ * 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;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.Properties;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class JDO_Test extends TestCase {
+    public static final int TRANSIENT                   = 0;
+    public static final int PERSISTENT_NEW              = 1;
+    public static final int PERSISTENT_CLEAN            = 2;
+    public static final int PERSISTENT_DIRTY            = 3;
+    public static final int HOLLOW                      = 4;
+    public static final int TRANSIENT_CLEAN             = 5;
+    public static final int TRANSIENT_DIRTY             = 6;
+    public static final int PERSISTENT_NEW_DELETED      = 7;
+    public static final int PERSISTENT_DELETED          = 8;
+    public static final int PERSISTENT_NONTRANSACTIONAL = 9;
+    public static final int NUM_STATES = 10;
+    public static final int ILLEGAL_STATE = 10;
+
+    public static final String[] states = {
+        "transient",
+        "persistent-new",
+        "persistent-clean",
+        "persistent-dirty",
+        "hollow",
+        "transient-clean",
+        "transient-dirty",
+        "persistent-new-deleted",
+        "persistent-deleted",
+        "persistent-nontransactional",
+        "illegal"
+    };
+    private static final int IS_PERSISTENT       = 0;
+    private static final int IS_TRANSACTIONAL    = 1;
+    private static final int IS_DIRTY            = 2;
+    private static final int IS_NEW              = 3;
+    private static final int IS_DELETED          = 4;
+    private static final int NUM_STATUSES        = 5;
+
+    /*
+     * This table indicates the values returned by the status interrogation
+     * methods for each state. This is used to determine the current lifecycle
+     * state of an object.
+     */
+    private static final boolean state_statuses[][] = {
+        // IS_PERSISTENT IS_TRANSACTIONAL    IS_DIRTY      IS_NEW      
IS_DELETED
+        // transient
+        {   false,          false,              false,      false,      false},
+
+        // persistent-new
+        {   true,           true,               true,       true,       false},
+
+        // persistent-clean
+        {   true,           true,               false,      false,      false},
+
+        // persistent-dirty
+        {   true,           true,               true,       false,      false},
+
+        // hollow
+        {   true,           false,              false,      false,      false},
+
+        // transient-clean
+        {   false,          true,               false,      false,      false},
+
+        // transient-dirty
+        {   false,          true,               true,       false,      false},
+
+        // persistent-new-deleted
+        {   true,           true,               true,       true,       true},
+
+        // persistent-deleted
+        {   true,           true,               true,       false,      true},
+
+        // persistent-nontransactional
+        {   true,           false,              false,      false,      false}
+    };
+  
+    /** Name of the file contaninig the properties for the PMF. */
+    protected static String PMFProperties;
+
+    /** The Properties object for the PersistenceManagerFactory. */
+    protected static Properties PMFPropertiesObject;
+
+    /** The PersistenceManagerFactory. */
+    protected PersistenceManagerFactory pmf;
+    
+    /** The PersistenceManager. */
+    protected PersistenceManager pm;
+    
+    // Flag indicating successful test run
+    protected boolean testSucceeded;
+
+    /** Logger */
+    protected Log logger = 
+        LogFactory.getFactory().getInstance("org.apache.jdo.tck");
+
+    /** true if debug logging in enabled. */
+    protected boolean debug = logger.isDebugEnabled();
+    
+    /** */
+    protected JDO_Test() {
+        PMFProperties = System.getProperty("PMFProperties");
+    }
+
+    /** */
+    protected void setUp() throws Exception {
+        pmf = getPMF();
+    }
+    
+    /**
+     * Runs the bare test sequence.
+     * @exception Throwable if any exception is thrown
+     */
+    public void runBare() throws Throwable {
+        setUp();
+        try {
+            testSucceeded = false;
+            runTest();
+            testSucceeded = true;
+        }
+        finally {
+            tearDown();
+        }
+    }
+
+    /** */
+    protected void tearDown() {
+        try {
+            cleanup();
+            closePMF();
+        }
+        catch (Throwable ex) {
+            if (debug) ex.printStackTrace();
+            if (testSucceeded) {
+                // runTest succeeded, but closePMF throws exception =>
+                // failure
+                fail("Exception during tearDown: " + ex);
+            }
+            else {
+                // runTest failed and closePMF throws exception =>
+                // just print the closePMF exception, otherwise the
+                // closePMF exception would swallow the test case failure
+                if (debug) logger.debug("Exception during tearDown: " + ex);
+            }
+        }
+    }
+
+    /**
+     * Get the <code>PersistenceManagerFactory</code> instance 
+     * for the implementation under test.
+     */
+    protected PersistenceManagerFactory getPMF()
+    {
+        if (pmf == null) {
+            PMFPropertiesObject = loadProperties(PMFProperties); // will exit 
here if no properties
+            pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
+        }
+        return pmf;
+    }
+
+    /**
+     * Get the <code>PersistenceManager</code> instance 
+     * for the implementation under test.
+     */
+    protected PersistenceManager getPM() {
+        if (pm == null) {
+            pm = getPMF().getPersistenceManager();
+        }
+        return pm;
+    }
+
+    
+    /** 
+     * This method cleans up the environment: closes the
+     * <code>PersistenceManager</code>.  This  should avoid leaving
+     * multiple PersistenceManager instances around, in case the
+     * PersistenceManagerFactory performs PersistenceManager pooling.  
+     */
+    protected void cleanup() 
+    {
+        cleanupPM(pm);
+        pm = null;
+    }
+
+    /** 
+     * This method cleans up the specified 
+     * <code>PersistenceManager</code>. If the pm still has an open
+     * transaction, it will be rolled back, before closing the pm.
+     */
+    protected void cleanupPM(PersistenceManager pm) 
+    {
+        if ((pm != null) && !pm.isClosed()) {
+            if (pm.currentTransaction().isActive()) {
+                pm.currentTransaction().rollback();
+            }
+            pm.close();
+        }
+    }
+
+    /** Closes the pmf stored in this instance. */
+    protected void closePMF()
+    {
+        if (pmf != null) {
+            pmf.close();
+            pmf = null;
+        }
+    }
+
+    /**
+     * This method load Properties from a given file.
+     */
+    protected Properties loadProperties(String fileName)
+    {
+        if (fileName == null) {
+            fileName = System.getProperty("user.home") + 
"/.jdo/PMFProperties.properties";
+        }
+        Properties props = new Properties();
+        InputStream propStream = null;
+        try {
+            propStream = new FileInputStream(fileName);
+        }
+        catch (IOException ex) {
+            System.out.println("Could not open properties file \"" + fileName 
+ "\"");
+            System.out.println("Please specify a system property PMFProperties 
" + 
+                               "with the PMF properties file name as value " + 
+                               "(defaults to 
{user.home}/.jdo/PMFProperties.properties)");
+            System.exit(1);
+        }
+        try {
+            props.load(propStream);
+        } 
+        catch (IOException ex) {
+            System.out.println("Error loading properties file \"" + fileName + 
"\"");
+            ex.printStackTrace();
+            System.exit(1);
+        }
+        return props;
+    }
+
+    /** 
+     * Prints the specified msg (if debug is true), before it aborts the
+     * test case.
+     */
+    public void fail(String assertionFailure, String msg) {
+        if (debug) logger.debug(msg);
+        fail(assertionFailure + "\n" + msg);
+    }
+
+    // Helper methods to check for supported options
+    
+    /** 
+     * Prints a message (if debug is true) saying the test with the
+     * specified name is not executed, because the JDO implementation under
+     * test does not support the specified optional feature. 
+     * @param testName the name of the test method that is skipped.
+     * @param optionalFeature the name of the option not supported by the
+     * JDO implementation under tets.
+     */
+    protected void printUnsupportedOptionalFeatureNotTested(
+        String testName, String optionalFeature) {
+        if (debug) {
+            logger.debug(
+                "Test " + testName + 
+                " was not run, because optional feature " + optionalFeature + 
+                " is not supported by the JDO implementation under test");
+        }
+    }
+
+    /** Reports whether TransientTransactional is supported. */
+    public boolean isTransientTransactionalSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.TransientTransactional");
+    }
+    
+    /** Reports whether NontransactionalRead is supported. */
+    public boolean isNontransactionalReadSupported(){
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.NontransactionalRead");
+    }
+    
+    /** Reports whether NontransactionalWrite is supported. */
+    public boolean isNontransactionalWriteSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.NontransactionalWrite");
+    }
+
+    /** Reports whether RetainValues is supported. */
+    public boolean isRetainValuesSupported()
+    {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.RetainValues");
+    }
+
+    /** Reports whether Optimistic is supported. */
+    public boolean isOptimisticSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.Optimistic");
+    }
+
+    /** Reports whether Application Identity is supported. */
+    public boolean isApplicationIdentitySupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.ApplicationIdentity");
+    }
+
+    /** Reports whether Datastore Identity is supported. */
+    public boolean isDatastoreIdentitySupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.DatastoreIdentity");
+    }
+
+    /** Reports whether Non-Durable Identity is supported. */
+    public boolean isNonDurableIdentitySupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.NonDatastoreIdentity");
+    }
+
+    /** Reports whether an <code>ArrayList</code> collection is supported. */
+    public boolean isArrayListSupported() {        
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.ArrayList");
+    }
+
+    /** Reports whether a <code>HashMap</code> collection is supported. */
+    public boolean isHashMapSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.HashMap");
+    }
+
+    /** Reports whether a <code>Hashtable</code> collection is supported. */
+    public boolean isHashtableSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.Hashtable");
+    }
+
+    /** Reports whether a <code>LinkedList</code> collection is supported. */
+    public boolean isLinkedListSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.LinkedList");
+    }
+
+    /** Reports whether a <code>TreeMap</code> collection is supported. */
+    public boolean isTreeMapSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.TreeMap");
+    }
+
+    /** Reports whether a <code>TreeSet</code> collection is supported. */
+    public boolean isTreeSetSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.TreeSet");
+    }
+
+    /** Reports whether a <code>Vector</code> collection is supported. */
+    public boolean isVectorSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.Vector");
+    }
+
+    /** Reports whether a <code>Map</code> collection is supported. */
+    public boolean isMapSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.Map");
+    }
+
+    /** Reports whether a <code>List</code> collection is supported. */
+    public boolean isListSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.List");
+    }
+
+    /** Reports whether arrays are supported. */
+    public boolean isArraySupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.Array");
+    }
+
+    /** Reports whether a null collection is supported. */
+    public boolean isNullCollectionSupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.NullCollection");
+    }
+
+    /** Reports whether Changing Application Identity is supported. */
+    public boolean isChangeApplicationIdentitySupported() {
+        return getPMF().supportedOptions().contains(
+            "javax.jdo.option.ChangeApplicationIdentity");
+    }
+
+    /**
+     * This utility method returns a <code>String</code> that indicates the
+     * current state of an instance. 
+     * @param o The object.
+     * @return The current state of the instance, by using the
+     * <code>JDOHelper</code> state interrogation methods.
+     */
+    public static String getStateOfInstance(Object o)
+    {
+        boolean existingEntries = false;
+        StringBuffer buff = new StringBuffer("{");
+        if( JDOHelper.isPersistent(o) ){
+            buff.append("persistent");
+            existingEntries = true;
+        }
+        if( JDOHelper.isTransactional(o) ){
+            if( existingEntries ) buff.append(", ");
+            buff.append("transactional");
+            existingEntries = true;
+        }
+        if( JDOHelper.isDirty(o) ){
+            if( existingEntries ) buff.append(", ");
+            buff.append("dirty");
+            existingEntries = true;
+        }
+        if( JDOHelper.isNew(o) ){
+            if( existingEntries ) buff.append(", ");
+            buff.append("new");
+            existingEntries = true;
+        }
+        if( JDOHelper.isDeleted(o) ){
+            if( existingEntries ) buff.append(", ");
+            buff.append("deleted");
+        }
+        buff.append("}");
+        return buff.toString();
+    }
+    
+    /**
+     * This method will return the current lifecycle state of an instance.
+     */
+    public static int currentState(Object o)
+    {
+        boolean[] status = new boolean[5];
+        status[IS_PERSISTENT]       = JDOHelper.isPersistent(o);
+        status[IS_TRANSACTIONAL]    = JDOHelper.isTransactional(o);
+        status[IS_DIRTY]            = JDOHelper.isDirty(o);
+        status[IS_NEW]              = JDOHelper.isNew(o);
+        status[IS_DELETED]          = JDOHelper.isDeleted(o);
+        int i, j;
+    outerloop:
+        for( i = 0; i < NUM_STATES; ++i ){
+            for( j = 0; j < NUM_STATUSES; ++j ){
+                if( status[j] != state_statuses[i][j] )
+                    continue outerloop;
+            }
+            return i;
+        }
+        return NUM_STATES;
+    }
+
+    /** This method mangles an object by changing all its public fields
+     */
+    protected void mangleObject (Object oid) 
+        throws Exception {
+        Class oidClass = oid.getClass();
+        Field[] fields = oidClass.getFields();
+        for (int i = 0; i < fields.length; ++i) {
+            Field field = fields[i];
+            field.setAccessible(true);
+            if (debug) 
+                logger.debug("field" + i + " has name: " + field.getName() +
+                             " type: " + field.getType());
+            Class fieldType = field.getType();
+            if (fieldType == long.class) {
+                field.setLong(oid, 10000L);
+            }
+            if (fieldType == int.class) {
+                field.setInt(oid, 10000);
+            }
+            if (fieldType == short.class) {
+                field.setShort(oid, (short)10000);
+            }
+            if (fieldType == byte.class) {
+                field.setByte(oid, (byte)100);
+            }
+            if (fieldType == char.class) {
+                field.setChar(oid, '0');
+            }
+            if (fieldType == String.class) {
+                field.set(oid, "This is certainly a challenge");
+            }
+            if (fieldType == Integer.class) {
+                field.set(oid, new Integer(10000));
+            }
+            if (fieldType == Long.class) {
+                field.set(oid, new Long(10000L));
+            }
+            if (fieldType == Short.class) {
+                field.set(oid, new Short((short)10000));
+            }
+            if (fieldType == Byte.class) {
+                field.set(oid, new Byte((byte)100));
+            }
+            if (fieldType == Character.class) {
+                field.set(oid, new Character('0'));
+            }
+        }
+    }
+
+}

Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,107 @@
+/*
+ * 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.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Access Other Instances In Prestore Method
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.2-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+The context in which a call is made to <code>jdoPreStore()</code> allows access
+to the <code>PersistenceManager</code> and other persistent JDO instances.
+
+ */
+
+
+/*
+ *   Within jdoPreStore(), locate the PersistenceManager 
(JDOHelper.getPersistenceManager()) and use it
+ *   to call currentTransaction().  Use the Transaction to call isActive() and 
verify active.  These operations
+ *   are done to help verify that we had access to a usable PersistenceManager.
+ *
+ *   Create objects.  
+ *   Within jdoPreStore(), capture information about objects referenced.
+ *   This includes a String, Date and Collection attribute.
+ *   After commit() verify jdoPreStore() called and found what expected.
+ */
+
+public class AccessOtherInstancesInPrestore extends TestParts {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.2-3 (AccessOtherInstancesInPrestore) 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(AccessOtherInstancesInPrestore.class);
+    }
+
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction();
+        
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackClass.removeAllInstances(pm); // always start fresh 
with no instances
+        t.commit();
+
+        InstanceCallbackClass.performPreStoreTests = true;
+        t.begin();
+        //  Create primaryObj which has a collection (children) of two objects 
and references another (nextObj).
+        //  None of the other objects have a non-empty collection.  The also 
all have nextObj set to null.
+        Date createTime = new Date();
+        InstanceCallbackClass secondaryObj = new 
InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
+        InstanceCallbackClass primaryObj = new 
InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', 
secondaryObj);
+        InstanceCallbackClass childA = new InstanceCallbackClass("childA", 
createTime, 3, 3.0, (short)-2, '3', null);
+        InstanceCallbackClass childB = new InstanceCallbackClass("childB", 
createTime, 4, 4.0, (short)-3, '4', null);
+        pm.makePersistent(primaryObj);
+        primaryObj.addChild(childA);
+        primaryObj.addChild(childB);
+        t.commit();
+
+        // check that jdoPreStore provides access to instances for primaryObj
+        checkInstances(ASSERTION_FAILED, "jdoStore instance access:  ", 1, 
"secondaryObj", 2, 7);
+        // check that jdoPreStore provides access to PersistenceManager for 
primaryObj
+        checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager 
access:  ", 1, true);
+        
+        // check that jdoPreStore provides access to instances for secondaryObj
+        checkInstances(ASSERTION_FAILED, "jdoStore instance access:  ", 2, 
null, 0, 0);
+        // check that jdoPreStore provides access to PersistenceManager for 
secondaryObj
+        checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager 
access:  ", 2, true);
+        
+        // There is no need to check childA or childB.  They are no different 
than secondaryObj.
+        
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.api.instancecallbacks;
+
+import java.util.Date;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Accessing Fields In Predelete
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.4-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ Access to field values within a call to <code>jdoPreDelete()</code>
+ of a class implementing <code>InstanceCallbacks</code> are valid.
+
+ */
+
+/*
+ *   Define a PersistenceCapable class containing some primative types, 
+ *      a Date attribute, a String attribute,
+ *      one reference to an object of the same class and one
+ *      Set collection attribute containing two instances of objects of this 
class.
+ *
+ *   Create an object of this class (along with the referenced object and two 
members in the Set) and commit.
+ *   Delete the object.
+ *   Within jdoPreDelete(), capture the values of attribues and delete the 
referenced object
+ *       and one of the two Set members.
+ *
+ *  In the next transaction, verify the data captured from the attriubtes was 
what was expected and
+ *  that all the objects that should have been deleted have been deleted and 
the
+ *  Set member that was not deleted is still present.
+ *  Also verify that jdoPreDelete() is called on each of these objects deleted 
within the first jdoPreDelete().
+ */
+
+public class AccessingFieldsInPredelete extends TestParts {
+    
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.4-2 (AccessingFieldsInPredelete) 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(AccessingFieldsInPredelete.class);
+    }
+    
+    /** */
+    public void test() throws Exception {
+        pm = getPM();
+        Transaction t = pm.currentTransaction();
+        
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackClass.removeAllInstances(pm); // always start fresh 
with no instances
+        t.commit();
+
+        InstanceCallbackClass.performPreDeleteTests = true;
+        t.begin();
+        Date createTime = new Date();
+        InstanceCallbackClass secondaryObj = new 
InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
+        InstanceCallbackClass primaryObj = new 
InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', 
secondaryObj);
+        InstanceCallbackClass childA = new InstanceCallbackClass("childA", 
createTime, 3, 3.0, (short)-2, '3', null);
+        InstanceCallbackClass childB = new InstanceCallbackClass("childB", 
createTime, 4, 4.0, (short)-3, '4', null);
+        pm.makePersistent(primaryObj);
+        pm.makePersistent(secondaryObj);
+        pm.makePersistent(childA);
+        pm.makePersistent(childB);
+        primaryObj.addChild(childA);
+        primaryObj.addChild(childB);
+        Object secondaryObjId = pm.getObjectId(secondaryObj);
+        Object primaryObjId = pm.getObjectId(primaryObj);
+        Object childAId = pm.getObjectId(childA);
+        Object childBId = pm.getObjectId(childB);
+        t.commit();
+        
+        t.begin();
+        primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, 
true);
+        pm.deletePersistent(primaryObj);
+        t.commit();
+        
+        t.begin();
+        try {
+            primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, 
true);
+            fail(ASSERTION_FAILED, "primaryObj deleted but getObjectById() on 
its Id succeeded.");
+        } catch (JDOUserException e) {
+            // expected one of these exceptions
+        } catch (JDODataStoreException e) {
+            // expected one of these exceptions
+        }
+        
+        // check that jdoPreDelete() provided proper access to the attributes 
in primaryObj
+        checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access:  ", 
1, "primaryObj", createTime, 1.0, (short)3, '1');
+        checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access:  ", 1, 
"secondaryObj", 2, 7);
+        checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager 
access:  ", 1, true);
+        
+        // check that secondaryObj had jdoPreDelete() called on it and 
provided proper access to its attributes.
+        checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access:  ", 
2,  "secondaryObj", createTime, 2.0, (short)-1, '2');
+        checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access:  ", 2, 
null, 0, 0);
+        checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager 
access:  ", 2, true);
+
+        // check that secondaryObj was deleted.
+        try {
+            secondaryObj = 
(InstanceCallbackClass)pm.getObjectById(secondaryObjId, true);
+            fail(ASSERTION_FAILED, "secondaryObj should have been deleted but 
getObjectById() on its Id succeeded.");
+        } catch (JDOUserException e) {
+            // expected one of these exceptions
+        } catch (JDODataStoreException e) {
+            // expected one of these exceptions
+        }
+        
+        // check that first added member of Set had jdoPreDelete() called on 
it and provided proper access to its attributes.
+        checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access:  ", 
3, "childA", createTime, 3.0, (short)-2, '3');
+        checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access:  ", 3, 
null, 0, 0);
+        checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager 
access:  ", 3, true);
+        
+        // verify first added member of Set was actaully deleted.
+        try {
+            childA = (InstanceCallbackClass)pm.getObjectById(childAId, true);
+            fail(ASSERTION_FAILED, "First added member of Set 
primaryObj.children should have been deleted but getObjectById() on its Id 
succeeded.");
+        } catch (JDOUserException e) {
+            // expected one of these exceptions
+        } catch (JDODataStoreException e) {
+            // expected one of these exceptions
+        }
+        
+        // check that the second added member of Set did not have 
jdoPreDelete() called on it and it was not deleted.
+        if(InstanceCallbackClass.processedIndex[4] == true) {
+            fail(ASSERTION_FAILED, "jdoPreDelete() called on childB--it was 
not deleted.");
+        }
+        
+        try {
+            childB = (InstanceCallbackClass)pm.getObjectById(childBId, true);
+            if( childB == null ){
+                if (debug) logger.debug("childB object is null");
+            } else {
+                if( childB.name == null )
+                    if (debug) logger.debug("childB.name is null");
+            }
+            if(!childB.name.equals("childB")) {
+                fail(ASSERTION_FAILED, "childB.name should be \"childB\".  
Instead its value is \"" + childB.name + "\".");                
+            }
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED, "Second added member of Set 
primaryObj.children should exist but getObjectById() got JDOUserException " + 
e);
+        } catch (JDODataStoreException e) {
+            fail(ASSERTION_FAILED, "Second added member of Set 
primaryObj.children should exist but getObjectById() got JDODataStoreException 
" + e);
+        }
+        t.rollback();
+        pm.close(); 
+        pm = null;
+    }
+}
+

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,148 @@
+/*
+ * 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.api.instancecallbacks;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import 
org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling InstanceCallbacks Postload Method
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.1-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The <code>jdoPostLoad()</code> method of a class implementing
+<code>InstanceCallbacks</code> is called after the default fetch
+group values are loaded from the <code>StateManager</code> into the instance.
+
+ */
+
+
+/*
+ *  Create a persistent object and commit().
+ *
+ *  Retrieve object in the next transaction and verify its state is hollow.
+ *
+ *  Reference a persistent attribute and verify:
+ *     the call to jdoPostLoad() occurred just before this reference--and 
after the object was retrieved (via getObjectById()),
+ *     jdoPostLoad() was called exactly once and
+ *     once the attribute has been referenced, the state of the object is 
persistent-clean
+ *
+ *  Verify that the values of the persistent attributes available in 
jdoPostLoad() are the values actually in the object (the
+ *    values have already been restored be the time jdoPostLoad() is called).
+ */
+public class CallingJdoPostload extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.1-1 (CallingJdoPostload) 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(CallingJdoPostload.class);
+    }
+    
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction();
+
+        InstanceCallbackNonPersistFdsClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackNonPersistFdsClass.removeAllInstances(pm); // always 
start fresh with no instances
+        t.commit();
+
+        t.begin();
+        // create instance        
+        InstanceCallbackNonPersistFdsClass obj1 = new 
InstanceCallbackNonPersistFdsClass(2.2f, 13);
+        pm.makePersistent(obj1);
+        Object objPtr1 = pm.getObjectId (obj1);
+        obj1.setNonPersist(1, (char)2, 3.3, (short)4);
+        t.commit(); 
+
+        t.begin();
+        // set applicationStep before and after getObjectById() to be sure 
when jdoPostLoad() gets called.
+        InstanceCallbackNonPersistFdsClass.applicationStep = 
InstanceCallbackNonPersistFdsClass.beforeGetObjectById;
+        try {
+            obj1 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true);  // 
jdoPreLoad() called
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPostload:  Could not locate 
persistent object obj1 created in previous transaction " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPostload:  Could not locate 
persistent object obj1 created in previous transaction " + e);
+            return;
+        }
+        
+        int objectState = currentState(obj1);        
+        // expect state to be hollow or persistent-clean
+        if(objectState != HOLLOW && objectState != PERSISTENT_CLEAN) {
+            fail(ASSERTION_FAILED, "State of object was not hollow or 
persistent clean after accessed via getObjectById((), state is " + 
states[objectState]);
+        }
+        
+        InstanceCallbackNonPersistFdsClass.applicationStep = 
InstanceCallbackNonPersistFdsClass.afterGetObjectById;
+        int getIntValue = obj1.intValue;  // reference attribute in default 
fetch group        
+        objectState = currentState(obj1);
+        
+        // expect jdoPostLoad() was called
+        if(!InstanceCallbackNonPersistFdsClass.postloadCalled) {
+            fail(ASSERTION_FAILED, "jdoPostLoad() never called");
+        }
+        
+        // only check other information if jdoPostLoad() called
+        if(InstanceCallbackNonPersistFdsClass.postloadCalled) {
+            // expect jdoPostLoad() was called only once
+            if(InstanceCallbackNonPersistFdsClass.postloadCalledMultipleTimes) 
{
+                fail(ASSERTION_FAILED, "jdoPostLoad was called more than once 
for the same loaded object");
+            }
+
+            // verify the value of intValue was available in jdoPostLoad()
+            if(InstanceCallbackNonPersistFdsClass.savedIntValue != 
getIntValue) {
+                fail(ASSERTION_FAILED, 
+                     "intValue available in jdoPostLoad is incorrect.  It was 
" + 
+                     InstanceCallbackNonPersistFdsClass.savedIntValue +
+                     ", it should be " + getIntValue);
+            }
+
+            // verify the value of floatValue was available in jdoPostLoad()
+            if(InstanceCallbackNonPersistFdsClass.savedFloatValue != 
obj1.floatValue) {
+                fail(ASSERTION_FAILED, 
+                     "floatValue available in jdoPostLoad is incorrect.  It 
was " + 
+                     InstanceCallbackNonPersistFdsClass.savedFloatValue +
+                     ", it should be " + obj1.floatValue);
+            }
+        }
+        
+        t.rollback();
+        pm.close(); 
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,136 @@
+/*
+ * 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.api.instancecallbacks;
+
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling Jdo Preclear
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.3-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The <code>jdoPreClear()</code> method of a class implementing
+<code>InstanceCallbacks</code> is called before the values in the instance
+are cleared. (This happens during the state transition to hollow.)
+
+ */
+
+/*
+ *   Create a new object, reference an existing object and modify an existing 
object and then
+ *   perform a commit.
+ *
+ *   Check that each instance contains the values set into the persistent 
attributes prior to commit.
+ */
+
+public class CallingJdoPreclear extends TestParts {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.3-1 (CallingJdoPreclear) 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(CallingJdoPreclear.class);
+    }
+    
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction();
+        t.setRetainValues(false);  // instances transition to hollow after 
commit
+
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackClass.removeAllInstances(pm); // always start fresh 
with no instances
+        t.commit();
+        
+        t.begin();
+        Calendar cal = Calendar.getInstance();
+        cal.set(1999, 1, 15, 12, 0);
+        Date createTime = cal.getTime();
+        cal.set(2002, 1, 15, 12, 0);
+        Date laterDate = cal.getTime();
+        InstanceCallbackClass secondaryObj = new 
InstanceCallbackClass("secondaryObj", createTime, 2, 2.2, (short)-20, '2', 
null);
+        InstanceCallbackClass primaryObj = new 
InstanceCallbackClass("primaryObj", laterDate, 1, 1.1, (short)-10, '1', 
secondaryObj);
+        pm.makePersistent(primaryObj);
+        pm.makePersistent(secondaryObj);
+        Object secondaryObjId = pm.getObjectId(secondaryObj);
+        Object primaryObjId = pm.getObjectId(primaryObj);
+        t.commit();
+
+        InstanceCallbackClass.performPreClearTests = true;
+        t.begin();
+        try {
+            primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, 
true);
+            pm.retrieve(primaryObj); // load fields of primaryObj (make it 
persistent-clean)
+        
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED, "Failed to find primaryObj created in 
previous transaction.  Got JDOUserException " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            fail(ASSERTION_FAILED, "Failed to find primaryObj created in 
previous transaction.  Got JDODataStoreException " + e);
+           return;
+        }
+        
+        secondaryObj = primaryObj.nextObj;
+        if(secondaryObj == null) {
+            fail(ASSERTION_FAILED, "Failed to find secondaryObj created in 
previous transaction using reference from primaryObj.");
+            return;
+        }
+        pm.retrieve(secondaryObj);
+        
+        primaryObj.addChild(secondaryObj);  // primaryObj contains one child;  
secondaryObj contains none. primaryObj is now dirty
+        
+        cal.set(2005, 6, 28, 0, 0);
+        Date stillLaterDate = cal.getTime();
+        InstanceCallbackClass ternaryObj = new 
InstanceCallbackClass("ternaryObj", stillLaterDate, 3, 3.3, (short)-30, '3', 
null);
+        pm.makePersistent(ternaryObj);
+        ternaryObj.addChild(secondaryObj);
+        ternaryObj.addChild(primaryObj);
+        t.commit();
+        
+        // verify attributes in what was persistent-clean object--secondaryObj
+        checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access:  ", 
2,  "secondaryObj", createTime, 2.2, (short)-20, '2');
+
+        // verify attributes in what was persistent-dirty object--primaryObj
+        checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access:  ", 
1, "primaryObj", laterDate, 1.1, (short)-10, '1');
+
+
+        // verify attributes in what was persistent-new object--ternaryObj
+        checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access:  ", 
3, "ternaryObj", stillLaterDate, 3.3, (short)-30, '3');
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,146 @@
+/*
+ * 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.api.instancecallbacks;
+
+import javax.jdo.JDOException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling JDO Predelete
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.4-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+<code>jdoPreDelete()</code> is called during the execution of
+<code>deletePersistent</code> before the state transition to persistent-deleted
+or persistent-new-deleted.
+
+ */
+
+/*
+ *    Use the same PersistenceCapable class and objects as in the test 
AccessingFieldsInPredelete (but the
+ *      referenced object and Set need not be created).
+ *
+ *    Delete one such new persistent, one persistent clean and one persistent 
dirty object.
+ *
+ *    For each of these objects:
+ *       determine jdoPredelete is called after deletePersistent is called
+ *       determine jdoPredelete is called before statements after 
deletePersistent is called.
+ *       determine that in jdoPredelete, the state of the object is 
persistent-new, persistent-clean, or persistent-dirty
+ *         (appropriately).
+ *       determine that the state of the object after return from 
deletePersistent is persistent-deleted or
+ *         persitent-new-deleted (appropriately).
+ *
+ */
+public class CallingJdoPredelete extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+         "Assertion A10.4-1 (CallingJdoPredelete) 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(CallingJdoPredelete.class);
+    }
+    
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction();
+        
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackClass.removeAllInstances(pm); // always start fresh 
with no instances
+        t.commit();
+
+        InstanceCallbackClass.performPreDeleteTests = true; // enabling 
PreDelete tests
+        t.begin();
+        InstanceCallbackClass a = new InstanceCallbackClass(null, null, 1, 
1.0, (short)-1, '1', null);
+        InstanceCallbackClass b = new InstanceCallbackClass(null, null, 2, 
2.0, (short)-1, '2', null);
+        pm.makePersistent(a);
+        pm.makePersistent(b);
+        Object aId  = pm.getObjectId(a);
+        Object bId  = pm.getObjectId(b);
+        t.commit();
+        
+        t.begin();
+        try {
+            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object 
a created in previous transaction, got JDOUserException " + e);
+            return;
+        }
+        try {
+            b = (InstanceCallbackClass)pm.getObjectById(bId, true);
+        } catch (JDOException e) {
+            fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object 
b created in previous transaction, got JDOUserException " + e);
+            return;
+        }
+        
+        int getfld = a.intValue;    // cause instance to be persistent-clean  
+        int getfld2 = a.childToDelete;
+        b.childToDelete++;          // make second object dirty
+        InstanceCallbackClass c = new InstanceCallbackClass(null, null, 3, 
3.0, (short)-1, '3', null);
+        pm.makePersistent(c);       // create persistent-new object
+        
+        InstanceCallbackClass.preDeleteCalled = false;
+        pm.deletePersistent(a);
+        if(!InstanceCallbackClass.preDeleteCalled) {
+            fail(ASSERTION_FAILED, "jdoPreDelete not called when 
PERSISTENT_CLEAN object deleted.");
+        } else {
+            if(InstanceCallbackClass.objectState == PERSISTENT_DELETED) {
+                fail(ASSERTION_FAILED, "Error, state was persistent-deleted in 
jdoPredelete callback");
+            }
+        }
+        
+        InstanceCallbackClass.preDeleteCalled = false;
+        pm.deletePersistent(b);
+        if(!InstanceCallbackClass.preDeleteCalled) {
+            fail(ASSERTION_FAILED, "jdoPreDelete not called when 
PERSISTENT_DIRTY object deleted.");
+        } else {
+            if(InstanceCallbackClass.objectState == PERSISTENT_DELETED) {
+                fail(ASSERTION_FAILED, "Error, state was persistent-deleted in 
jdoPredelete callback");
+            }
+        }
+        
+        InstanceCallbackClass.preDeleteCalled = false;
+        pm.deletePersistent(c);
+        if(!InstanceCallbackClass.preDeleteCalled) {
+            fail(ASSERTION_FAILED,"jdoPreDelete not called when PERSISTENT_NEW 
object deleted.");
+        } else {
+            if(InstanceCallbackClass.objectState == PERSISTENT_NEW_DELETED) {
+                fail(ASSERTION_FAILED, "Error, state was 
persistent-new-deleted in jdoPredelete callback");
+            }
+        }
+        t.rollback();
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,212 @@
+/*
+ * 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.api.instancecallbacks;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import 
org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling InstanceCallbacks Prestore Method
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.2-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The <code>jdoPreStore()</code> method of a class implementing
+<code>InstanceCallbacks</code> is called before the values are
+stored from the instance to the <code>StateManager</code>.
+
+ */
+
+/*
+ *  Use non-managed and transactional values to construct a persistent 
attribute value to store in database.
+ *   Check to see this constructed persistent attribute got stored.
+ *
+ *  jdoPreStore() should have been called when obj1 and obj2 were created.
+ *  jdoPreStore() should have been called again when obj2 was modified.
+ *  jdoPreStore() should not be called a second time on obj1 because it was 
not modified.
+
+ /* 
+ This test is accomplished in three transactions. 
+     1)  object1 and object2 are created.  At commit, we expect jdoPreStore()
+         to be called on each and calculate values of persistent attributes 
from non-presistent attributes. 
+     2)  Retrieve object1 and object2 from the database and verify the 
persistent attributes
+         have values calculated in the jdoPreStore()s called in the previous 
transaction.
+         Change non-persistent fields in each but only change a persistent 
field in one of them. 
+     3)  Retrieve object1 and object2 from the database and verify that again 
jdoPreStore()
+         was called for each in the previous transaction. 
+*/ 
+
+public class CallingJdoPrestore extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.2-1 (CallingJdoPrestore) 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(CallingJdoPrestore.class);
+    }
+    
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction(); 
+
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackNonPersistFdsClass.removeAllInstances(pm); // always 
start fresh with no instances
+        t.commit();
+
+        InstanceCallbackClass.performPreStoreTests = true;
+        t.begin();        
+        int expectedIntValue1, expectedIntValue2;
+        float expectedFloatValue1, expectedFloatValue2;
+        
+        int origIntValue1 = 10, origIntValue2 = 12;
+        float origFloatValue1 = 2.5f, origFloatValue2 = -3.0f;
+        
+        // create two instances
+        
+        InstanceCallbackNonPersistFdsClass obj1 = new 
InstanceCallbackNonPersistFdsClass(origFloatValue1, origIntValue1);
+        pm.makePersistent(obj1);
+        Object objPtr1 = pm.getObjectId (obj1);
+        obj1.setNonPersist(5, (char)10, .25, (short)100);
+        expectedIntValue1 = obj1.calcIntValue();
+        expectedFloatValue1 = obj1.calcFloatValue();
+        
+        InstanceCallbackNonPersistFdsClass obj2 = new 
InstanceCallbackNonPersistFdsClass(origFloatValue2, origIntValue2);
+        pm.makePersistent(obj2);
+        Object objPtr2 = pm.getObjectId (obj2);
+        obj2.setNonPersist(2, (char)125, .1, (short)750);
+        expectedIntValue2 = obj2.calcIntValue();
+        expectedFloatValue2 = obj2.calcFloatValue();
+
+        t.commit();
+        
+        t.begin();
+        // read both objects back in to determine persistent state is as 
expected.
+        try {
+            obj1 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true);
+            checkValues("Object1 created and read back in:  ", origIntValue1, 
expectedIntValue1, obj1.intValue);
+            checkValues("Object1 created and read back in:  ", 
origFloatValue1, expectedFloatValue1, obj1.floatValue);
+            origIntValue1 = obj1.intValue;
+            origFloatValue1 = obj1.floatValue;
+            obj1.setNonManaged(-1, (char)62);
+            expectedIntValue1 = obj1.calcIntValue();
+            expectedFloatValue1 = obj1.calcFloatValue();
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj1 created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj1 created in previous transaction, got " + e);
+            return;
+        }
+
+        try {
+            obj2 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr2, true);
+            checkValues("Object2 created and read back in:  ", origIntValue2, 
expectedIntValue2, obj2.intValue);
+            checkValues("Object2 created and read back in:  ", 
origFloatValue2, expectedFloatValue2, obj2.floatValue);
+            origIntValue2 = obj2.intValue;
+            origFloatValue2 = obj2.floatValue;
+            obj2.setNonPersist(12, (char)30, 5.0, (short)137);
+            expectedIntValue2 = obj2.calcIntValue();
+            expectedFloatValue2 = obj2.calcFloatValue();
+            
+            // change obj2 making it persistent dirty (leave obj1 persistent 
clean).
+            obj2.incrementIntValue();
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj2 created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj2 created in previous transaction, got " + e);
+            return;
+        }
+
+        t.commit();
+        
+        t.begin();
+        // read both objects back in to determine persistent state is as 
expected.
+         try {
+            // obj1 not made dirty, so jdoPreStore() should not have been 
called.
+            obj1 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true);
+            checkValues("Object1, did not expect jdoPreStore to be called:  ", 
origIntValue1, origIntValue1, obj1.intValue);
+            checkValues("Object1, did not expect jdoPreStore to be called:  ", 
origFloatValue1, origFloatValue1, obj1.floatValue);
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj1 created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj1 created in previous transaction, got " + e);
+            return;
+        }
+        
+        try {
+            obj2 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr2, true);
+            checkValues("Object2, expected jdoPreStore() to be called:  ", 
origIntValue2, expectedIntValue2, obj2.intValue);
+            checkValues("Object2, expected jdoPreStore() to be called:  ", 
origFloatValue2, expectedFloatValue2, obj2.floatValue);
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj2 created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object 
obj2 created in previous transaction, got " + e);
+            return;
+        }
+        t.rollback();
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void checkValues(String title, int origIntValue, int expectedIntValue, int 
intValue) {
+        if(expectedIntValue != intValue) {
+            fail(ASSERTION_FAILED, 
+                 title + "Original persistent intValue is " + origIntValue + 
+                 ", expected " + expectedIntValue + 
+                 ".  Instead intValue is " + intValue);
+        }
+    }
+    
+    /** */
+    void checkValues(String title, float origFloatValue, float 
expectedFloatValue, float floatValue) {
+        if(expectedFloatValue != floatValue) {
+            fail(ASSERTION_FAILED,
+                 title + "Original persistent floatValue is " + origFloatValue 
+ 
+                 ", expected " + expectedFloatValue +
+                 ".  Instead floatVal is " + floatValue);
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,176 @@
+/*
+ * 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.api.instancecallbacks;
+
+import java.util.Iterator;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import 
org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Modification of Nontransactional Nonpersistent Fields
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A6.4.1-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+Nontransactional non-persistent fields may be modified during execution of
+user-written callbacks defined in interface <code>InstanceCallbacks</code>
+at specific points in the life cycle.
+
+ */
+
+/*
+ *  Test jdoPostLoad() by setting values into the non-managed and 
transactional attriubes.
+ *    This includes creating and populating a collection and initializing a 
Date.
+ *  Verify those values are set once the object is referenced.
+ *
+ *  Test jdoPreClear(), jdoPreDelete() & jdoPreStore() by setting values into 
the nonmanaged and transactional attributes.
+ *   This includes setting a collection and Date to null.
+ *  Verify that no exceptions are thrown.
+ */
+public class ModificationOfNontransactionalNonpersistentFields extends 
JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A6.4.1-3 
(ModificationOfNontransactionalNonpersistentFields) 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(ModificationOfNontransactionalNonpersistentFields.class);
+    }
+
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction(); 
+
+        InstanceCallbackNonPersistFdsClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackNonPersistFdsClass.removeAllInstances(pm); // always 
start fresh with no instances
+        t.commit();
+        
+        t.begin();
+        // create instance
+        InstanceCallbackNonPersistFdsClass obj1 = new 
InstanceCallbackNonPersistFdsClass(1.1f, 1);
+        pm.makePersistent(obj1);
+        Object objPtr1 = pm.getObjectId (obj1);
+        obj1.setNonPersist(1, (char)1, 0, (short)0);
+        t.commit();  // jdoPreStore() and jdoPreClear() called 
+        
+        t.begin();
+        try {
+            obj1 = 
(InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true);  // 
jdoPostLoad() called
+        } catch (JDOUserException e) {
+            // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, 
"ModificationOfNontransactionalNonpersistentFields:  Could not locate 
persistent object obj1 created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+           // could not locate persistent object created in previous 
transaction
+            fail(ASSERTION_FAILED, 
"ModificationOfNontransactionalNonpersistentFields:  Could not locate 
persistent object obj1 created in previous transaction, got " + e);
+            return;
+        }
+        
+        // check fields set in jdoPostLoad()
+        if(obj1.i != -10) {
+            fail(ASSERTION_FAILED, "jdoPostLoad:  Value incorrect, obj1.i != 
-10; it is " + obj1.i);
+        }
+        if(obj1.c != '2') {
+            fail(ASSERTION_FAILED, "jdoPostLoad:  Value incorrect, obj1.c != 
'2'; it is " + obj1.c);
+        }
+        if(obj1.d != 30.0) {
+            fail(ASSERTION_FAILED, "jdoPostLoad:  Value incorrect, obj1.d != 
30.0; it is " + obj1.d);
+        }
+        if(obj1.s != 40) {
+            fail(ASSERTION_FAILED, "jdoPostLoad:  Value incorrect, obj1.s != 
40; it is " + obj1.s);
+        }
+        if(obj1.loadTime != InstanceCallbackNonPersistFdsClass.savedLoadTime)  
{
+            fail(ASSERTION_FAILED,
+                 "jdoPostLoad:  Value incorrect, obj1.loadTime != " +
+                 InstanceCallbackNonPersistFdsClass.savedLoadTime + 
+                 "; it is " + obj1.loadTime);
+        }
+        boolean childrenValueIncorrect = false;
+        if(obj1.children.size() != 3)  {
+            childrenValueIncorrect = true;
+        }else {
+            
if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member1)) {
+                childrenValueIncorrect = true;
+            }
+            
if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member2)) {
+                childrenValueIncorrect = true;
+            }
+            
if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member3)) {
+                childrenValueIncorrect = true;
+            }
+        }
+        if(childrenValueIncorrect) {
+            if (debug) {
+                logger.debug("jdoPostLoad:  Value incorrect, obj1.children 
does not contain the correct String members");
+                logger.debug("The members should be: " + 
InstanceCallbackNonPersistFdsClass.member1 + ", " +
+                        InstanceCallbackNonPersistFdsClass.member2 + ", " + 
InstanceCallbackNonPersistFdsClass.member3);
+                logger.debug("obj1.children contains " + obj1.children.size() 
+ " members");
+                if(obj1.children.size() != 0) {
+                    logger.debug("Those members are:");
+                    for(Iterator i = obj1.children.iterator(); i.hasNext();) {
+                        logger.debug((String)i.next());
+                    }
+                }
+            }
+            fail(ASSERTION_FAILED, "jdoPostLoad:  Value incorrect, 
obj1.children does not contain the correct String members");
+        }
+        
+        pm.deletePersistent(obj1);  // jdoPreDelete() called
+        t.commit();
+        // check result of jdoPreStore(), jdoPreClear() and jdoPreDelete()
+        if (!InstanceCallbackNonPersistFdsClass.preClearCalled) {
+            fail(ASSERTION_FAILED, "jdoPreClear() never called on obj1");
+        }
+        
+        if(!InstanceCallbackNonPersistFdsClass.preStoreCalled) {
+            fail(ASSERTION_FAILED, "jdoPreStore() never called on obj1");
+        }
+        
+        if(!InstanceCallbackNonPersistFdsClass.preDeleteCalled) {
+            fail(ASSERTION_FAILED, "jdoPreDelete() never called on obj1");
+        }
+        
+        if(InstanceCallbackNonPersistFdsClass.exceptions.size() != 0) {
+            for(int index = 0; index < 
InstanceCallbackNonPersistFdsClass.exceptions.size(); index++) {
+                fail(ASSERTION_FAILED, 
+                     "" + 
InstanceCallbackNonPersistFdsClass.callbackCalled.get(index) + 
+                     "operation " + 
+                     
InstanceCallbackNonPersistFdsClass.attributeOpCausingExceptions.get(index) + 
+                     " resulted in exception " +
+                     InstanceCallbackNonPersistFdsClass.exceptions.get(index));
+            }
+        }
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,159 @@
+/*
+ * 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.api.instancecallbacks;
+
+import java.util.Date;
+import java.util.HashSet;
+
+import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> No Access To Fields After Predelete
+ *<BR>
+ *<B>Keywords:</B> instancecallbacks
+ *<BR>
+ *<B>Assertion ID:</B> A10.4-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+Access to field values after a call to <code>jdoPreDelete()</code>
+of a class implementing <code>InstanceCallbacks</code> are disallowed.
+
+ */
+
+/*
+ *  Delete a persistent object and new object.  While the objects are in state 
persitent-deleted (or persistent-new-deleted)
+ *     access persistent fields (except do not reference primary key fields).
+ *
+ *  Verify the field access results in a JDOUserException.
+ */
+
+public class NoAccessToFieldsAfterPredelete extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A10.4-3 (NoAccessToFieldsAfterPredelete) 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(NoAccessToFieldsAfterPredelete.class);
+    }
+
+    /** */
+    public void test() throws Exception
+    {
+        pm = getPM();
+        Transaction t = pm.currentTransaction(); 
+
+        InstanceCallbackClass.initializeStaticsForTest();
+        t.begin();
+        InstanceCallbackClass.removeAllInstances(pm); // always start fresh 
with no instances
+        t.commit();
+        
+        t.begin();
+        // make intValue outside the range of zero to arraySize-1 to skip most 
jdoPreDelete() code.
+        InstanceCallbackClass a = new InstanceCallbackClass("object a", null, 
InstanceCallbackClass.arraySize, 6.0, (short)-1, '6', null);
+        pm.makePersistent(a);
+        Object aId = pm.getObjectId(a);
+        t.commit();
+        
+        t.begin();
+        // relocte object.
+        try {
+            a = (InstanceCallbackClass)pm.getObjectById(aId, true);
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not 
locate persistent object created in previous transaction, got " + e);
+            return;
+        } catch (JDODataStoreException e) {
+            fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete:  Could not 
locate persistent object created in previous transaction, got " + e);
+            return;
+        }
+        
+        pm.deletePersistent(a);
+        performAccessFieldTests("Object in state persistent-deleted:  ", a);
+        
+        InstanceCallbackClass b = new InstanceCallbackClass("object b", null, 
InstanceCallbackClass.arraySize + 1, 7.0, (short)-1, '7', null);
+        pm.makePersistent(b);
+        pm.deletePersistent(b);
+        performAccessFieldTests("Object in state persistent-new-deleted:  ", 
b);
+        
+        t.rollback();
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    void performAccessFieldTests(String title, InstanceCallbackClass o) {
+        try {
+            short x1 = o.childToDelete;
+            fail(ASSERTION_FAILED, title + "Accessed persistent short field 
childToDelete--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            double x2 = o.doubleValue;
+            fail(ASSERTION_FAILED, title + "Accessed persistent double field 
doubleValue--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            char x3 = o.charValue;
+            fail(ASSERTION_FAILED, title + "Accessed persistent char field 
charValue--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            String x4 = o.name;
+            fail(ASSERTION_FAILED,title + "Accessed persistent String field 
name--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            Date x5 = o.timeStamp;
+            fail(ASSERTION_FAILED, title + "Accessed persistent Date field 
timeStamp--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            HashSet x6 = o.children;
+            fail(ASSERTION_FAILED, title + "Accessed persistent HashSet field 
Children--should have gotten JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+        
+        try {
+            InstanceCallbackClass x7 = o.nextObj;
+            fail(ASSERTION_FAILED, title + "Accessed persistent 
InstanceCallbackClass reference field nextObj--should have gotten 
JDOUserException");
+        } catch (JDOUserException e) {
+            // expected
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to