Index: api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml =================================================================== --- api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml (revision 1176468) +++ api/test/schema/jdoconfig/Pmfmapmap01/META-INF/jdoconfig.xml (working copy) @@ -10,7 +10,7 @@ + class="javax.jdo.stub.StubPMF"> @@ -18,7 +18,7 @@ + class="javax.jdo.stub.StubPMF"> Index: api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props =================================================================== --- api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props (revision 1176468) +++ api/test/schema/jdoconfig/Pmfmapmap02/propsfile.props (working copy) @@ -1,2 +1,2 @@ -javax.jdo.PersistenceManagerFactoryClass javax.jdo.PMFService +javax.jdo.PersistenceManagerFactoryClass javax.jdo.stub.StubPMF javax.jdo.option.ConnectionDriverName Jane Doe Index: api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory =================================================================== --- api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory (revision 1176468) +++ api/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory (working copy) @@ -1 +1 @@ -javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException +javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOFatalInternalException Index: api/test/java/javax/jdo/JDOHelperConfigTest.java =================================================================== --- api/test/java/javax/jdo/JDOHelperConfigTest.java (revision 1176468) +++ api/test/java/javax/jdo/JDOHelperConfigTest.java (working copy) @@ -17,754 +17,517 @@ package javax.jdo; -import junit.framework.TestSuite; - -import javax.jdo.util.AbstractTest; -import javax.jdo.util.BatchTestRunner; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.net.URLClassLoader; -import java.util.Enumeration; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Random; +import javax.jdo.util.BatchTestRunner; + +import junit.framework.TestSuite; + /** * * Tests class javax.jdo.JDOHelper for META-INF/jdoconfig.xml compliance. * */ -public class JDOHelperConfigTest extends AbstractTest implements Constants { +public class JDOHelperConfigTest extends AbstractJDOConfigTest implements + Constants { public static void main(String args[]) { - BatchTestRunner.run(JDOHelperConfigTest.class); + BatchTestRunner.run(JDOHelperConfigTest.class); } /** * {@inheritDoc} + * * @return {@inheritDoc} */ public static TestSuite suite() { - return new TestSuite(JDOHelperConfigTest.class); + return new TestSuite(JDOHelperConfigTest.class); } /** - * 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 (test/schema/jdoconfig). + * Builds up a {@link java.util.Map Map} object that contains key parameter + * values specific to a named test. All of the properties needed to run a + * particular test are loaded into this object. * - * @return the default class path prefix used by this test suite. + * @param testVariant + * the name of the test to include in the {@link java.util.Map + * Map} values. + * @param listenerCount + * the number of life cycle listener class names to add to this + * map. The listener names will begin with the value stored in + * {@link javax.jdo.Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER + * PROPERTY_INSTANCE_LIFECYCLE_LISTENER}. + * @param vendorSpecificPropertyCount + * the number of properties named of the form * - */ - protected static String initJDOConfigClasspathPrefix() { - return initBasedir() + "test/schema/jdoconfig"; - } - - /** - * The class path used to specify the location of test class files. - * @return the class path where test class files can be found. - */ - protected static String TEST_CLASSPATH = - initTestClasspath(); - - /** - * Returns the default class path for JDO test class files - * (target/test-classes/). - * @return the default class path for JDO test class files. - */ - protected static String initTestClasspath() { - return initBasedir() + "target/test-classes/"; - } - - /** - * The class path used to locate the JDO API class files. - */ - protected static String API_CLASSPATH = - initAPIClasspath(); - - /** - * Returns the default class path for JDO API class files - * (target/classes/). - * @return the default class path for JDO API class files. - */ - protected static String initAPIClasspath() { - return initBasedir() + "target/classes/"; - } - - /** - * 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 - * System.getProperty("basedir"). - * A trailing slash is appended to the path if it doesn't exist. + *
+     * "property." + testVariant + ".name"
+     * 
* - * @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; - } - - /** - * A radomizer seeded with the system clock's current time. - */ - protected static Random RANDOM = new Random(System.currentTimeMillis()); - - /** - * Builds up a {@link java.util.Map Map} object that contains key - * parameter values specific to a named test. All of the properties - * needed to run a particular test are loaded into this object. - * @param testVariant the name of the test to include in the - * {@link java.util.Map Map} values. - * @param listenerCount the number of life cycle listener class names to - * add to this map. The listener names will begin with the value - * stored in {@link - * javax.jdo.Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER - * PROPERTY_INSTANCE_LIFECYCLE_LISTENER}. - * @param vendorSpecificPropertyCount the number of properties named of - * the form
"property." + testVariant + ".name"
that - * are added to the map. - * @param excludeName if true the property specified by - * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is - * not added to the map. - * @param excludePUName if true the property specified by - * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME - * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. + * that are added to the map. + * @param excludeName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is not + * added to the map. + * @param excludePUName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME + * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. * @return a new {@link java.util.Map Map} object populated with properties * that can be used in this test suite. */ - protected Map prepareInitialExpectedMap( - String testVariant, - int listenerCount, - int vendorSpecificPropertyCount, - boolean excludeName, - boolean excludePUName - ) { - Map expected = new HashMap(); + protected Map prepareInitialExpectedMap(String testVariant, + int listenerCount, int vendorSpecificPropertyCount, + boolean excludeName, boolean excludePUName) { + Map expected = new HashMap(); - if (!excludeName) { - expected.put( - PROPERTY_NAME, - PMF_ATTRIBUTE_NAME + "." + testVariant); - } - if (!excludePUName) { - expected.put( - PROPERTY_PERSISTENCE_UNIT_NAME, - PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME + "." + testVariant); - } + if (!excludeName) { + expected.put(PROPERTY_NAME, PMF_ATTRIBUTE_NAME + "." + testVariant); + } + if (!excludePUName) { + expected.put(PROPERTY_PERSISTENCE_UNIT_NAME, + PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME + "." + testVariant); + } - expected.put(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, - PMF_ATTRIBUTE_CLASS + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_DRIVER_NAME, - PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_FACTORY_NAME, - PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_FACTORY2_NAME, - PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_PASSWORD, - PMF_ATTRIBUTE_CONNECTION_PASSWORD + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_URL, - PMF_ATTRIBUTE_CONNECTION_URL + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_USER_NAME, - PMF_ATTRIBUTE_CONNECTION_USER_NAME + "." + testVariant); - expected.put( - PROPERTY_IGNORE_CACHE, - PMF_ATTRIBUTE_IGNORE_CACHE + "." + testVariant); - expected.put( - PROPERTY_MAPPING, - PMF_ATTRIBUTE_MAPPING + "." + testVariant); - expected.put( - PROPERTY_MULTITHREADED, - PMF_ATTRIBUTE_MULTITHREADED + "." + testVariant); - expected.put( - PROPERTY_NONTRANSACTIONAL_READ, - PMF_ATTRIBUTE_NONTRANSACTIONAL_READ + "." + testVariant); - expected.put( - PROPERTY_NONTRANSACTIONAL_WRITE, - PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE + "." + testVariant); - expected.put( - PROPERTY_OPTIMISTIC, - PMF_ATTRIBUTE_OPTIMISTIC + "." + testVariant); - expected.put( - PROPERTY_RESTORE_VALUES, - PMF_ATTRIBUTE_RESTORE_VALUES + "." + testVariant); - expected.put( - PROPERTY_RETAIN_VALUES, - PMF_ATTRIBUTE_RETAIN_VALUES + "." + testVariant); - expected.put( - PROPERTY_DETACH_ALL_ON_COMMIT, - PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT + "." + testVariant); - expected.put( - PROPERTY_SERVER_TIME_ZONE_ID, - PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID + "." + testVariant); + expected.put(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, + PMF_ATTRIBUTE_CLASS + "." + testVariant); + expected.put(PROPERTY_CONNECTION_DRIVER_NAME, + PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_FACTORY_NAME, + PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_FACTORY2_NAME, + PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_PASSWORD, + PMF_ATTRIBUTE_CONNECTION_PASSWORD + "." + testVariant); + expected.put(PROPERTY_CONNECTION_URL, PMF_ATTRIBUTE_CONNECTION_URL + + "." + testVariant); + expected.put(PROPERTY_CONNECTION_USER_NAME, + PMF_ATTRIBUTE_CONNECTION_USER_NAME + "." + testVariant); + expected.put(PROPERTY_IGNORE_CACHE, PMF_ATTRIBUTE_IGNORE_CACHE + "." + + testVariant); + expected.put(PROPERTY_MAPPING, PMF_ATTRIBUTE_MAPPING + "." + + testVariant); + expected.put(PROPERTY_MULTITHREADED, PMF_ATTRIBUTE_MULTITHREADED + "." + + testVariant); + expected.put(PROPERTY_NONTRANSACTIONAL_READ, + PMF_ATTRIBUTE_NONTRANSACTIONAL_READ + "." + testVariant); + expected.put(PROPERTY_NONTRANSACTIONAL_WRITE, + PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE + "." + testVariant); + expected.put(PROPERTY_OPTIMISTIC, PMF_ATTRIBUTE_OPTIMISTIC + "." + + testVariant); + expected.put(PROPERTY_RESTORE_VALUES, PMF_ATTRIBUTE_RESTORE_VALUES + + "." + testVariant); + expected.put(PROPERTY_RETAIN_VALUES, PMF_ATTRIBUTE_RETAIN_VALUES + "." + + testVariant); + expected.put(PROPERTY_DETACH_ALL_ON_COMMIT, + PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT + "." + testVariant); + expected.put(PROPERTY_SERVER_TIME_ZONE_ID, + PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID + "." + testVariant); - // listeners - for (int i = 0; i < listenerCount; i++) { - expected.put( - PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + - "listener." + testVariant + ".listener" + i, - "classes." + testVariant + ".classes" + i - ); - } + // listeners + for (int i = 0; i < listenerCount; i++) { + expected.put(PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + + "listener." + testVariant + ".listener" + i, "classes." + + testVariant + ".classes" + i); + } - // vendor-specific properties - for (int i = 0; i < vendorSpecificPropertyCount; i++) { - expected.put( - "property." + testVariant + ".name" + i, - "property." + testVariant + ".value" + i - ); - } + // vendor-specific properties + for (int i = 0; i < vendorSpecificPropertyCount; i++) { + expected.put("property." + testVariant + ".name" + i, "property." + + testVariant + ".value" + i); + } - return expected; + return expected; } /** - * Fails the test if the number of properties in the two specified - * {@link java.util.Map Map} objects are not identical or their values - * do not match. - * @param expected the first {@link java.util.Map Map} object to test. - * @param actual the second {@link java.util.Map Map} object to test. - */ - static void assertEqualProperties(Map expected, Map actual) { - Iterator i = expected.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - String key = (String) entry.getKey(); - String expectedValue = (String) entry.getValue(); - String actualValue = (String) actual.get(key); - - assertEquals( - "Actual property at key [" + key + "] with value [" + - actualValue + "] not equal to expected value [" + - expectedValue + "]", - expectedValue, - actualValue); - } - } - - /** - * Performs a test specified by testVariantName, by building - * up a property map and executing the test according to the property - * values. With this version of doPositiveTest the property - * name ({@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) and - * the {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME - * PERSISTENCE_UNIT_NAME}) are included in the property map that is used - * to run the test. + * Performs a test specified by testVariantName, by building up a + * property map and executing the test according to the property values. + * With this version of doPositiveTest the property name ( + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) and the + * {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME PERSISTENCE_UNIT_NAME}) + * are included in the property map that is used to run the test. * - * @param classpaths class paths to add to the class loader that runs the - * test that specify where jdoconfig.xml can be found. - * @param testVariantName the name of the test. - * @param listenerCount number of listeners utilized in the test. - * @param vendorSpecificPropertyCount number of vendor properties used - * in the test. - * @param checkEqualProperties if true the test's properties are tested. - * @throws java.io.IOException if an {@java.io.IOException IOException} - * occurs during class loading or any part of the test. + * @param classpaths + * class paths to add to the class loader that runs the test that + * specify where jdoconfig.xml can be found. + * @param testVariantName + * the name of the test. + * @param listenerCount + * number of listeners utilized in the test. + * @param vendorSpecificPropertyCount + * number of vendor properties used in the test. + * @param checkEqualProperties + * if true the test's properties are tested. + * @throws java.io.IOException + * if an {@java.io.IOException + * IOException} occurs during class loading or any part of the + * test. */ - protected void doPositiveTest( - String[] classpaths, - String testVariantName, - int listenerCount, - int vendorSpecificPropertyCount, - boolean checkEqualProperties) - throws IOException { + protected void doPositiveTest(String[] classpaths, String testVariantName, + int listenerCount, int vendorSpecificPropertyCount, + boolean checkEqualProperties) throws IOException { - doPositiveTest( - classpaths, - testVariantName, - listenerCount, - vendorSpecificPropertyCount, - checkEqualProperties, - false, - false); + doPositiveTest(classpaths, testVariantName, listenerCount, + vendorSpecificPropertyCount, checkEqualProperties, false, false); } /** - * Performs a test specified by testVariantName, by building - * up a property map and executing the test according to the property - * values. An assertion exeception is thrown if the test being run - * has a negative (non-true) result. With this version of - * doPositiveTest the property - * name ({@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) and - * the {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME - * PERSISTENCE_UNIT_NAME}) are included in the property map that is used - * to run the test. + * Performs a test specified by testVariantName, by building up a + * property map and executing the test according to the property values. An + * assertion exeception is thrown if the test being run has a negative + * (non-true) result. With this version of doPositiveTest the + * property name ({@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) + * and the {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME + * PERSISTENCE_UNIT_NAME}) are included in the property map that is used to + * run the test. * - * @param classpaths class paths to add to the class loader that runs the - * test that specify where jdoconfig.xml can be found. - * @param testVariantName the name of the test. - * @param listenerCount number of listeners utilized in the test. - * @param vendorSpecificPropertyCount number of vendor properties used - * in the test. - * @param checkEqualProperties if true the test's properties are tested. - * @param excludeName if true the property specified by - * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is - * not added to the map. - * @param excludePUName if true the property specified by - * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME - * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. - * @throws java.io.IOException if an {@java.io.IOException IOException} - * occurs during class loading or any part of the test. + * @param classpaths + * class paths to add to the class loader that runs the test that + * specify where jdoconfig.xml can be found. + * @param testVariantName + * the name of the test. + * @param listenerCount + * number of listeners utilized in the test. + * @param vendorSpecificPropertyCount + * number of vendor properties used in the test. + * @param checkEqualProperties + * if true the test's properties are tested. + * @param excludeName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is not + * added to the map. + * @param excludePUName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME + * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. + * @throws java.io.IOException + * if an {@java.io.IOException + * IOException} occurs during class loading or any part of the + * test. */ - protected void doPositiveTest( - String[] classpaths, - String testVariantName, - int listenerCount, - int vendorSpecificPropertyCount, - boolean checkEqualProperties, - boolean excludeName, - boolean excludePUName) - throws IOException { + protected void doPositiveTest(String[] classpaths, String testVariantName, + int listenerCount, int vendorSpecificPropertyCount, + boolean checkEqualProperties, boolean excludeName, + boolean excludePUName) throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), classpaths); - for (int i = 0; i < classpaths.length; i++) { - ClasspathHelper.addFile(classpaths[i], loader); - } + Map expected = prepareInitialExpectedMap(testVariantName, + listenerCount, vendorSpecificPropertyCount, excludeName, + excludePUName); - Map expected = prepareInitialExpectedMap( - testVariantName, - listenerCount, - vendorSpecificPropertyCount, - excludeName, - excludePUName); - - String name = testVariantName == null - ? null - : (String) expected.get(PROPERTY_NAME); + String name = testVariantName == null ? null : (String) expected + .get(PROPERTY_NAME); - Map actual = JDOHelper.getPropertiesFromJdoconfig(name, loader); + Map actual = JDOHelper.getPropertiesFromJdoconfig(name, loader); - assertNotNull("No properties found", actual); - if (checkEqualProperties) { - assertEqualProperties(expected, actual); - } + assertNotNull("No properties found", actual); + if (checkEqualProperties) { + assertEqualProperties(expected, actual); + } } public void testPositive00_PMF0_BasicPMFConfigUsingOnlyStandardAttributesAndListeners() - throws IOException { - doPositiveTest( - new String[]{JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, - "positive00.pmf0", - 2, - 0, - true); + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + + "/Positive00" }, "positive00.pmf0", 2, 0, true); } public void testPositive00_PMF1_BasicPMFConfigUsingOnlyPropertyElementsWithStandardJavaxDotJDOProperties() - throws IOException { - doPositiveTest( - new String[]{JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, - "positive00.pmf1", - 2, - 0, - true); + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + + "/Positive00" }, "positive00.pmf1", 2, 0, true); } public void testPositive00_PMF2_NestedPropertyElementsWithOnlyStandardAttributeNames() - throws IOException { - doPositiveTest( - new String[]{JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, - "positive00.pmf2", - 2, - 0, - true); + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + + "/Positive00" }, "positive00.pmf2", 2, 0, true); } public void testPositive00_PMF3_StandardAttributesPlusNonstandardPropertiesInPropertyElements() - throws IOException { - doPositiveTest( - new String[]{JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, - "positive00.pmf3", - 2, - 2, - true); + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + + "/Positive00" }, "positive00.pmf3", 2, 2, true); } public void testPositive00_PMF4_StandardAttributesPlusNonstandardAttributes() - throws IOException { - doPositiveTest( - new String[]{JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, - "positive00.pmf4", - 0, - 2, - true); + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + + "/Positive00" }, "positive00.pmf4", 0, 2, true); } public void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); + String[] classpaths = new String[] { + JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1a", + JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1b" }; + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), classpaths); - String[] classpaths = new String[]{ - JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1a", - JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1b" - }; - for (int i = 0; i < classpaths.length; i++) { - ClasspathHelper.addFile(classpaths[i], loader); - } - - Map actual = JDOHelper.getPropertiesFromJdoconfig( - ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); } public void testPositive02_GetAnonymousPMFWithNoProperties() - throws IOException { - - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); + throws IOException { - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Positive02", loader); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive02/"); - Map properties = JDOHelper.getPropertiesFromJdoconfig( - ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - assertNotNull( - "Anonymous PMF with no properties returned null", properties); - assertTrue( - "Anonymous PMF with no properties had properties", - properties.size() == 0); + Map properties = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); + assertNotNull("Anonymous PMF with no properties returned null", + properties); + assertTrue("Anonymous PMF with no properties had properties", + properties.size() == 0); } public void testPositive03_PMF0_PMFClassNameViaServicesLookup() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile(JDOCONFIG_CLASSPATH_PREFIX + "/Positive03", loader); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive03/"); - String expected = "class.positive03.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); + String expected = "class.positive03.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); } public void testPositive04_PMF0_PMFClassNameViaServicesLookup() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile(JDOCONFIG_CLASSPATH_PREFIX + "/Positive04", loader); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive04/"); - String expected = "class.positive04.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); + String expected = "class.positive04.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); } public void testPositive05_PMF0_PMFClassNameViaServicesLookup() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Positive05", loader); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive05/"); - String expected = "class.positive05.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); + String expected = "class.positive05.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); } public void testPositive06_PMF0_GetAnonymousPMFProperties() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive06/"); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Positive06", loader); + Map expected = prepareInitialExpectedMap("positive06.pmf0", 2, 0, true, + true); - Map expected = prepareInitialExpectedMap( - "positive06.pmf0", 2, 0, true, true); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - Map actual = JDOHelper.getPropertiesFromJdoconfig( - ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - - assertNotNull("No properties found", actual); - assertEqualProperties(expected, actual); + assertNotNull("No properties found", actual); + assertEqualProperties(expected, actual); } public void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() - throws IOException { + throws IOException { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive07/"); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Positive07", loader); + Map expected = prepareInitialExpectedMap("positive07.pmf0", 2, 0, true, + false); - Map expected = prepareInitialExpectedMap( - "positive07.pmf0", 2, 0, true, false); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - Map actual = JDOHelper.getPropertiesFromJdoconfig( - ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - - assertNotNull("No properties found", actual); - assertEqualProperties(expected, actual); + assertNotNull("No properties found", actual); + assertEqualProperties(expected, actual); } public void testNegative00_EmptyJDOConfigXML() throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative0", loader); + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative0/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // sunny day - } + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // sunny day + } } public void testNegative01_NoPersistenceUnitsDefined() throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative01", loader); + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative01/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // joy, sweet joy - } + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // joy, sweet joy + } } public void testNegative02_DuplicateAnonymousPersistenceUnitsInSameConfig() - throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative02", loader); + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative02/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // the cockles of my heart warmeth - } + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // the cockles of my heart warmeth + } } public void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() - throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative03", loader); + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative03/"); - JDOHelper.getPersistenceManagerFactory( - "name.negative03", - loader); + JDOHelper.getPersistenceManagerFactory("name.negative03", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // warm fuzzies - } + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // warm fuzzies + } } public void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() - throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative04", loader); + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative04/"); - JDOHelper.getPersistenceManagerFactory( - "name.negative04.value0", - loader); + JDOHelper.getPersistenceManagerFactory("name.negative04.value0", + loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // no cold pricklies - } + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // no cold pricklies + } } public void testNegative05_DuplicatePropertyInAttributeAndElement() - throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative05", loader); + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative05/"); - JDOHelper.getPersistenceManagerFactory(loader); + JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // party! - } + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // party! + } } public void testNegative06_DuplicatePUInDifferentConfigFiles() - throws IOException { - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a", loader); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b", loader); + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative06/6a/", JDOCONFIG_CLASSPATH_PREFIX + + "/Negative06/6b/"); - JDOHelper.getPersistenceManagerFactory( - "name.negative06", - loader); + JDOHelper.getPersistenceManagerFactory("name.negative06", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // clear blue sky - } + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // clear blue sky + } } - - public void testNegative07_EmptyServicesFile() - throws IOException { - JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( - new String[]{JDOCONFIG_CLASSPATH_PREFIX}, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative07", testLoader); - String shouldBeNull = - getPMFClassNameViaServiceLookup(testLoader); - assertNull(shouldBeNull); + public void testNegative07_EmptyServicesFile() throws IOException { + JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative07/"); + String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); + assertNull(shouldBeNull); } public void testNegative08_NoResourcesFound() { - String resource = "" + RANDOM.nextLong(); + String resource = "" + RANDOM.nextLong(); - InputStream in = - getClass().getClassLoader().getResourceAsStream(resource); - assertNull(in); + InputStream in = getClass().getClassLoader().getResourceAsStream( + resource); + assertNull(in); - // resource pretty much guaranteed not to exist - try { - JDOHelper.getPersistenceManagerFactory(resource); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalUserException x) { - // happy path - } + // resource pretty much guaranteed not to exist + try { + JDOHelper.getPersistenceManagerFactory(resource); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // happy path + } } public void testNegative08_ServicesFileWithOnlyComments() - throws IOException { - JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( - new String[]{JDOCONFIG_CLASSPATH_PREFIX}, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative08", testLoader); - String shouldBeNull = - getPMFClassNameViaServiceLookup(testLoader); - assertNull(shouldBeNull); + throws IOException { + JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative08/"); + String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); + assertNull(shouldBeNull); } - + public void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() - throws IOException { + throws IOException { - // no class name in Negative09/jdoconfig.xml - // 9a and 9b include services/javax.jdo.PersistenceManagerFactory - // with bad implementations - try { - URLClassLoader loader = new JDOConfigTestClassLoader( - JDOCONFIG_CLASSPATH_PREFIX, - getClass().getClassLoader()); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9a", loader); - ClasspathHelper.addFile( - JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9b", loader); - ClasspathHelper.addFile( - TEST_CLASSPATH, loader); - ClasspathHelper.addFile( - API_CLASSPATH, loader); + // no class name in Negative09/jdoconfig.xml + // 9a and 9b include services/javax.jdo.PersistenceManagerFactory + // with bad implementations + try { + URLClassLoader loader = new JDOConfigTestClassLoader(getClass() + .getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + + "/Negative09/9a/", JDOCONFIG_CLASSPATH_PREFIX + + "/Negative09/9b/", TEST_CLASSPATH, API_CLASSPATH); - JDOHelper.getPersistenceManagerFactory("name.negative09", loader); + JDOHelper.getPersistenceManagerFactory("name.negative09", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } - catch (JDOFatalException x) { + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalException x) { - Throwable[] nestedExceptions = x.getNestedExceptions(); - if (nestedExceptions.length != 2) { - appendMessage( - "JDOHelper.getPersistenceManagerFactory wrong number of " + - "nested exceptions. Expected 2, got " + nestedExceptions.length + - "\n" + x); - } - for (int i = 0; i < nestedExceptions.length; ++i) { - Throwable exception = nestedExceptions[i]; - if (!(exception instanceof JDOFatalException)) { - appendMessage("Nested exception " + - exception.getClass().getName() + - " is not a JDOFatalException."); - } - } - } - failOnError(); + Throwable[] nestedExceptions = x.getNestedExceptions(); + if (nestedExceptions.length != 2) { + appendMessage("JDOHelper.getPersistenceManagerFactory wrong number of " + + "nested exceptions. Expected 2, got " + + nestedExceptions.length + "\n" + x); + } + for (int i = 0; i < nestedExceptions.length; ++i) { + Throwable exception = nestedExceptions[i]; + if (!(exception instanceof JDOFatalException)) { + appendMessage("Nested exception " + + exception.getClass().getName() + + " is not a JDOFatalException."); + } + } + } + failOnError(); } - - private String getPMFClassNameViaServiceLookup(ClassLoader loader) { - try { - Enumeration urls = JDOHelper.getResources(loader, - SERVICE_LOOKUP_PMF_RESOURCE_NAME); - while (urls.hasMoreElements()) { - // return the first one found - return JDOHelper.getClassNameFromURL((URL)urls.nextElement()); - } - } catch (Exception ex) { - // ignore exceptions from i/o errors - } - return null; - } } Index: api/test/java/javax/jdo/JDOHelperTest.java =================================================================== --- api/test/java/javax/jdo/JDOHelperTest.java (revision 1176468) +++ api/test/java/javax/jdo/JDOHelperTest.java (working copy) @@ -601,6 +601,14 @@ } } + public static class BadPMFGetPMFMethodThrowsJDOFatalInternalException { + public static PersistenceManagerFactory + getPersistenceManagerFactory(Map props) { + throw new JDOFatalInternalException( + "GetPMF method throws JDOFatalInternalException"); + } + } + public static class BadPMFGetPMFMethodReturnsNull { public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { Index: api/test/java/javax/jdo/PMFMapMapTest.java =================================================================== --- api/test/java/javax/jdo/PMFMapMapTest.java (revision 1176468) +++ api/test/java/javax/jdo/PMFMapMapTest.java (working copy) @@ -18,6 +18,7 @@ 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 @@ /** * * 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 @@ 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 (test/schema/jdoconfig). - * - * @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 - * System.getProperty("basedir"). - * 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; - } + try { + pmf = JDOHelper.getPersistenceManagerFactory(); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + + ex.getMessage()); + } - /* 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 + "\""); - } + 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()); - } + 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 + "\""); - } + 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. + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.io.File propsFile) Returns a PersistenceManagerFactory configured + * based on the properties stored in the file at propsFile. */ - public void testPropsFile() { + public void testPropsFile() throws IOException { - setupResourceClassLoader(propsDir); - Thread.currentThread().setContextClassLoader(resourceClassLoader); + setupResourceClassLoader(propsDir); + Thread.currentThread().setContextClassLoader(resourceClassLoader); - try { - pmf = JDOHelper.getPersistenceManagerFactory(propertiesFile); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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() { + public void testPropsFileAndLoader() throws IOException { - setupResourceClassLoader(propsDir); + setupResourceClassLoader(propsDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(propertiesFile, - resourceClassLoader); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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); + 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()); + 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); + setupResourceClassLoader(resourceDir); + Thread.currentThread().setContextClassLoader(resourceClassLoader); - try { - pmf = JDOHelper.getPersistenceManagerFactory(byteArrayInputStream); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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); + 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()); + ByteArrayOutputStream outstream = new ByteArrayOutputStream(); + try { + props.store(outstream, ""); + } catch (IOException ex) { + fail(ex.getMessage()); + } + InputStream byteArrayInputStream = new ByteArrayInputStream( + outstream.toByteArray()); - setupResourceClassLoader(resourceDir); + setupResourceClassLoader(resourceDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(byteArrayInputStream, - resourceClassLoader); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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); + 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()); - } + 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 + "\""); - } + 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. + * 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); + 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()); - } + 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 + "\""); - } + 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. + * 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); + public void testNamedPMFWithOverrides() throws IOException { + overrides = new Properties(); + overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME, + expectedDriverNameWithOverrides); - setupResourceClassLoader(resourceDir); - Thread.currentThread().setContextClassLoader(resourceClassLoader); + setupResourceClassLoader(resourceDir); + Thread.currentThread().setContextClassLoader(resourceClassLoader); - try { - pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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); + public void testNamedPMFWithOverridesAndLoader() throws IOException { + overrides = new Properties(); + overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME, + expectedDriverNameWithOverrides); - setupResourceClassLoader(resourceDir); + setupResourceClassLoader(resourceDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName, - resourceClassLoader); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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); + public void testNamedPMFWithOverridesAndTwoLoaders() throws IOException { + overrides = new Properties(); + overrides.setProperty(PROPERTY_CONNECTION_DRIVER_NAME, + expectedDriverNameWithOverrides); - setupResourceClassLoader(resourceDir); + setupResourceClassLoader(resourceDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMFName, - resourceClassLoader, - Thread.currentThread().getContextClassLoader()); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); - } + 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 + "\""); - } + 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. + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.lang.String name) Returns a named PersistenceManagerFactory or + * persistence unit. */ - public void testNamedPMF() { + public void testNamedPMF() throws IOException { - setupResourceClassLoader(resourceDir); - Thread.currentThread().setContextClassLoader(resourceClassLoader); + setupResourceClassLoader(resourceDir); + Thread.currentThread().setContextClassLoader(resourceClassLoader); - try { - pmf = JDOHelper.getPersistenceManagerFactory(PMFName); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); - } + 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 + "\""); - } + 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. + * static PersistenceManagerFactory getPersistenceManagerFactory + * (java.lang.String name, java.lang.ClassLoader loader) Returns a named + * PersistenceManagerFactory or persistence unit. */ - public void testNamedPMFWithLoader() { + public void testNamedPMFWithLoader() throws IOException { - setupResourceClassLoader(resourceDir); + setupResourceClassLoader(resourceDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(PMFName, - resourceClassLoader); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); - } + 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 + "\""); - } + 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. + * 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() { + public void testNamedPMFWithTwoLoaders() throws IOException { - setupResourceClassLoader(resourceDir); + setupResourceClassLoader(resourceDir); - try { - pmf = JDOHelper.getPersistenceManagerFactory(PMFName, - resourceClassLoader, - Thread.currentThread().getContextClassLoader()); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); - } + 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 + "\""); - } + String driverName = pmf.getConnectionDriverName(); + if (!expectedDriverName4NamedPMF.equals(driverName)) { + fail("Bad ConnectionDriverName(): " + driverName + + ". Expected: \"" + expectedDriverName4NamedPMF + "\""); + } } } Index: api/test/java/javax/jdo/JDOConfigTestClassLoader.java =================================================================== --- api/test/java/javax/jdo/JDOConfigTestClassLoader.java (revision 1176468) +++ api/test/java/javax/jdo/JDOConfigTestClassLoader.java (working copy) @@ -1,100 +1,43 @@ package javax.jdo; -import org.apache.tools.ant.AntClassLoader; - +import java.io.File; +import java.io.IOException; 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; -import java.util.Iterator; /** - * A class loader used to ensure that classpath URLs added in JUnit tests - * aren't included in subsequent JUnit tests. + * A class loader that allows the user to add classpath entries. */ public class JDOConfigTestClassLoader extends URLClassLoader { - public JDOConfigTestClassLoader( - String partialPathToIgnore, - ClassLoader unparent - ) { - this(new String[]{partialPathToIgnore}, unparent); + /** + * Uses the CTCCL as the parent and adds the given path to this loader's classpath. + */ + public JDOConfigTestClassLoader(String... additionalPath) throws IOException { + this(Thread.currentThread().getContextClassLoader(), additionalPath); } + + /** + * Uses the given ClassLoader as the parent & adds the given paths to this loader's classpath. + */ + public JDOConfigTestClassLoader(ClassLoader parent, String... additionalPaths) throws IOException { + super(new URL[] {}, parent); - public JDOConfigTestClassLoader( - String[] partialPathsToIgnore, - ClassLoader unparent - ) { - super(new URL[]{}, null); - - if (unparent instanceof URLClassLoader) { - addNonTestURLs( - partialPathsToIgnore == null - ? new String[]{} - : partialPathsToIgnore, - (URLClassLoader) unparent); - } - else if (unparent instanceof AntClassLoader) { - addNonTestURLs( - partialPathsToIgnore == null - ? new String[]{} - : partialPathsToIgnore, - (AntClassLoader) unparent); - } - else { - throw new RuntimeException( - "unknown ClassLoader type: " - + unparent.getClass().getName()); - } + for (String path : additionalPaths) { + addFile(path); + } } - // HACK: need to identify a better way of controlling test classpath - protected void addNonTestURLs( - String[] partialPathsToIgnore, - URLClassLoader unparent - ) { - URL[] urls = unparent.getURLs(); - for (int i = 0; i < urls.length; i++) { - URL url = urls[i]; - String urlString = url.toString(); - for (int j = 0; j < partialPathsToIgnore.length; j++) { - if (urlString.indexOf(partialPathsToIgnore[j]) == -1) { - addURL(url); - } - } - } + public void addFile(String s) throws IOException { + addFile(new File(s)); } - protected void addNonTestURLs( - String[] partialPathsToIgnore, - AntClassLoader unparent - ) { - List elements = new ArrayList(); - String classpath = unparent.getClasspath(); - StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator); - while (st.hasMoreTokens()) { - String nextToken = st.nextToken(); - if(!nextToken.endsWith(".jar")) { - nextToken = nextToken.concat(File.separator); - } - elements.add("file://" + nextToken); - } - Iterator i = elements.iterator(); - while (i.hasNext()) { - String element = i.next(); - for (int j = 0; j < partialPathsToIgnore.length; j++) { - if (element.indexOf(partialPathsToIgnore[j]) == -1) { - try { - addURL(new URL(element)); - } - catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } - } + public void addFile(File f) throws IOException { + addURL(f.toURI().toURL()); } + + @Override + public void addURL(URL url) { + super.addURL(url); + } } Index: api/test/java/javax/jdo/ClasspathHelper.java =================================================================== --- api/test/java/javax/jdo/ClasspathHelper.java (revision 1163308) +++ api/test/java/javax/jdo/ClasspathHelper.java (working copy) @@ -1,73 +0,0 @@ -/* - * 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.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; - -public class ClasspathHelper { - - private static URLClassLoader SYSTEM_CLASSLOADER = (URLClassLoader) ClassLoader.getSystemClassLoader(); - private static Method METHOD; - static { - try { - METHOD = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class }); - METHOD.setAccessible(true); - } - catch (Throwable t) { - throw new RuntimeException(t); - } - } - - public static void addFile(String s) throws IOException { - addFile(s, null); - } - - public static void addFile(File f) throws IOException { - addFile(f, null); - } - - public static void addURL(URL u) throws IOException { - addURL(u, null); - } - - public static void addFile(String s, URLClassLoader loader) throws IOException { - addFile(new File(s), loader); - } - - public static void addFile(File f, URLClassLoader loader) throws IOException { - addURL(f.toURL(), loader); - } - - public static void addURL(URL u, URLClassLoader loader) throws IOException { - if (loader == null) { - loader = SYSTEM_CLASSLOADER; - } - try { - METHOD.invoke(loader, new Object[] { u }); - } - catch (Throwable t) { - throw new IOException("Could not add URL to system classloader: " + t.getMessage()); - } - } -} - - Index: api/test/java/javax/jdo/AbstractJDOConfigTest.java =================================================================== --- api/test/java/javax/jdo/AbstractJDOConfigTest.java (revision 0) +++ api/test/java/javax/jdo/AbstractJDOConfigTest.java (revision 0) @@ -0,0 +1,126 @@ +package javax.jdo; + +import java.net.URL; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Map; +import java.util.Random; + +import javax.jdo.util.AbstractTest; + +public abstract class AbstractJDOConfigTest extends AbstractTest { + + /** + * 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 (test/schema/jdoconfig). + * + * @return the default class path prefix used by this test suite. + * + */ + protected static String initJDOConfigClasspathPrefix() { + return initBasedir() + "test/schema/jdoconfig"; + } + + /** + * The class path used to specify the location of test class files. + * @return the class path where test class files can be found. + */ + protected static String TEST_CLASSPATH = + initTestClasspath(); + + /** + * Returns the default class path for JDO test class files + * (target/test-classes/). + * @return the default class path for JDO test class files. + */ + protected static String initTestClasspath() { + return initBasedir() + "target/test-classes/"; + } + + /** + * The class path used to locate the JDO API class files. + */ + protected static String API_CLASSPATH = + initAPIClasspath(); + + /** + * Returns the default class path for JDO API class files + * (target/classes/). + * @return the default class path for JDO API class files. + */ + protected static String initAPIClasspath() { + return initBasedir() + "target/classes/"; + } + + /** + * 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 + * System.getProperty("basedir"). + * 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; + } + + /** + * A randomizer seeded with the system clock's current time. + */ + protected static Random RANDOM = new Random(System.currentTimeMillis()); + + /** + * Fails the test if the number of properties in the two specified + * {@link java.util.Map Map} objects are not identical or their values + * do not match. + * @param expected the first {@link java.util.Map Map} object to test. + * @param actual the second {@link java.util.Map Map} object to test. + */ + static void assertEqualProperties(Map expected, Map actual) { + Iterator i = expected.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + String key = (String) entry.getKey(); + String expectedValue = (String) entry.getValue(); + String actualValue = (String) actual.get(key); + + assertEquals( + "Actual property at key [" + key + "] with value [" + + actualValue + "] not equal to expected value [" + + expectedValue + "]", + expectedValue, + actualValue); + } + } + + protected String getPMFClassNameViaServiceLookup(ClassLoader loader) { + try { + Enumeration urls = JDOHelper.getResources(loader, + SERVICE_LOOKUP_PMF_RESOURCE_NAME); + while (urls.hasMoreElements()) { + // return the first one found + return JDOHelper.getClassNameFromURL((URL)urls.nextElement()); + } + } catch (Exception ex) { + // ignore exceptions from i/o errors + } + return null; + } +} Property changes on: api\test\java\javax\jdo\AbstractJDOConfigTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Index: api/test/java/javax/jdo/stub/StubPMF.java =================================================================== --- api/test/java/javax/jdo/stub/StubPMF.java (revision 0) +++ api/test/java/javax/jdo/stub/StubPMF.java (revision 0) @@ -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 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); + } + + } +} Property changes on: api\test\java\javax\jdo\stub\StubPMF.java ___________________________________________________________________ Added: svn:mime-type + text/plain Index: api/test/java/javax/jdo/util/AbstractTest.java =================================================================== --- api/test/java/javax/jdo/util/AbstractTest.java (revision 1176468) +++ api/test/java/javax/jdo/util/AbstractTest.java (working copy) @@ -19,10 +19,12 @@ 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;