db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject svn commit: r1180967 [2/2] - in /db/jdo/trunk/api/test: java/javax/jdo/ java/javax/jdo/stub/ java/javax/jdo/util/ schema/jdoconfig/Negative09/9b/META-INF/services/ schema/jdoconfig/Pmfmapmap01/META-INF/ schema/jdoconfig/Pmfmapmap02/
Date Mon, 10 Oct 2011 13:51:01 GMT
Modified: 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=1180967&r1=1180966&r2=1180967&view=diff
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java (original)
+++ db/jdo/trunk/api/test/java/javax/jdo/PMFMapMapTest.java Mon Oct 10 13:51:00 2011
@@ -18,6 +18,7 @@ package javax.jdo;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.net.MalformedURLException;
 
 import javax.jdo.util.AbstractTest;
@@ -33,18 +34,18 @@ import javax.jdo.util.BatchTestRunner;
 /**
  * 
  * Tests class javax.jdo.JDOHelper for calls to the impl's static method
- *  getPersistenceManagerFactory(Map overrides, Map props).
+ * getPersistenceManagerFactory(Map overrides, Map props).
  * 
  */
-public class PMFMapMapTest extends AbstractTest implements Constants {
+public class PMFMapMapTest extends AbstractJDOConfigTest {
 
     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 resourceDir = "/Pmfmapmap01/";
+    static String propsDir = "/Pmfmapmap02/";
+    static String pmfServiceClass = "javax.jdo.stub.StubPMF";
     static String propertiesFile = "propsfile.props";
     PersistenceManagerFactory pmf;
     Properties props;
@@ -53,455 +54,427 @@ public class PMFMapMapTest extends Abstr
     ClassLoader saveContextClassLoader;
 
     public static void main(String args[]) {
-        BatchTestRunner.run(PMFMapMapTest.class);
+	BatchTestRunner.run(PMFMapMapTest.class);
     }
 
     /**
      * {@inheritDoc}
+     * 
      * @return {@inheritDoc}
      */
     public static TestSuite suite() {
-        return new TestSuite(PMFMapMapTest.class);
+	return new TestSuite(PMFMapMapTest.class);
     }
 
-    public void setup() {
-    }
+    void setupResourceClassLoader(String dir) throws IOException {
 
-    public void teardown() {
-    }
+	switch (dir.charAt(dir.length() - 1)) {
+	case '\\':
+	    dir = dir.substring(0, dir.length() - 1) + '/';
+	    break;
+	case '/':
+	    break;
+	default:
+	    if (new File(dir).isDirectory()) {
+		dir += '/';
+	    }
+	}
 
-    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();
-        }
+	resourceClassLoader = new JDOConfigTestClassLoader(getClass()
+		.getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + dir);
     }
 
-    /**
-     * A class path prefix used in the various tests where the class path
-     * needs to be set.
+    /*
+     * 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).
      */
-    protected static String JDOCONFIG_CLASSPATH_PREFIX = initJDOConfigClasspathPrefix();
+    public void testJDOConfigXML() throws IOException {
 
-    /**
-     * 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";
-    }
+	setupResourceClassLoader(resourceDir);
+	Thread.currentThread().setContextClassLoader(resourceClassLoader);
 
-    /**
-     * 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 + "\"");
-        }
+	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.
+     * 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);
+	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 + "\"");
-        }
+	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() throws IOException {
+
+	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() throws IOException {
+
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+	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() throws IOException {
+
+	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() throws IOException {
+
+	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() throws IOException {
+
+	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 + "\"");
+	}
     }
 }

Added: db/jdo/trunk/api/test/java/javax/jdo/stub/StubPMF.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/stub/StubPMF.java?rev=1180967&view=auto
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/stub/StubPMF.java (added)
+++ db/jdo/trunk/api/test/java/javax/jdo/stub/StubPMF.java Mon Oct 10 13:51:00 2011
@@ -0,0 +1,636 @@
+package javax.jdo.stub;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jdo.Constants;
+import javax.jdo.FetchGroup;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.datastore.DataStoreCache;
+import javax.jdo.listener.InstanceLifecycleListener;
+import javax.jdo.metadata.JDOMetadata;
+import javax.jdo.metadata.TypeMetadata;
+
+public class StubPMF implements PersistenceManagerFactory, Constants {
+
+    public static PersistenceManagerFactory getPersistenceManagerFactory(
+	    Map props) {
+	
+	StubPMF pmf = new StubPMF();
+
+	pmf.setProperties(props);
+	
+	for (Object key : props.keySet()) {
+	    if (!(key instanceof String)) {
+		continue;
+	    }
+	    String prop = (String) key;
+	    if (!prop.startsWith("javax.jdo.")) {
+		continue;
+	    }
+	    pmf.setProperty(prop, props.get(prop));
+	}
+
+	return pmf;
+    }
+
+    public static PersistenceManagerFactory getPersistenceManagerFactory(
+	    Map overrides, Map props) {
+	
+	StubPMF pmf = new StubPMF();
+	
+	pmf.setProperties(props);
+	pmf.setProperties(overrides);
+	
+	return pmf;
+    }
+
+    String name;
+    String persistenceManagerFactoryClassName;
+    String spiResourceName;
+    String optionConnectionUserName;
+    String optionConnectionPassword;
+    String optionConnectionURL;
+    String optionConnectionDriverName;
+    String optionConnectionFactoryName;
+    Object optionConnectionFactory;
+    String optionConnectionFactory2Name;
+    Object optionConnectionFactory2;
+    boolean optionMultithreaded;
+    String optionMapping;
+    boolean optionOptimistic;
+    boolean optionRetainValues;
+    boolean optionRestoreValues;
+    boolean optionNontransactionalRead;
+    boolean optionNontransactionalWrite;
+    boolean optionIgnoreCache;
+    boolean optionDetachAllOnCommit;
+    boolean optionCopyOnAttach;
+    String optionName;
+    String optionPersistenceUnitName;
+    String optionServerTimeZoneID;
+    String optionTransactionType;
+    boolean optionReadOnly;
+    String optionTransactionIsolationLevel;
+    Integer optionDatastoreReadTimeoutMillis;
+    Integer optionDatastoreWriteTimeoutMillis;
+
+    Properties properties = new Properties();
+
+    @Override
+    public String getConnectionUserName() {
+	return optionConnectionUserName;
+    }
+
+    @Override
+    public void setConnectionUserName(String connectionUserName) {
+	this.optionConnectionUserName = connectionUserName;
+    }
+
+    @Override
+    public void setConnectionPassword(String connectionPassword) {
+	this.optionConnectionPassword = connectionPassword;
+    }
+
+    @Override
+    public String getConnectionURL() {
+	return optionConnectionURL;
+    }
+
+    @Override
+    public void setConnectionURL(String connectionURL) {
+	this.optionConnectionURL = connectionURL;
+    }
+
+    @Override
+    public String getConnectionDriverName() {
+	return optionConnectionDriverName;
+    }
+
+    @Override
+    public void setConnectionDriverName(String connectionDriverName) {
+	this.optionConnectionDriverName = connectionDriverName;
+    }
+
+    @Override
+    public String getConnectionFactoryName() {
+	return optionConnectionFactoryName;
+    }
+
+    @Override
+    public void setConnectionFactoryName(String connectionFactoryName) {
+	this.optionConnectionFactoryName = connectionFactoryName;
+    }
+
+    @Override
+    public Object getConnectionFactory() {
+	return optionConnectionFactory;
+    }
+
+    @Override
+    public void setConnectionFactory(Object connectionFactory) {
+	this.optionConnectionFactory = connectionFactory;
+    }
+
+    @Override
+    public String getConnectionFactory2Name() {
+	return optionConnectionFactory2Name;
+    }
+
+    @Override
+    public void setConnectionFactory2Name(String connectionFactory2Name) {
+	this.optionConnectionFactory2Name = connectionFactory2Name;
+    }
+
+    @Override
+    public Object getConnectionFactory2() {
+	return optionConnectionFactory2;
+    }
+
+    @Override
+    public void setConnectionFactory2(Object connectionFactory2) {
+	this.optionConnectionFactory2 = connectionFactory2;
+    }
+
+    @Override
+    public boolean getMultithreaded() {
+	return optionMultithreaded;
+    }
+
+    @Override
+    public void setMultithreaded(boolean multithreaded) {
+	this.optionMultithreaded = multithreaded;
+    }
+
+    @Override
+    public String getMapping() {
+	return optionMapping;
+    }
+
+    @Override
+    public void setMapping(String mapping) {
+	this.optionMapping = mapping;
+    }
+
+    @Override
+    public boolean getOptimistic() {
+	return optionOptimistic;
+    }
+
+    @Override
+    public void setOptimistic(boolean optimistic) {
+	this.optionOptimistic = optimistic;
+    }
+
+    @Override
+    public boolean getRetainValues() {
+	return optionRetainValues;
+    }
+
+    @Override
+    public void setRetainValues(boolean retainValues) {
+	this.optionRetainValues = retainValues;
+    }
+
+    @Override
+    public boolean getRestoreValues() {
+	return optionRestoreValues;
+    }
+
+    @Override
+    public void setRestoreValues(boolean restoreValues) {
+	this.optionRestoreValues = restoreValues;
+    }
+
+    @Override
+    public boolean getNontransactionalRead() {
+	return optionNontransactionalRead;
+    }
+
+    @Override
+    public void setNontransactionalRead(boolean nontransactionalRead) {
+	this.optionNontransactionalRead = nontransactionalRead;
+    }
+
+    @Override
+    public boolean getNontransactionalWrite() {
+	return optionNontransactionalWrite;
+    }
+
+    @Override
+    public void setNontransactionalWrite(boolean nontransactionalWrite) {
+	this.optionNontransactionalWrite = nontransactionalWrite;
+    }
+
+    @Override
+    public boolean getIgnoreCache() {
+	return optionIgnoreCache;
+    }
+
+    @Override
+    public void setIgnoreCache(boolean ignoreCache) {
+	this.optionIgnoreCache = ignoreCache;
+    }
+
+    @Override
+    public boolean getDetachAllOnCommit() {
+	return optionDetachAllOnCommit;
+    }
+
+    @Override
+    public void setDetachAllOnCommit(boolean detachAllOnCommit) {
+	this.optionDetachAllOnCommit = detachAllOnCommit;
+    }
+
+    @Override
+    public boolean getCopyOnAttach() {
+	return optionCopyOnAttach;
+    }
+
+    @Override
+    public void setCopyOnAttach(boolean copyOnAttach) {
+	this.optionCopyOnAttach = copyOnAttach;
+    }
+
+    @Override
+    public String getName() {
+	return optionName;
+    }
+
+    @Override
+    public void setName(String name) {
+	this.optionName = name;
+    }
+
+    @Override
+    public String getPersistenceUnitName() {
+	return optionPersistenceUnitName;
+    }
+
+    @Override
+    public void setPersistenceUnitName(String persistenceUnitName) {
+	this.optionPersistenceUnitName = persistenceUnitName;
+    }
+
+    @Override
+    public String getServerTimeZoneID() {
+	return optionServerTimeZoneID;
+    }
+
+    @Override
+    public void setServerTimeZoneID(String serverTimeZoneID) {
+	this.optionServerTimeZoneID = serverTimeZoneID;
+    }
+
+    @Override
+    public String getTransactionType() {
+	return optionTransactionType;
+    }
+
+    @Override
+    public void setTransactionType(String transactionType) {
+	this.optionTransactionType = transactionType;
+    }
+
+    @Override
+    public boolean getReadOnly() {
+	return optionReadOnly;
+    }
+
+    @Override
+    public void setReadOnly(boolean readOnly) {
+	this.optionReadOnly = readOnly;
+    }
+
+    @Override
+    public String getTransactionIsolationLevel() {
+	return optionTransactionIsolationLevel;
+    }
+
+    @Override
+    public void setTransactionIsolationLevel(String transactionIsolationLevel) {
+	this.optionTransactionIsolationLevel = transactionIsolationLevel;
+    }
+
+    @Override
+    public Integer getDatastoreReadTimeoutMillis() {
+	return optionDatastoreReadTimeoutMillis;
+    }
+
+    @Override
+    public void setDatastoreReadTimeoutMillis(Integer datastoreReadTimeoutMillis) {
+	this.optionDatastoreReadTimeoutMillis = datastoreReadTimeoutMillis;
+    }
+
+    @Override
+    public Integer getDatastoreWriteTimeoutMillis() {
+	return optionDatastoreWriteTimeoutMillis;
+    }
+
+    @Override
+    public void setDatastoreWriteTimeoutMillis(
+	    Integer datastoreWriteTimeoutMillis) {
+	this.optionDatastoreWriteTimeoutMillis = datastoreWriteTimeoutMillis;
+    }
+
+    @Override
+    public void close() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public boolean isClosed() {
+	return true;
+    }
+
+    @Override
+    public PersistenceManager getPersistenceManager() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public PersistenceManager getPersistenceManagerProxy() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public PersistenceManager getPersistenceManager(String userid,
+	    String password) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public Properties getProperties() {
+	return properties;
+    }
+
+    @Override
+    public Collection<String> supportedOptions() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public DataStoreCache getDataStoreCache() {
+	return new DataStoreCache() {
+
+	    @Override
+	    public void evict(Object oid) {
+	    }
+
+	    @Override
+	    public void evictAll() {
+	    }
+
+	    @Override
+	    public void evictAll(Object... oids) {
+	    }
+
+	    @Override
+	    public void evictAll(Collection oids) {
+	    }
+
+	    @Override
+	    public void evictAll(Class pcClass, boolean subclasses) {
+	    }
+
+	    @Override
+	    public void evictAll(boolean subclasses, Class pcClass) {
+	    }
+
+	    @Override
+	    public void pin(Object oid) {
+	    }
+
+	    @Override
+	    public void pinAll(Collection oids) {
+	    }
+
+	    @Override
+	    public void pinAll(Object... oids) {
+	    }
+
+	    @Override
+	    public void pinAll(Class pcClass, boolean subclasses) {
+	    }
+
+	    @Override
+	    public void pinAll(boolean subclasses, Class pcClass) {
+	    }
+
+	    @Override
+	    public void unpin(Object oid) {
+	    }
+
+	    @Override
+	    public void unpinAll(Collection oids) {
+	    }
+
+	    @Override
+	    public void unpinAll(Object... oids) {
+	    }
+
+	    @Override
+	    public void unpinAll(Class pcClass, boolean subclasses) {
+	    }
+
+	    @Override
+	    public void unpinAll(boolean subclasses, Class pcClass) {
+	    }
+	};
+    }
+
+    @Override
+    public void addInstanceLifecycleListener(
+	    InstanceLifecycleListener listener, Class[] classes) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public void removeInstanceLifecycleListener(
+	    InstanceLifecycleListener listener) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public void addFetchGroups(FetchGroup... groups) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public void removeFetchGroups(FetchGroup... groups) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public void removeAllFetchGroups() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Override
+    public FetchGroup getFetchGroup(Class cls, String name) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Override
+    public Set getFetchGroups() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public void registerMetadata(JDOMetadata metadata) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public JDOMetadata newMetadata() {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    @Override
+    public TypeMetadata getMetadata(String className) {
+	throw new UnsupportedOperationException("not implemented");
+    }
+
+    void setSpiResourceName(String spiPropertiesResourceName) {
+	this.spiResourceName = spiPropertiesResourceName;
+    }
+    public String getSpiPropertiesResourceName() {
+	return spiResourceName;
+    }
+
+    void setPersistenceManagerFactoryClass(String className) {
+	this.persistenceManagerFactoryClassName = className;
+    }
+    public String getPersistenceManagerFactoryClass() {
+	return this.persistenceManagerFactoryClassName;
+    }
+
+    void setProperty(String name, Object value) {
+
+	String val = value.toString();
+
+	if (name.equals(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS)) {
+	    setPersistenceManagerFactoryClass(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_DRIVER_NAME)) {
+	    setConnectionDriverName(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_FACTORY_NAME)) {
+	    setConnectionFactoryName(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_FACTORY2_NAME)) {
+	    setConnectionFactory2Name(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_PASSWORD)) {
+	    setConnectionPassword(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_URL)) {
+	    setConnectionURL(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_CONNECTION_USER_NAME)) {
+	    setConnectionUserName(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_IGNORE_CACHE)) {
+	    setCopyOnAttach(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS)) {
+	    setDatastoreReadTimeoutMillis(Integer.parseInt(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS)) {
+	    setDatastoreWriteTimeoutMillis(Integer.parseInt(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_DETACH_ALL_ON_COMMIT)) {
+	    setDetachAllOnCommit(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_IGNORE_CACHE)) {
+	    setIgnoreCache(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_MAPPING)) {
+	    setMapping(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_MULTITHREADED)) {
+	    setMultithreaded(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_NAME)) {
+	    setName(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_NONTRANSACTIONAL_READ)) {
+	    setNontransactionalRead(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_NONTRANSACTIONAL_WRITE)) {
+	    setNontransactionalWrite(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_OPTIMISTIC)) {
+	    setOptimistic(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_PERSISTENCE_UNIT_NAME)) {
+	    setPersistenceUnitName(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_READONLY)) {
+	    setReadOnly(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_RESTORE_VALUES)) {
+	    setRestoreValues(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_RETAIN_VALUES)) {
+	    setRetainValues(Boolean.parseBoolean(val));
+	    return;
+	}
+	if (name.equals(PROPERTY_SERVER_TIME_ZONE_ID)) {
+	    setServerTimeZoneID(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_TRANSACTION_ISOLATION_LEVEL)) {
+	    setTransactionIsolationLevel(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_TRANSACTION_TYPE)) {
+	    setTransactionType(val);
+	    return;
+	}
+	if (name.equals(PROPERTY_SPI_RESOURCE_NAME)) {
+	    setSpiResourceName(val);
+	    return;
+	}
+	
+	throw new IllegalArgumentException("unhandled stub PMF property "
+		+ name);
+    }
+    
+    void setProperties(Map properties) {
+	for (Object key : properties.keySet()) {
+	    String k = key.toString();
+	    Object v = properties.get(key);
+	    
+	    this.properties.put(k, v);
+	    setProperty(k, v);
+	}
+	
+    }
+}

Propchange: db/jdo/trunk/api/test/java/javax/jdo/stub/StubPMF.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: db/jdo/trunk/api/test/java/javax/jdo/util/AbstractTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/java/javax/jdo/util/AbstractTest.java?rev=1180967&r1=1180966&r2=1180967&view=diff
==============================================================================
--- db/jdo/trunk/api/test/java/javax/jdo/util/AbstractTest.java (original)
+++ db/jdo/trunk/api/test/java/javax/jdo/util/AbstractTest.java Mon Oct 10 13:51:00 2011
@@ -19,10 +19,12 @@ package javax.jdo.util;
 
 import java.io.PrintStream;
 
+import javax.jdo.Constants;
+
 import junit.framework.TestCase;
 
 /** */
-public abstract class AbstractTest extends TestCase {
+public abstract class AbstractTest extends TestCase implements Constants {
 
     /** */
     protected static PrintStream out = System.out;

Modified: db/jdo/trunk/api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory?rev=1180967&r1=1180966&r2=1180967&view=diff
==============================================================================
--- db/jdo/trunk/api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory (original)
+++ db/jdo/trunk/api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory Mon Oct 10 13:51:00 2011
@@ -1 +1 @@
-javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException
+javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOFatalInternalException

Modified: db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml?rev=1180967&r1=1180966&r2=1180967&view=diff
==============================================================================
--- db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml (original)
+++ db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml Mon Oct 10 13:51:00 2011
@@ -10,7 +10,7 @@
 
     <!-- -->
     <persistence-manager-factory
-        class="javax.jdo.PMFService">
+        class="javax.jdo.stub.StubPMF">
         <property
             name="javax.jdo.option.ConnectionDriverName"
             value="Jane Doe"/>
@@ -18,7 +18,7 @@
 
     <persistence-manager-factory
         name="BookSearch"
-        class="javax.jdo.PMFService">
+        class="javax.jdo.stub.StubPMF">
         <property
             name="javax.jdo.option.ConnectionDriverName"
             value="Larry"/>

Modified: db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props?rev=1180967&r1=1180966&r2=1180967&view=diff
==============================================================================
--- db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props (original)
+++ db/jdo/trunk/api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props Mon Oct 10 13:51:00 2011
@@ -1,2 +1,2 @@
-javax.jdo.PersistenceManagerFactoryClass    javax.jdo.PMFService
+javax.jdo.PersistenceManagerFactoryClass    javax.jdo.stub.StubPMF
 javax.jdo.option.ConnectionDriverName       Jane Doe



Mime
View raw message