You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by cl...@apache.org on 2010/06/25 14:03:46 UTC

svn commit: r957906 - in /db/jdo/trunk/api/test: java/javax/jdo/JDOConfigTestClassLoader.java java/javax/jdo/PMFMapMapTest.java java/javax/jdo/PMFProxy.java java/javax/jdo/PMFService.java schema/jdoconfig/Pmfmapmap01/ schema/jdoconfig/Pmfmapmap02/

Author: clr
Date: Fri Jun 25 12:03:46 2010
New Revision: 957906

URL: http://svn.apache.org/viewvc?rev=957906&view=rev
Log:
JDO-557 applied changes to trunk/api

Added:
    db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java   (with props)
    db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java   (with props)
    db/jdo/trunk/api/test/java/javax/jdo/PMFService.java   (with props)
    db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap01/
      - copied from r957894, db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/
    db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap02/
      - copied from r957894, db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/
Modified:
    db/jdo/trunk/api/test/java/javax/jdo/JDOConfigTestClassLoader.java

Modified: db/jdo/trunk/api/test/java/javax/jdo/JDOConfigTestClassLoader.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/JDOConfigTestClassLoader.java?rev=957906&r1=957905&r2=957906&view=diff
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/JDOConfigTestClassLoader.java (original)
+++ db/jdo/trunk/api/test/java/javax/jdo/JDOConfigTestClassLoader.java Fri Jun 25 12:03:46 2010
@@ -5,6 +5,7 @@ import org.apache.tools.ant.AntClassLoad
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.MalformedURLException;
+import java.io.File;
 import java.util.StringTokenizer;
 import java.util.List;
 import java.util.ArrayList;
