You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by cu...@apache.org on 2010/07/06 20:54:00 UTC

svn commit: r960981 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/ openjpa-kernel/src/main/resources/org/...

Author: curtisr7
Date: Tue Jul  6 18:53:59 2010
New Revision: 960981

URL: http://svn.apache.org/viewvc?rev=960981&view=rev
Log:
OPENJPA-1707: Log a warning message when a down level Entity is encountered.

Added:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java   (with props)
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java   (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
    openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties
    openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
    openjpa/trunk/openjpa-lib/pom.xml

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=960981&r1=960980&r2=960981&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Tue Jul  6 18:53:59 2010
@@ -21,6 +21,7 @@ package org.apache.openjpa.enhance;
 import java.io.Externalizable;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInput;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
@@ -45,11 +46,13 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.conf.OpenJPAVersion;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.ClassArgParser;
@@ -60,6 +63,7 @@ import org.apache.openjpa.lib.util.Local
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.Services;
 import org.apache.openjpa.lib.util.Localizer.Message;
+import org.apache.openjpa.lib.util.svn.SVNUtils;
 import org.apache.openjpa.meta.AccessCode;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
@@ -110,13 +114,13 @@ import serp.util.Strings;
  *
  * @author Abe White
  */
-public class PCEnhancer {
+public class PCEnhancer { 
     // Designates a version for maintaining compatbility when PCEnhancer
     // modifies enhancement that can break serialization or other contracts
     // Each enhanced class will return the value of this field via
     // public int getEnhancementContractVersion()
-    public static final int ENHANCER_VERSION = 2;
-    
+    public static final int ENHANCER_VERSION;
+
     boolean _addVersionInitFlag = true; 
 
     public static final int ENHANCE_NONE = 0;
@@ -164,6 +168,29 @@ public class PCEnhancer {
         }
         _auxEnhancers = (AuxiliaryEnhancer[]) auxEnhancers.toArray
         (new AuxiliaryEnhancer[auxEnhancers.size()]);
+        
+        int rev = 0;
+        Properties revisionProps = new Properties();
+        try {
+            InputStream in = PCEnhancer.class.getResourceAsStream("/META-INF/org.apache.openjpa.revision.properties");
+            if (in != null) {
+                try {
+                    revisionProps.load(in);
+                } finally {
+                    in.close();
+                }
+            }
+            String prop = revisionProps.getProperty("openjpa.enhancer.revision");
+            rev = SVNUtils.svnInfoToInteger(prop);
+        } catch (Exception e) {
+        }
+        if (rev > 0) {
+            ENHANCER_VERSION = rev;
+        } else {
+            // Something bad happened and we couldn't load from the properties file. We need to default to using the
+            // value of 2 because that is the value that was the value as of rev.511998.
+            ENHANCER_VERSION = 2;
+        }
     }
 
     private BCClass _pc;
@@ -4700,4 +4727,34 @@ public class PCEnhancer {
         code.calculateMaxStack();
         code.calculateMaxLocals();
     }
+    
+    /**
+     * This static public worker method detects and logs any Entities that may have been enhanced at build time by
+     * a version of the enhancer that is older than the current version.
+     * 
+     * @param cls
+     *            - A non-null Class implementing org.apache.openjpa.enhance.PersistenceCapable.
+     * @param log
+     *            - A non-null org.apache.openjpa.lib.log.Log.
+     * 
+     * @throws - IllegalStateException if cls doesn't implement org.apache.openjpa.enhance.PersistenceCapable.
+     * 
+     * @return true if the provided Class is down level from the current PCEnhancer.ENHANCER_VERSION. False
+     *         otherwise.
+     */
+    public static boolean checkEnhancementLevel(Class<?> cls, Log log) {
+        if (cls == null || log == null) {
+            return false;
+        }
+        PersistenceCapable pc = PCRegistry.newInstance(cls, null, true);
+        if (pc == null) {
+            return false;
+        }
+        if (pc.pcGetEnhancementContractVersion() < PCEnhancer.ENHANCER_VERSION) {
+            log.info(_loc.get("down-level-enhanced-entity", new Object[] { cls.getName(),
+                pc.pcGetEnhancementContractVersion(), PCEnhancer.ENHANCER_VERSION }));
+            return true;
+        }
+        return false;
+    }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?rev=960981&r1=960980&r2=960981&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java Tue Jul  6 18:53:59 2010
@@ -37,6 +37,7 @@ import java.util.TreeSet;
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.enhance.DynamicPersistenceCapable;
+import org.apache.openjpa.enhance.PCEnhancer;
 import org.apache.openjpa.enhance.PCRegistry;
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.enhance.PCRegistry.RegisterClassListener;
@@ -154,6 +155,10 @@ public class MetaDataRepository implemen
     private static final String PRELOAD_STR = "Preload";
     
     private boolean _reorderMetaDataResolution = false;
+    
+    // A boolean used to decide whether or not we need to call to PCEnhancer to check whether we have any down level
+    // Entities.
+    private boolean _logEnhancementLevel = true;
 
     /**
      * Default constructor. Configure via {@link Configurable}.
@@ -1622,6 +1627,7 @@ public class MetaDataRepository implemen
             if (pcNames != null && !pcNames.isEmpty() && !pcNames.contains(reg[i].getName()))
                 continue;
 
+            checkEnhancementLevel(reg[i]);
             try {
                 processRegisteredClass(reg[i]);
             } catch (Throwable t) {
@@ -2628,4 +2634,20 @@ public class MetaDataRepository implemen
         return false;
     }
 
+    /**
+     * This private worker ensures that a message is logged when an Entity is enhanced by a version of the enhancer that
+     * is older than the current version.
+     */
+    private void checkEnhancementLevel(Class<?> cls) {
+        if (_logEnhancementLevel == false) {
+            return;
+        }
+        Log log = _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
+        boolean res = PCEnhancer.checkEnhancementLevel(cls, _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME));
+        if (log.isTraceEnabled() == false && res == true) {
+            // Since trace isn't enabled flip the flag so we only log this once.
+            _logEnhancementLevel = false;
+            log.info(_loc.get("down-level-entity"));
+        }
+    }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties?rev=960981&r1=960980&r2=960981&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties (original)
+++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties Tue Jul  6 18:53:59 2010
@@ -214,4 +214,6 @@ temp-file-creation: The temporary file "
 get-field: Error while getting value of field {1} from instance {0} by reflection.    
 get-method: Error while getting value by getter method {1} on instance {0} by reflection.    
 set-field: Error while setting value {2} of {3} on field {1} of instance {0} by reflection.    
-set-method: Error while setting value {2} of {3} by setter method {1} of instance {0} by reflection.    
+set-method: Error while setting value {2} of {3} by setter method {1} of instance {0} by reflection.
+down-level-enhanced-entity: The Entity "{0}" was enhanced at level "{1}", but the current level of enhancement is \
+"{2}". 

Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties?rev=960981&r1=960980&r2=960981&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties (original)
+++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties Tue Jul  6 18:53:59 2010
@@ -359,4 +359,5 @@ repos-initializeEager-error: Unexpected 
 pu-root-url: The persistent unit root url is "{0}"
 resource-url: The resource url is "{0}"   
 mapping-file-name: Mapping file name is "{0}"
-jar-file-url: Jar file url is "{0}"
\ No newline at end of file
+jar-file-url: Jar file url is "{0}"
+down-level-entity: A down level Entity was detected and logged. Please enable RUNTIME trace to see all down level Entities.

Modified: openjpa/trunk/openjpa-lib/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/pom.xml?rev=960981&r1=960980&r2=960981&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/pom.xml (original)
+++ openjpa/trunk/openjpa-lib/pom.xml Tue Jul  6 18:53:59 2010
@@ -99,13 +99,18 @@
                                 <exec outputproperty="subversion.revision" failonerror="false" failifexecutionfails="false" executable="${svnversion.executable}">
                                     <arg line="-c ${basedir}/.." />
                                 </exec>
+                                <exec outputproperty="pcenhancer.revision" failonerror="false" failifexecutionfails="false" executable="${svnversion.executable}">
+                                    <arg line=". ../openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java" />
+                                </exec>                                
                                 <property name="subversion.revision" value="unknown" />
                                 <echo>Revision: ${subversion.revision}</echo>
                                 <echo>OpenJPA version: ${project.version}</echo>
                                     
                                 <mkdir dir="${outdir}/META-INF" />
                                 <echo file="${outdir}/META-INF/org.apache.openjpa.revision.properties">revision.number=${subversion.revision}
-openjpa.version=${project.version}</echo>
+openjpa.version=${project.version}
+openjpa.enhancer.revision=${pcenhancer.revision}
+</echo>
                                 <delete dir="${tmpdir}" />
                             </tasks>
                         </configuration>

Added: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java?rev=960981&view=auto
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java (added)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java Tue Jul  6 18:53:59 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.lib.util.svn;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class SVNUtils {
+    static final Pattern fullRevisionPattern = Pattern.compile("(([0-9]*:)?)[0-9]+(([MSms]+)?)");
+    static final Pattern revisionPattern = Pattern.compile("[0-9]+");
+
+    /**
+     * A public worker method that takes the output from running the svnversion command and parses the trailing integer
+     * version out.
+     * 
+     * For example: 959691:959709M would return 959709
+     * 
+     * @param svninfo
+     * @return The formatted int version, or -1 if svninfo is null or unparsable.
+     */
+    public static int svnInfoToInteger(String svninfo) {
+        if (svninfo == null || fullRevisionPattern.matcher(svninfo).matches() == false) {
+            return -1;
+        }
+        // We only want to look after ":"
+        int index = svninfo.indexOf(":");
+        if(index != -1){
+            svninfo = svninfo.substring(index+1);
+        }
+
+        Matcher matcher = revisionPattern.matcher(svninfo);
+        if(matcher.find()){
+            return Integer.parseInt(matcher.group());
+        }
+
+        return -1;
+    }
+}

Propchange: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/svn/SVNUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java?rev=960981&view=auto
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java (added)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java Tue Jul  6 18:53:59 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.lib.util.svn;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+public class TestSVNUtils extends TestCase {
+    public TestSVNUtils(String s) {
+        super(s);
+    }
+
+    public void testNull() {
+        assertEquals(-1, SVNUtils.svnInfoToInteger(null));
+    }
+
+    public void testBasic() {
+        int i = 12345678;
+        assertEquals(i, SVNUtils.svnInfoToInteger(i + ""));
+    }
+
+    public void testGoodTrailingString() {
+        int i = 12345678;
+        assertEquals(i, SVNUtils.svnInfoToInteger(i + "m"));
+    }
+
+    public void testMixedRevision() {
+        int i = 12345678;
+        assertEquals(i, SVNUtils.svnInfoToInteger("55555:" + i));
+    }
+
+    public void testMixedRevisionTrailingString() {
+        int i = 12345678;
+        assertEquals(i, SVNUtils.svnInfoToInteger("55555:" + i + "MS"));
+    }
+
+    public void testBad() {
+        int i = 12345678;
+        assertEquals(-1, SVNUtils.svnInfoToInteger("55555:aa" + i + "ms"));
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestSVNUtils.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Propchange: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/svn/TestSVNUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java?rev=960981&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java Tue Jul  6 18:53:59 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.enhance;
+
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.log.NoneLogFactory.NoneLog;
+import org.apache.openjpa.persistence.DummyPersistenceCapeable;
+import org.apache.openjpa.persistence.Country;
+import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
+
+public class TestPCEnhancerEnhancementContractVersion extends AbstractPersistenceTestCase {
+    Log log = NoneLog.getInstance();
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        // Create to trigger static initializer to run.
+        new Country();
+        new DummyPersistenceCapeable();
+    }
+    public void testCurrentLevel() {
+        assertFalse(PCEnhancer.checkEnhancementLevel(Country.class, log));
+    }
+    
+    public void testDownLevel(){
+        assertTrue(PCEnhancer.checkEnhancementLevel(DummyPersistenceCapeable.class, log));
+    }
+    public void testContact() {
+        assertFalse(PCEnhancer.checkEnhancementLevel(null, log));
+        assertFalse(PCEnhancer.checkEnhancementLevel(Country.class, null));
+        try {
+            PCEnhancer.checkEnhancementLevel(Object.class, log);
+            fail("Should have got an IllegalArgumentException exception from " +
+            		"org.apache.openjpa.enhance.PCEnhancer.checkEnhancementLevel");
+        } catch (java.lang.IllegalStateException ile) {
+            // expected
+        }
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerEnhancementContractVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java?rev=960981&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java Tue Jul  6 18:53:59 2010
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence;
+
+import org.apache.openjpa.enhance.FieldConsumer;
+import org.apache.openjpa.enhance.FieldSupplier;
+import org.apache.openjpa.enhance.PCEnhancer;
+import org.apache.openjpa.enhance.PCRegistry;
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.enhance.StateManager;
+
+/**
+ * This Object is here for the sole purpose of testing pcGetEnhancementContractVersion. This object isn't a tested
+ * PersistenceCapable implementation so it shouldn't be used unless you are fully aware of what you are doing.
+ */
+public class DummyPersistenceCapeable implements PersistenceCapable {
+    private static int pcInheritedFieldCount;
+    private static String pcFieldNames[] = {};
+    private static Class pcFieldTypes[];
+    private static byte pcFieldFlags[] = {};
+    private static Class pcPCSuperclass;
+    protected transient boolean pcVersionInit;
+    protected transient StateManager pcStateManager;
+    private transient Object pcDetachedState;
+
+    static {
+        Class aclass[] = new Class[0];
+        pcFieldTypes = aclass;
+        PCRegistry.register(DummyPersistenceCapeable.class, pcFieldNames, pcFieldTypes, pcFieldFlags, pcPCSuperclass,
+            "DummyPersistenceCapeable", new DummyPersistenceCapeable());
+    }
+
+    public int pcGetEnhancementContractVersion() {
+        return PCEnhancer.ENHANCER_VERSION - 1;
+    }
+
+    public PersistenceCapable pcNewInstance(StateManager sm, boolean clear) {
+        return new DummyPersistenceCapeable();
+    }
+
+    public void pcCopyFields(Object fromObject, int[] fields) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcCopyKeyFieldsFromObjectId(FieldConsumer consumer, Object obj) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcCopyKeyFieldsToObjectId(FieldSupplier supplier, Object obj) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcCopyKeyFieldsToObjectId(Object obj) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcDirty(String fieldName) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public Object pcFetchObjectId() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object pcGetDetachedState() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object pcGetGenericContext() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public StateManager pcGetStateManager() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object pcGetVersion() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean pcIsDeleted() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public Boolean pcIsDetached() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean pcIsDirty() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean pcIsNew() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean pcIsPersistent() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean pcIsTransactional() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public PersistenceCapable pcNewInstance(StateManager sm, Object obj, boolean clear) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object pcNewObjectIdInstance() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object pcNewObjectIdInstance(Object obj) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void pcProvideField(int fieldIndex) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcProvideFields(int[] fieldIndices) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcReplaceField(int fieldIndex) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcReplaceFields(int[] fieldIndex) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcReplaceStateManager(StateManager sm) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void pcSetDetachedState(Object state) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public DummyPersistenceCapeable() {
+        // TODO Auto-generated constructor stub
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/DummyPersistenceCapeable.java
------------------------------------------------------------------------------
    svn:eol-style = native