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 mc...@apache.org on 2010/06/20 04:54:02 UTC
svn commit: r956317 - in /db/jdo/trunk/api2: ./ test/java/javax/jdo/
test/schema/jdoconfig/Pmfmapmap01/
test/schema/jdoconfig/Pmfmapmap01/META-INF/
test/schema/jdoconfig/Pmfmapmap02/
Author: mcaisse
Date: Sun Jun 20 02:54:01 2010
New Revision: 956317
URL: http://svn.apache.org/viewvc?rev=956317&view=rev
Log:
JDO-557 - Tests for api's invocation of getPersistenceManager(Map) and getPersistenceManager(Map, Map). Also fixed an issue in JDOConfigTestClassLoader.java.
Added:
db/jdo/trunk/api2/test/java/javax/jdo/PMFMapMapTest.java
db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java
db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java
db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/
db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/
db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml
db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/
db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props
Modified:
db/jdo/trunk/api2/ (props changed)
db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java
Propchange: db/jdo/trunk/api2/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Jun 20 02:54:01 2010
@@ -1 +1,2 @@
target
+.maven.xml.swp
Modified: db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java?rev=956317&r1=956316&r2=956317&view=diff
==============================================================================
--- db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java (original)
+++ db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java Sun Jun 20 02:54:01 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/api2/test/java/javax/jdo/PMFMapMapTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/java/javax/jdo/PMFMapMapTest.java?rev=956317&view=auto
==============================================================================
--- db/jdo/trunk/api2/test/java/javax/jdo/PMFMapMapTest.java (added)
+++ db/jdo/trunk/api2/test/java/javax/jdo/PMFMapMapTest.java Sun Jun 20 02:54:01 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 + "\"");
+ }
+ }
+}
Added: db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java?rev=956317&view=auto
==============================================================================
--- db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java (added)
+++ db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java Sun Jun 20 02:54:01 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;
+ }
+}
+
Added: db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java?rev=956317&view=auto
==============================================================================
--- db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java (added)
+++ db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java Sun Jun 20 02:54:01 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));
+ }
+ }
+}
+
Added: db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml?rev=956317&view=auto
==============================================================================
--- db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml (added)
+++ db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml Sun Jun 20 02:54:01 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Do not change any values in this file without also making changes to
+ JDOHelperConfigTest.java, as that file depends on the values in this one!
+-->
+<jdoconfig
+ xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <!-- -->
+ <persistence-manager-factory
+ class="javax.jdo.PMFService">
+ <property
+ name="javax.jdo.option.ConnectionDriverName"
+ value="Jane Doe"/>
+ </persistence-manager-factory>
+
+ <persistence-manager-factory
+ name="BookSearch"
+ class="javax.jdo.PMFService">
+ <property
+ name="javax.jdo.option.ConnectionDriverName"
+ value="Larry"/>
+ </persistence-manager-factory>
+
+</jdoconfig>
+
+
Added: db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props?rev=956317&view=auto
==============================================================================
--- db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props (added)
+++ db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props Sun Jun 20 02:54:01 2010
@@ -0,0 +1,2 @@
+javax.jdo.PersistenceManagerFactoryClass javax.jdo.PMFService
+javax.jdo.option.ConnectionDriverName Jane Doe
Re: svn commit: r956317 - in /db/jdo/trunk/api2: ./ test/java/javax/jdo/
test/schema/jdoconfig/Pmfmapmap01/ test/schema/jdoconfig/Pmfmapmap01/META-INF/
test/schema/jdoconfig/Pmfmapmap02/
Posted by Michael Bouschen <mb...@spree.de>.
Hi Michelle,
should these changes go into the api subproject (instead of api2)?
I think having them in api2 does not hurt, so there is no need to
rollback the checkin. But we need them in api, since api defines the JDO
3 API classes and interfaces.
Regards Michael
> Author: mcaisse
> Date: Sun Jun 20 02:54:01 2010
> New Revision: 956317
>
> URL: http://svn.apache.org/viewvc?rev=956317&view=rev
> Log:
> JDO-557 - Tests for api's invocation of getPersistenceManager(Map) and getPersistenceManager(Map, Map). Also fixed an issue in JDOConfigTestClassLoader.java.
>
>
> Added:
> db/jdo/trunk/api2/test/java/javax/jdo/PMFMapMapTest.java
> db/jdo/trunk/api2/test/java/javax/jdo/PMFProxy.java
> db/jdo/trunk/api2/test/java/javax/jdo/PMFService.java
> db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/
> db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/
> db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml
> db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/
> db/jdo/trunk/api2/test/schema/jdoconfig/Pmfmapmap02/propsfile.props
> Modified:
> db/jdo/trunk/api2/ (props changed)
> db/jdo/trunk/api2/test/java/javax/jdo/JDOConfigTestClassLoader.java
>
> Propchange: db/jdo/trunk/api2/
> ------------------------------------------------------------------------------
> --- svn:ignore (original)
> +++ svn:ignore Sun Jun 20 02:54:01 2010
> @@ -1 +1,2 @@
> target
> +.maven.xml.swp
>
>
>
--
*Michael Bouschen*
*Prokurist*
akquinet tech@spree GmbH
Bülowstr. 66, D-10783 Berlin
Fon: +49 30 235 520-33
Fax: +49 30 217 520-12
Email: michael.bouschen@akquinet.de
Url: www.akquinet.de <http://www.akquinet.de>
akquinet tech@spree GmbH, Berlin
Geschäftsführung: Martin Weber, Prof. Dr. Christian Roth
Amtsgericht Berlin-Charlottenburg HRB 86780 B
USt.-Id. Nr.: DE 225 964 680