@@ -73,10 +74,13 @@ public class JDOConfigTestClassLoader ex
     ) {
         List<String> elements = new ArrayList<String>();
         String classpath = unparent.getClasspath();
-        StringTokenizer st = new StringTokenizer(
-                classpath, System.getProperty("path.separator"));
+        StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
         while (st.hasMoreTokens()) {
-            elements.add("file://" + st.nextToken());
+            String nextToken = st.nextToken();
+            if(!nextToken.endsWith(".jar")) {
+                nextToken = nextToken.concat(File.separator);
+            }
+            elements.add("file://" + nextToken);
         }
         Iterator<String> i = elements.iterator();
         while (i.hasNext()) {

Added: db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java?rev=957906&view=auto
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java (added)
+++ db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java Fri Jun 25 12:03:46 2010
@@ -0,0 +1,507 @@
+/*
+ * 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 javax.jdo;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.net.MalformedURLException;
+
+import javax.jdo.util.AbstractTest;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Properties;
+import junit.framework.TestSuite;
+
+import javax.jdo.util.BatchTestRunner;
+
+/**
+ * 
+ * Tests class javax.jdo.JDOHelper for calls to the impl's static method
+ *  getPersistenceManagerFactory(Map overrides, Map props).
+ * 
+ */
+public class PMFMapMapTest extends AbstractTest implements Constants {
+
+    static String expectedDriverName = "Jane Doe";
+    static String expectedDriverName4NamedPMF = "Larry";
+    static String expectedDriverNameWithOverrides = "Gerard Manley Hopkins";
+    static String PMFName = "BookSearch";
+    static String resourceDir = "Pmfmapmap01";
+    static String propsDir = "Pmfmapmap02";
+    static String pmfServiceClass = "javax.jdo.PMFService";
+    static String propertiesFile = "propsfile.props";
+    PersistenceManagerFactory pmf;
+    Properties props;
+    Properties overrides;
+    URLClassLoader resourceClassLoader;
+    ClassLoader saveContextClassLoader;
+
+    public static void main(String args[]) {
+        BatchTestRunner.run(PMFMapMapTest.class);
+    }
+
+    /**
+     * {@inheritDoc}
+     * @return {@inheritDoc}
+     */
+    public static TestSuite suite() {
+        return new TestSuite(PMFMapMapTest.class);
+    }
+
+    public void setup() {
+    }
+
+    public void teardown() {
+    }
+
+    void setupResourceClassLoader(String dir) {
+        try {
+            URL url = new URL(
+                    "file://" + JDOCONFIG_CLASSPATH_PREFIX + "/" + dir + "/");
+            resourceClassLoader = new URLClassLoader(new URL[]{url},
+                    getClass().getClassLoader());
+        } catch (MalformedURLException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    /**
+     * A class path prefix used in the various tests where the class path
+     * needs to be set.
+     */
+    protected static String JDOCONFIG_CLASSPATH_PREFIX = initJDOConfigClasspathPrefix();
+
+    /**
+     * Returns the JDO configuration class path prefix's default value, which is
+     * the project base directory suffixed by the path to the configuration
+     * directory (<tt>test/schema/jdoconfig</tt>).
+     *
+     * @return the default class path prefix used by this test suite.
+     *
+     */
+    protected static String initJDOConfigClasspathPrefix() {
+        return initBasedir() + "test/schema/jdoconfig";
+    }
+
+    /**
+     * Returns the base directory for this project.  This base directory
+     * is used to build up the other class paths defined in this test suite.
+     * The value returned is the value returned by
+     * <code>System.getProperty("basedir")</code>.
+     * A trailing slash is appended to the path if it doesn't exist.
+     *
+     * @return the default base directory of the project.
+     */
+    protected static String initBasedir() {
+        String basedir = System.getProperty("basedir");
+        if (basedir != null) {
+            if (!basedir.endsWith("/")) {
+                basedir += "/";
+            }
+        } else {
+            basedir = "";
+        }
+        return basedir;
+    }
+
+    /* static PersistenceManagerFactory getPersistenceManagerFactory()
+    Get the anonymous PersistenceManagerFactory configured via the
+    standard configuration file resource "META-INF/jdoconfig.xml",
+    using the current thread's context class loader to locate the
+    configuration file resource(s).
+     */
+    public void testJDOConfigXML() {
+
+        setupResourceClassLoader(resourceDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory();
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory
+    (java.lang.ClassLoader pmfClassLoader)
+    Get the anonymous PersistenceManagerFactory configured via the
+    standard configuration file resource "META-INF/jdoconfig.xml",
+    using the given class loader.
+     */
+    public void testJDOConfigXMLWithLoader() throws IOException {
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.io.File propsFile)
+    Returns a PersistenceManagerFactory configured based on the properties
+    stored in the file at propsFile.
+     */
+    public void testPropsFile() {
+
+        setupResourceClassLoader(propsDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(propertiesFile);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.io.File propsFile, java.lang.ClassLoader loader)
+    Returns a PersistenceManagerFactory configured based on the properties
+    stored in the file at propsFile.
+     */
+    public void testPropsFileAndLoader() {
+
+        setupResourceClassLoader(propsDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(propertiesFile,
+                    resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.io.InputStream stream)
+    Returns a PersistenceManagerFactory configured based on the Properties
+    stored in the input stream at stream.
+     */
+    public void testInputStream() {
+        props = new Properties();
+        props.setProperty(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS,
+                pmfServiceClass);
+        props.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverName);
+
+        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
+        try {
+            props.store(outstream, "");
+        } catch (IOException ex) {
+            fail(ex.getMessage());
+        }
+        InputStream byteArrayInputStream =
+                new ByteArrayInputStream(outstream.toByteArray());
+
+        setupResourceClassLoader(resourceDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(byteArrayInputStream);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.io.InputStream stream, java.lang.ClassLoader loader)
+    Returns a PersistenceManagerFactory configured based on the Properties
+    stored in the input stream at stream.
+     */
+    public void testInputStreamWithLoader() {
+        props = new Properties();
+        props.setProperty(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS,
+                pmfServiceClass);
+        props.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverName);
+
+        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
+        try {
+            props.store(outstream, "");
+        } catch (IOException ex) {
+            fail(ex.getMessage());
+        }
+        InputStream byteArrayInputStream =
+                new ByteArrayInputStream(outstream.toByteArray());
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(byteArrayInputStream,
+                    resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.util.Map<?,?> props)
+    Get a PersistenceManagerFactory based on a Properties instance,
+    using the current thread's context class loader to locate
+    the PersistenceManagerFactory class.
+     */
+    public void testProperties() {
+        props = new Properties();
+        props.setProperty(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS,
+                pmfServiceClass);
+        props.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverName);
+
+        setupResourceClassLoader(resourceDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(props);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.util.Map<?,?> props, java.lang.ClassLoader pmfClassLoader)
+    Get a PersistenceManagerFactory based on a Map and a class loader.
+     */
+    public void testPropertiesAndLoader() {
+        props = new Properties();
+        props.setProperty(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS,
+                pmfServiceClass);
+        props.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverName);
+
+        setupResourceClassLoader(resourceDir);
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(props,
+                    resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory
+    (java.util.Map<?,?> overrides, java.lang.String name)
+    Returns a named PersistenceManagerFactory or persistence unit.
+     */
+    public void testNamedPMFWithOverrides() {
+        overrides = new Properties();
+        overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverNameWithOverrides);
+
+        setupResourceClassLoader(resourceDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverNameWithOverrides.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverNameWithOverrides + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.util.Map<?,?> overrides, java.lang.String name,
+    java.lang.ClassLoader resourceLoader)
+    Returns a named PersistenceManagerFactory or persistence unit.
+     */
+    public void testNamedPMFWithOverridesAndLoader() {
+        overrides = new Properties();
+        overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverNameWithOverrides);
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName,
+                    resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverNameWithOverrides.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverNameWithOverrides + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.util.Map<?,?> overrides, java.lang.String name,
+    java.lang.ClassLoader resourceLoader, java.lang.ClassLoader pmfLoader)
+    Returns a PersistenceManagerFactory configured based on the properties
+    stored in the resource at name, or, if not found,
+    returns a PersistenceManagerFactory with the given name or,
+    if not found, returns a javax.persistence.EntityManagerFactory
+    cast to a PersistenceManagerFactory.
+     */
+    public void testNamedPMFWithOverridesAndTwoLoaders() {
+        overrides = new Properties();
+        overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME,
+                expectedDriverNameWithOverrides);
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName,
+                    resourceClassLoader,
+                    Thread.currentThread().getContextClassLoader());
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverNameWithOverrides.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverNameWithOverrides + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.lang.String name)
+    Returns a named PersistenceManagerFactory or persistence unit.
+     */
+    public void testNamedPMF() {
+
+        setupResourceClassLoader(resourceDir);
+        Thread.currentThread().setContextClassLoader(resourceClassLoader);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(PMFName);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName4NamedPMF.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName4NamedPMF + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory
+    (java.lang.String name, java.lang.ClassLoader loader)
+    Returns a named PersistenceManagerFactory or persistence unit.
+     */
+    public void testNamedPMFWithLoader() {
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(PMFName,
+                    resourceClassLoader);
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName4NamedPMF.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName4NamedPMF + "\"");
+        }
+    }
+
+    /*
+    static PersistenceManagerFactory getPersistenceManagerFactory(
+    java.lang.String name, java.lang.ClassLoader resourceLoader,
+    java.lang.ClassLoader pmfLoader)
+    Returns a named PersistenceManagerFactory or persistence unit.
+     */
+    public void testNamedPMFWithTwoLoaders() {
+
+        setupResourceClassLoader(resourceDir);
+
+        try {
+            pmf = JDOHelper.getPersistenceManagerFactory(PMFName,
+                    resourceClassLoader,
+                    Thread.currentThread().getContextClassLoader());
+        } catch (JDOFatalUserException ex) {
+            fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage());
+        }
+
+        String driverName = pmf.getConnectionDriverName();
+        if (!expectedDriverName4NamedPMF.equals(driverName)) {
+            fail("Bad ConnectionDriverName(): " + driverName + ".  Expected: \""
+                    + expectedDriverName4NamedPMF + "\"");
+        }
+    }
+}

Propchange: db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java?rev=957906&view=auto
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java (added)
+++ db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java Fri Jun 25 12:03:46 2010
@@ -0,0 +1,58 @@
+/*
+ * 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 javax.jdo;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * 
+ * <p>
+ */
+public class PMFProxy implements InvocationHandler {
+
+    private String connectionDriverName;
+
+    public static PersistenceManagerFactory newInstance() {
+        PersistenceManagerFactory pmf =
+               (PersistenceManagerFactory) Proxy.newProxyInstance(
+                PMFProxy.class.getClassLoader(),
+                new Class[]{PersistenceManagerFactory.class},
+                new PMFProxy());
+        return pmf;
+    }
+
+    /*
+     *
+     */
+    public Object invoke(Object proxy, Method m, Object[] args)
+            throws Exception {
+        Object result = null;
+
+        if (m.getName().equals("getConnectionDriverName")) {
+            result = connectionDriverName;
+        } else if (m.getName().equals("setConnectionDriverName")) {
+            connectionDriverName = (String) args[0];
+        } else {
+            throw new Exception(
+                    "Unexpected invocation of method: " + m);
+        }
+        return result;
+    }
+}
+

Propchange: db/jdo/trunk/api/test/java/javax/jdo/PMFProxy.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/api/test/java/javax/jdo/PMFService.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/PMFService.java?rev=957906&view=auto
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/PMFService.java (added)
+++ db/jdo/trunk/api/test/java/javax/jdo/PMFService.java Fri Jun 25 12:03:46 2010
@@ -0,0 +1,58 @@
+/*
+ * 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 javax.jdo;
+
+import java.util.Map;
+
+/**
+ * 
+ * <p>
+ */
+public class PMFService implements Constants{
+
+    public PMFService() {
+    }
+
+    public static PersistenceManagerFactory getPersistenceManagerFactory(
+            Map overrides, Map props) {
+        PersistenceManagerFactory pmf =
+                (PersistenceManagerFactory) PMFProxy.newInstance();
+        setPMFProperties(pmf, props, overrides);
+
+        return pmf;
+    }
+
+    public static PersistenceManagerFactory getPersistenceManagerFactory(
+            Map props) {
+        PersistenceManagerFactory pmf =
+                (PersistenceManagerFactory) PMFProxy.newInstance();
+        setPMFProperties(pmf, props, null);
+
+        return pmf;
+    }
+
+    private static void setPMFProperties(PersistenceManagerFactory pmf,
+            Map props, Map overrides) {
+
+        pmf.setConnectionDriverName((String)props.get(PROPERTY_CONNECTION_DRIVER_NAME));
+
+        if (overrides != null) {
+            pmf.setConnectionDriverName((String)overrides.get(PROPERTY_CONNECTION_DRIVER_NAME));
+        }
+    }
+}
+

Propchange: db/jdo/trunk/api/test/java/javax/jdo/PMFService.java
------------------------------------------------------------------------------
    svn:eol-style = LF