JDO
  1. JDO
  2. JDO-582

Test case needed for JDOFatalUserException nested exception argument needs cast to Throwable[]

    Details

      Description

      After collecting exceptions from invoking getPersistenceManagerFactory on all implementations, if no implementation has succeeded in returning a PersistenceManagerFactory, an exception is thrown, and the argument should be a Throwable[]. Otherwise, it's treated as a failed object instead of nested exceptions.

      1. Negative09.zip
        4 kB
        Richard Schilling
      2. 20080912-jdo-582-JDOHelperConfigTest.patch
        2 kB
        Richard Schilling
      3. 20080912-jdo-582-JDOHelper.patch
        5 kB
        Richard Schilling
      4. 20080912-jdo-582-combined.patch
        7 kB
        Richard Schilling
      5. 20080911-jdo-582-combined.patch
        7 kB
        Richard Schilling
      6. 20080911-jdo-582-Negative09.patch
        0.9 kB
        Richard Schilling
      7. 20080911-jdo-582-JDOHelperConfigTest.patch
        2 kB
        Richard Schilling
      8. 20080911-jdo-582-JDOHelper.patch
        5 kB
        Richard Schilling
      9. 20080911-jdo-582.patch
        7 kB
        Richard Schilling
      10. estedExceptionJDOHelper.patch
        0.7 kB
        Erik Bengtson

        Activity

        Hide
        Craig L Russell added a comment -

        Thanks to a lot of work by Richard Schilling, this is now fixed and checked in to svn.

        JDO-582 Fixed bugs in JDOHelper implementation:
        If implementation returns null to getPersistenceManagerFactory, JDOHelper now throws JDOFatalInternalException.
        JDOHelperTest adds a new test case for the above failure.

        If implementation fails to return a valid PersistenceManagerFactory, JDOHelper now catches all exceptions
        and if no implementation can be found, throws JDOFatalException with all failed efforts.
        JDOHelperConfigTest adds a new test case for the above failure.

        Bundle.properties message EXC_GetPMFNoSuchMethod was incorrect.
        JDOHelper used the wrong bundle message if no implementation of getPersistenceManagerFactory(Map).

        svn commit trunk/api2/test/schema/jdoconfig/Negative09 trunk/api2/test/java/javax/jdo/JDOHelperConfigTest.java trunk/api2/test/java/javax/jdo/JDOHelperTest.java trunk/api2/src/java/javax/jdo/JDOHelper.java trunk/api2/src/java/javax/jdo/Bundle.properties
        Sending trunk/api2/src/java/javax/jdo/Bundle.properties
        Sending trunk/api2/src/java/javax/jdo/JDOHelper.java
        Sending trunk/api2/test/java/javax/jdo/JDOHelperConfigTest.java
        Sending trunk/api2/test/java/javax/jdo/JDOHelperTest.java
        Adding trunk/api2/test/schema/jdoconfig/Negative09
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9a
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/services
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/services/javax.jdo.PersistenceManagerFactory
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9b
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/services
        Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory
        Transmitting file data .......
        Committed revision 694815.

        Show
        Craig L Russell added a comment - Thanks to a lot of work by Richard Schilling, this is now fixed and checked in to svn. JDO-582 Fixed bugs in JDOHelper implementation: If implementation returns null to getPersistenceManagerFactory, JDOHelper now throws JDOFatalInternalException. JDOHelperTest adds a new test case for the above failure. If implementation fails to return a valid PersistenceManagerFactory, JDOHelper now catches all exceptions and if no implementation can be found, throws JDOFatalException with all failed efforts. JDOHelperConfigTest adds a new test case for the above failure. Bundle.properties message EXC_GetPMFNoSuchMethod was incorrect. JDOHelper used the wrong bundle message if no implementation of getPersistenceManagerFactory(Map). svn commit trunk/api2/test/schema/jdoconfig/Negative09 trunk/api2/test/java/javax/jdo/JDOHelperConfigTest.java trunk/api2/test/java/javax/jdo/JDOHelperTest.java trunk/api2/src/java/javax/jdo/JDOHelper.java trunk/api2/src/java/javax/jdo/Bundle.properties Sending trunk/api2/src/java/javax/jdo/Bundle.properties Sending trunk/api2/src/java/javax/jdo/JDOHelper.java Sending trunk/api2/test/java/javax/jdo/JDOHelperConfigTest.java Sending trunk/api2/test/java/javax/jdo/JDOHelperTest.java Adding trunk/api2/test/schema/jdoconfig/Negative09 Adding trunk/api2/test/schema/jdoconfig/Negative09/9a Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/services Adding trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/services/javax.jdo.PersistenceManagerFactory Adding trunk/api2/test/schema/jdoconfig/Negative09/9b Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/services Adding trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory Transmitting file data ....... Committed revision 694815.
        Hide
        Richard Schilling added a comment -

        So, with Craig's last few suggestions I think I got things working properly. All the patches and new setup files are uploaded.

        Thanks Craig for your help! I'll add what I learned to the Wiki. If you would like me to include any links let me know.

        Show
        Richard Schilling added a comment - So, with Craig's last few suggestions I think I got things working properly. All the patches and new setup files are uploaded. Thanks Craig for your help! I'll add what I learned to the Wiki. If you would like me to include any links let me know.
        Hide
        Richard Schilling added a comment -

        This file contains the directory structure and setup files to run the test case, and can be unzipped at the top of the source tree (one directory above trunk).

        Show
        Richard Schilling added a comment - This file contains the directory structure and setup files to run the test case, and can be unzipped at the top of the source tree (one directory above trunk).
        Hide
        Richard Schilling added a comment -

        Patch file 3 of 3. This patch only contains changes from one of the files in 20080912-jdo-582-combined.patch.

        Show
        Richard Schilling added a comment - Patch file 3 of 3. This patch only contains changes from one of the files in 20080912-jdo-582-combined.patch.
        Hide
        Richard Schilling added a comment -

        Patch file 2 of 3. This patch only contains changes from one of the files in 20080912-jdo-582-combined.patch.

        Show
        Richard Schilling added a comment - Patch file 2 of 3. This patch only contains changes from one of the files in 20080912-jdo-582-combined.patch.
        Hide
        Richard Schilling added a comment -

        Uploading new patch that combines changes from all files. This is file 1 of 3.

        This file has the correct date pre-pended on the file name.

        Show
        Richard Schilling added a comment - Uploading new patch that combines changes from all files. This is file 1 of 3. This file has the correct date pre-pended on the file name.
        Hide
        Richard Schilling added a comment -

        Uploaded new patch file (1 of 3). This one contains all the files that are patched.

        Show
        Richard Schilling added a comment - Uploaded new patch file (1 of 3). This one contains all the files that are patched.
        Hide
        Craig L Russell added a comment -

        Ok, so you should use one (not two) jdoconfig.xml with a name. This can go into 9a. The name should match the name in your getPMF call. So you will resolve to a valid persistence-manager-factory element. That element should not contain a class attribute. This will stimulate the JDOHelper to try to find services/javax.jdo.PersistenceManagerFactory. Here is where you want to have two services files: one in 9a and the other in 9b. Both fail. Two exceptions are generated. Each goes into one of the list elements and when none of the services results in success, the whole thing fails.

        Show
        Craig L Russell added a comment - Ok, so you should use one (not two) jdoconfig.xml with a name. This can go into 9a. The name should match the name in your getPMF call. So you will resolve to a valid persistence-manager-factory element. That element should not contain a class attribute. This will stimulate the JDOHelper to try to find services/javax.jdo.PersistenceManagerFactory. Here is where you want to have two services files: one in 9a and the other in 9b. Both fail. Two exceptions are generated. Each goes into one of the list elements and when none of the services results in success, the whole thing fails.
        Hide
        Richard Schilling added a comment -

        I know I'm close to getting the setup correct. But, I'm getting two messages now, which the JDO specification doesn't cover:

        Without assigning a name to the <persistence-manager-factory> tag in jdoconfig.xml:
        Duplicate PMF name "(anonymous)" found in file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml and file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/jdoconfig.xml.

        And, when I do assign a name (like it is in the other tests):
        Duplicate PMF name "name.negative09" found in file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml and file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/jdoconfig.xml.

        The JDO specification has the DTD of the jdoconfig file, but nothing really useful on semantics of each attribute.

        Help ....

        Show
        Richard Schilling added a comment - I know I'm close to getting the setup correct. But, I'm getting two messages now, which the JDO specification doesn't cover: Without assigning a name to the <persistence-manager-factory> tag in jdoconfig.xml: Duplicate PMF name "(anonymous)" found in file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml and file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/jdoconfig.xml . And, when I do assign a name (like it is in the other tests): Duplicate PMF name "name.negative09" found in file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9a/META-INF/jdoconfig.xml and file:/S:/jdo/trunk/api2/test/schema/jdoconfig/Negative09/9b/META-INF/jdoconfig.xml . The JDO specification has the DTD of the jdoconfig file, but nothing really useful on semantics of each attribute. Help ....
        Hide
        Craig L Russell added a comment -

        To stimulate the Map, Map, Loader, Loader method you need to pass a properties file or set one up in the config. So you will need a jdoconfig.xml but without a classname property.

        Show
        Craig L Russell added a comment - To stimulate the Map, Map, Loader, Loader method you need to pass a properties file or set one up in the config. So you will need a jdoconfig.xml but without a classname property.
        Hide
        Craig L Russell added a comment -

        The setup is what I expected.

        I had suggested using javax.jdo.JDOHelper$BadPMFNoGetPMFMethod and javax.jdo.JDOHelper$BadPMFNonStaticGetPMFMethod in the services files. Nothing wrong with what you've got though.

        But do make sure that the props you pass in don't contain the class name of pu name property.

        Show
        Craig L Russell added a comment - The setup is what I expected. I had suggested using javax.jdo.JDOHelper$BadPMFNoGetPMFMethod and javax.jdo.JDOHelper$BadPMFNonStaticGetPMFMethod in the services files. Nothing wrong with what you've got though. But do make sure that the props you pass in don't contain the class name of pu name property.
        Hide
        Richard Schilling added a comment -

        I setup the code now so that I'm using the META-INF/services/javax.jdo.PersistenceManagerFactory approach. The test is failing because no nested exception is being generated. So, I'll look into this to be sure I've written the original code correctly.

        Is the following the correct setup?

        I reorganized the settings files so I have the following

        Contents of Negative09/9a/META-INF/services/javax.jdo.PersistenceManagerFactory:
        javax.jdo.JDOHelperTest$BadPMFWrongReturnType

        Contents of Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory:
        javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException

        And, here is the method the calls upon these files:

        public void testNegative09_MultipleInvalidClassesInDifferentConfigFiles()
        throws IOException {

        // failure ensured with a bad class name in Negative09/jdoconfig.xml
        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); JDOHelper.getPersistenceManagerFactory(loader); fail("JDOHelper failed to throw JDOFatalUserException"); }

        catch (JDOFatalUserException x) {

        // if nested exceptions are returned, we're on the happy farm ...
        if (x.getNestedExceptions() == null)

        { fail("JDOHelper failed to include any nested exceptions"); }

        else {

        Throwable t[] = x.getNestedExceptions();
        System.out.println("There are " + t.length + " nested exceptiond.");
        for (int i=0;i<t.length;i++)

        { System.out.println("exception " + i + ": " + t[i].getMessage()); }

        }

        }
        }

        Show
        Richard Schilling added a comment - I setup the code now so that I'm using the META-INF/services/javax.jdo.PersistenceManagerFactory approach. The test is failing because no nested exception is being generated. So, I'll look into this to be sure I've written the original code correctly. Is the following the correct setup? I reorganized the settings files so I have the following Contents of Negative09/9a/META-INF/services/javax.jdo.PersistenceManagerFactory: javax.jdo.JDOHelperTest$BadPMFWrongReturnType Contents of Negative09/9b/META-INF/services/javax.jdo.PersistenceManagerFactory: javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException And, here is the method the calls upon these files: public void testNegative09_MultipleInvalidClassesInDifferentConfigFiles() throws IOException { // failure ensured with a bad class name in Negative09/jdoconfig.xml 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); JDOHelper.getPersistenceManagerFactory(loader); fail("JDOHelper failed to throw JDOFatalUserException"); } catch (JDOFatalUserException x) { // if nested exceptions are returned, we're on the happy farm ... if (x.getNestedExceptions() == null) { fail("JDOHelper failed to include any nested exceptions"); } else { Throwable t[] = x.getNestedExceptions(); System.out.println("There are " + t.length + " nested exceptiond."); for (int i=0;i<t.length;i++) { System.out.println("exception " + i + ": " + t[i].getMessage()); } } } }
        Hide
        Craig L Russell added a comment -

        > I had initially set up the test with two configuration files, just like you suggested, but I didn't understand by looking at the code and the XML file how both class names get added to the search list.

        > So, I think I just need more information on how to setup the .xml files and actually make the call.

        > On my first attempt I tried using one configuration file with two persistence manager factories defined. I got an error - something about not being able to have duplicate properties defined. Here's what I had in one file:
        > <persistence-manager-factory>
        This isn't needed. What you need instead is simply a services/javax.jdo.PersistenceManagerFactory file that names the error PMFs.

        > ClasspathHelper.addFile(
        > JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09a", loader);
        > ClasspathHelper.addFile(
        > JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09b", loader);

        You're on the right track with the above, but instead of having jdoconfix.xml files in 09a and 09b, you should have services entries that name the invalid PMF classes.

        Show
        Craig L Russell added a comment - > I had initially set up the test with two configuration files, just like you suggested, but I didn't understand by looking at the code and the XML file how both class names get added to the search list. > So, I think I just need more information on how to setup the .xml files and actually make the call. > On my first attempt I tried using one configuration file with two persistence manager factories defined. I got an error - something about not being able to have duplicate properties defined. Here's what I had in one file: > <persistence-manager-factory> This isn't needed. What you need instead is simply a services/javax.jdo.PersistenceManagerFactory file that names the error PMFs. > ClasspathHelper.addFile( > JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09a", loader); > ClasspathHelper.addFile( > JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09b", loader); You're on the right track with the above, but instead of having jdoconfix.xml files in 09a and 09b, you should have services entries that name the invalid PMF classes.
        Hide
        Craig L Russell added a comment -

        Try doing a clean build. No class found is usually a build mismatch error.

        Show
        Craig L Russell added a comment - Try doing a clean build. No class found is usually a build mismatch error.
        Hide
        Richard Schilling added a comment -

        I updated my source that included your patch and I get a build error:

        Testcase: testNegative03_DuplicateNamedPersistenceUnitsInSameConfig(javax.jdo.JDOHelperConfigTest): Caused an ERROR
        javax/jdo/JDOHelper$14
        java.lang.NoClassDefFoundError: javax/jdo/JDOHelper$14
        at javax.jdo.JDOHelper.getResourceAsStream(JDOHelper.java:1829)
        at javax.jdo.JDOHelper.loadPropertiesFromResource(JDOHelper.java:1187)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1062)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:922)
        at javax.jdo.JDOHelperConfigTest.testNegative03_DuplicateNamedPersistenceUnitsInSameConfig(JDOHelperConfigTest.java:459)
        at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
        at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:42)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83)
        at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116)
        at org.apache.maven.werkz.Goal.fire(Goal.java:691)
        at org.apache.maven.werkz.Goal.attain(Goal.java:623)
        at org.apache.maven.werkz.Goal.attainPrecursors(Goal.java:526)
        at org.apache.maven.werkz.Goal.attain(Goal.java:621)
        at org.apache.maven.werkz.Goal.attainPrecursors(Goal.java:526)
        at org.apache.maven.werkz.Goal.attain(Goal.java:621)
        at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:712)
        at org.apache.maven.MavenSession.attainGoals(MavenSession.java:265)
        at org.apache.maven.cli.App.doMain(App.java:307)
        at org.apache.maven.cli.App.main(App.java:217)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)

        Show
        Richard Schilling added a comment - I updated my source that included your patch and I get a build error: Testcase: testNegative03_DuplicateNamedPersistenceUnitsInSameConfig(javax.jdo.JDOHelperConfigTest): Caused an ERROR javax/jdo/JDOHelper$14 java.lang.NoClassDefFoundError: javax/jdo/JDOHelper$14 at javax.jdo.JDOHelper.getResourceAsStream(JDOHelper.java:1829) at javax.jdo.JDOHelper.loadPropertiesFromResource(JDOHelper.java:1187) at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1062) at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:922) at javax.jdo.JDOHelperConfigTest.testNegative03_DuplicateNamedPersistenceUnitsInSameConfig(JDOHelperConfigTest.java:459) at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:195) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186) at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:42) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:250) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:83) at org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:116) at org.apache.maven.werkz.Goal.fire(Goal.java:691) at org.apache.maven.werkz.Goal.attain(Goal.java:623) at org.apache.maven.werkz.Goal.attainPrecursors(Goal.java:526) at org.apache.maven.werkz.Goal.attain(Goal.java:621) at org.apache.maven.werkz.Goal.attainPrecursors(Goal.java:526) at org.apache.maven.werkz.Goal.attain(Goal.java:621) at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:712) at org.apache.maven.MavenSession.attainGoals(MavenSession.java:265) at org.apache.maven.cli.App.doMain(App.java:307) at org.apache.maven.cli.App.main(App.java:217) at com.werken.forehead.Forehead.run(Forehead.java:551) at com.werken.forehead.Forehead.main(Forehead.java:581)
        Hide
        Richard Schilling added a comment -

        I had initially set up the test with two configuration files, just like you suggested, but I didn't understand by looking at the code and the XML file how both class names get added to the search list.

        So, I think I just need more information on how to setup the .xml files and actually make the call.

        On my first attempt I tried using one configuration file with two persistence manager factories defined. I got an error - something about not being able to have duplicate properties defined. Here's what I had in one file:

        <persistence-manager-factory>
        <property
        name="javax.jdo.PersistenceManagerFactoryClass"
        value="bad.class.negative9a.1"/> <!-- name is arbitrary class name -->
        </persistence-manager-factory>
        <persistence-manager-factory>
        <property
        name="javax.jdo.PersistenceManagerFactoryClass"
        value="bad.class.negative9a.2"/> <!-- name is arbitrary class name -->
        </persistence-manager-factory>

        Then I tried using the two configuration files as you suggest, putting the definition for each PMF in a separate file. But, I got an error there as well, with the following code being executed in the test method:

        ClasspathHelper.addFile(
        JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09a", loader);
        ClasspathHelper.addFile(
        JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09b", loader);

        // call getPersistenceManagerFactory(classloader);

        So, how do I specify the class names in the .xml files?

        Also, I didn't expect to be actually using a real class name as you suggets (e.g. javax.jdo.JDOHelperTest.BadPMFNoGetPMFMethod).

        Can you explain this a little more please? Would be very helpful in my understanding of PMF internal behavior...

        Thanks.

        Show
        Richard Schilling added a comment - I had initially set up the test with two configuration files, just like you suggested, but I didn't understand by looking at the code and the XML file how both class names get added to the search list. So, I think I just need more information on how to setup the .xml files and actually make the call. On my first attempt I tried using one configuration file with two persistence manager factories defined. I got an error - something about not being able to have duplicate properties defined. Here's what I had in one file: <persistence-manager-factory> <property name="javax.jdo.PersistenceManagerFactoryClass" value="bad.class.negative9a.1"/> <!-- name is arbitrary class name --> </persistence-manager-factory> <persistence-manager-factory> <property name="javax.jdo.PersistenceManagerFactoryClass" value="bad.class.negative9a.2"/> <!-- name is arbitrary class name --> </persistence-manager-factory> Then I tried using the two configuration files as you suggest, putting the definition for each PMF in a separate file. But, I got an error there as well, with the following code being executed in the test method: ClasspathHelper.addFile( JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09a", loader); ClasspathHelper.addFile( JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/09b", loader); // call getPersistenceManagerFactory(classloader); So, how do I specify the class names in the .xml files? Also, I didn't expect to be actually using a real class name as you suggets (e.g. javax.jdo.JDOHelperTest.BadPMFNoGetPMFMethod). Can you explain this a little more please? Would be very helpful in my understanding of PMF internal behavior... Thanks.
        Hide
        Richard Schilling added a comment -

        Adding a file that can be unzipped in your working copy of the JDO project. Unzip the file in the directory above the trunk.

        File contents:

        Archive: Negative09.zip
        Length Date Time Name
        -------- ---- ---- ----
        691 09-11-08 12:43 trunk/api2/test/schema/jdoconfig/Negative09/META-INF/jdoconfig.xml
        -------- -------
        691 1 file

        Show
        Richard Schilling added a comment - Adding a file that can be unzipped in your working copy of the JDO project. Unzip the file in the directory above the trunk. File contents: Archive: Negative09.zip Length Date Time Name -------- ---- ---- ---- 691 09-11-08 12:43 trunk/api2/test/schema/jdoconfig/Negative09/META-INF/jdoconfig.xml -------- ------- 691 1 file
        Hide
        Craig L Russell added a comment -

        In the JDOHelperConfigTest, I don't think you're testing the error condition. What JDOHelper is doing is iterating over the services entries and finding classes to load. So there is a need for Negative09/09a/META-INF/services that contains a bad class and another Negative09/09b/META-INF/services that contains another bad class.

        I'd suggest using two of the bad classes from JDOHelperTest (except that these are private). I've checked in a patch to JDOHelperTest that makes the inner classes public so they can be referenced outside the test class.

        Then the services/javax.jdo.PersistenceManagerHelper files can have one-liners: javax.jdo.JDOHelper$BadPMFNoGetPMFMethod and javax.jdo.JDOHelper$BadPMFNonStaticGetPMFMethod.

        And the test should test that the nestedThrowable array contains two elements.

        Show
        Craig L Russell added a comment - In the JDOHelperConfigTest, I don't think you're testing the error condition. What JDOHelper is doing is iterating over the services entries and finding classes to load. So there is a need for Negative09/09a/META-INF/services that contains a bad class and another Negative09/09b/META-INF/services that contains another bad class. I'd suggest using two of the bad classes from JDOHelperTest (except that these are private). I've checked in a patch to JDOHelperTest that makes the inner classes public so they can be referenced outside the test class. Then the services/javax.jdo.PersistenceManagerHelper files can have one-liners: javax.jdo.JDOHelper$BadPMFNoGetPMFMethod and javax.jdo.JDOHelper$BadPMFNonStaticGetPMFMethod. And the test should test that the nestedThrowable array contains two elements.
        Hide
        Richard Schilling added a comment -

        It's a new file. Perhaps you have to manually create an empty file first in the patch that's indicated?

        Not sure how to create a patch that adds a new file. So, I'll just upload the Negative09 files and you can add them.

        For some reason I that patch would have created a the Negative09 files.

        Richard

        Show
        Richard Schilling added a comment - It's a new file. Perhaps you have to manually create an empty file first in the patch that's indicated? Not sure how to create a patch that adds a new file. So, I'll just upload the Negative09 files and you can add them. For some reason I that patch would have created a the Negative09 files. Richard
        Hide
        Craig L Russell added a comment -

        Could you repost the patch for the Negative09? It looks like a diff but there's nothing to diff.

        Show
        Craig L Russell added a comment - Could you repost the patch for the Negative09? It looks like a diff but there's nothing to diff.
        Hide
        Richard Schilling added a comment -

        Broke submitted patch file into three separate files per Craig's request. This is file 3 of 3.

        Show
        Richard Schilling added a comment - Broke submitted patch file into three separate files per Craig's request. This is file 3 of 3.
        Hide
        Richard Schilling added a comment -

        Broke submitted patch file into three separate files per Craig's request. This is file 2 of 3.

        Show
        Richard Schilling added a comment - Broke submitted patch file into three separate files per Craig's request. This is file 2 of 3.
        Hide
        Richard Schilling added a comment -

        Broke submitted patch file into three separate files per Craig's request. This is file 1 of 3.

        Show
        Richard Schilling added a comment - Broke submitted patch file into three separate files per Craig's request. This is file 1 of 3.
        Hide
        Richard Schilling added a comment -

        The previous file I uploaded was an incomplete patch. This one is a complete patch.

        This file supersedes all other file uploaded before this one.

        Show
        Richard Schilling added a comment - The previous file I uploaded was an incomplete patch. This one is a complete patch. This file supersedes all other file uploaded before this one.
        Hide
        Craig L Russell added a comment -

        Great. I'll review the code changes to JDOHelper that you checked in. I guess you will provide another patch with the test case changes.

        Show
        Craig L Russell added a comment - Great. I'll review the code changes to JDOHelper that you checked in. I guess you will provide another patch with the test case changes.
        Hide
        Richard Schilling added a comment -

        Finally figured out the complete testing mechanism for JDOHelper, and how to properly setup files, etc.... This patch includes the change to JDO Helper, JDOHelperConfigTest, and a new configuration file Negative09.

        Show
        Richard Schilling added a comment - Finally figured out the complete testing mechanism for JDOHelper, and how to properly setup files, etc.... This patch includes the change to JDO Helper, JDOHelperConfigTest, and a new configuration file Negative09.
        Hide
        Michelle Caisse added a comment -

        The test needs to provide appropriate set-up to exercise line 821 in JDOHelper. This is the line that was fixed by the initial patch on this issue. Given this scenario, then a call to ex.getNestedExceptions() will return a non-null value. This could be the assertion for the test, that the value is non-null. In the current test, the exception returned is one of the variants of JDOUserException that was constructed without a nested Throwable array (http://db.apache.org/jdo/api21/apidocs/index.html), so ex.getNestedExceptions() returns null.

        Show
        Michelle Caisse added a comment - The test needs to provide appropriate set-up to exercise line 821 in JDOHelper. This is the line that was fixed by the initial patch on this issue. Given this scenario, then a call to ex.getNestedExceptions() will return a non-null value. This could be the assertion for the test, that the value is non-null. In the current test, the exception returned is one of the variants of JDOUserException that was constructed without a nested Throwable array ( http://db.apache.org/jdo/api21/apidocs/index.html ), so ex.getNestedExceptions() returns null.
        Hide
        Michelle Caisse added a comment -

        In target/test-reports/TEST-javax.jdo.JDOHelperTest.txt, there is some error output that should be helpful:

        Testcase: testGetPMFBadResource(javax.jdo.JDOHelperTest): Caused an ERROR
        null
        java.lang.NullPointerException
        at javax.jdo.JDOHelperTest.testGetPMFBadResource(JDOHelperTest.java:235)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        ...

        Show
        Michelle Caisse added a comment - In target/test-reports/TEST-javax.jdo.JDOHelperTest.txt, there is some error output that should be helpful: Testcase: testGetPMFBadResource(javax.jdo.JDOHelperTest): Caused an ERROR null java.lang.NullPointerException at javax.jdo.JDOHelperTest.testGetPMFBadResource(JDOHelperTest.java:235) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185) ...
        Hide
        Richard Schilling added a comment -

        I think I need some clarification on what the test case should be looking for:

        In text following text appears in the original description:
        "and the argument should be a Throwable[]. Otherwise, it's treated as a failed object instead of nested exceptions."

        I'm wondering what argument is being referred to here. If it's the argument passed to the JDOFatalUserException constructor (line 821 in JDOHelper.java), then we are guaranteed it's an array of Throwable[] because only Throwable classes are added to the ArrayList, from wich the Throwable[] array is extracted and passed to the JDOFatalUserException constructor.

        Thoughts anyone?

        Show
        Richard Schilling added a comment - I think I need some clarification on what the test case should be looking for: In text following text appears in the original description: "and the argument should be a Throwable[]. Otherwise, it's treated as a failed object instead of nested exceptions." I'm wondering what argument is being referred to here. If it's the argument passed to the JDOFatalUserException constructor (line 821 in JDOHelper.java), then we are guaranteed it's an array of Throwable[] because only Throwable classes are added to the ArrayList, from wich the Throwable[] array is extracted and passed to the JDOFatalUserException constructor. Thoughts anyone?
        Hide
        Richard Schilling added a comment -

        new .diff file that replaces the previous version. I fixed a bug in the test case....

        Show
        Richard Schilling added a comment - new .diff file that replaces the previous version. I fixed a bug in the test case....
        Hide
        Michelle Caisse added a comment -

        I get a compile error:
        test:compile:
        [javac] Compiling 9 source files to C:\jdo\trunk\api2\target\test-classes
        C:\jdo\trunk\api2\test\java\javax\jdo\JDOHelperTest.java:236: inconvertible types
        found : java.lang.Throwable
        required: java.lang.Throwable[]
        if (!(ex.getCause() instanceof Throwable[]))
        ^
        Note: Some input files use unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.
        1 error

        Show
        Michelle Caisse added a comment - I get a compile error: test:compile: [javac] Compiling 9 source files to C:\jdo\trunk\api2\target\test-classes C:\jdo\trunk\api2\test\java\javax\jdo\JDOHelperTest.java:236: inconvertible types found : java.lang.Throwable required: java.lang.Throwable[] if (!(ex.getCause() instanceof Throwable[])) ^ Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
        Hide
        Richard Schilling added a comment -

        This is just an interim file, so please don't apply it to the code base yet.

        Some notes and questions on file JDOHelperTest.java:

        the test method that gets run, testGetPMFBadResource(), doesn't seem to complete. Any ideas as to why that would happen? I think I need to brush up on JUnit testing. Note my calls to System.out.println() at the beginning and end of the method (with my initials being printed out to make it easy to find the line in the output). The first call to System.out.println() is executed, and it's followed by lots of great exception data, but the second never is executed.

        I'm assuming that the call to fail() is what causes the test to fail, but I don't see where fail should be called here with the code I have in the method. Am I missing something?

        Show
        Richard Schilling added a comment - This is just an interim file, so please don't apply it to the code base yet. Some notes and questions on file JDOHelperTest.java: the test method that gets run, testGetPMFBadResource(), doesn't seem to complete. Any ideas as to why that would happen? I think I need to brush up on JUnit testing. Note my calls to System.out.println() at the beginning and end of the method (with my initials being printed out to make it easy to find the line in the output). The first call to System.out.println() is executed, and it's followed by lots of great exception data, but the second never is executed. I'm assuming that the call to fail() is what causes the test to fail, but I don't see where fail should be called here with the code I have in the method. Am I missing something?
        Hide
        Craig L Russell added a comment -

        Good luck.

        Show
        Craig L Russell added a comment - Good luck.
        Hide
        Craig L Russell added a comment -

        The fix to JDOHelper has been applied to both trunk and branches/2.1.

        This needs a test case in JDOHelperTest that isn't major priority but should be added for completeness.

        Show
        Craig L Russell added a comment - The fix to JDOHelper has been applied to both trunk and branches/2.1. This needs a test case in JDOHelperTest that isn't major priority but should be added for completeness.
        Hide
        Craig L Russell added a comment -

        Ok, so my math skills are not the best before 9:00 AM. Oops.

        4 files (Michelle's two are affected by this change.

        in api2, line 815. In api2-legacy, line 740.

        Show
        Craig L Russell added a comment - Ok, so my math skills are not the best before 9:00 AM. Oops. 4 files (Michelle's two are affected by this change. in api2, line 815. In api2-legacy, line 740.
        Hide
        Michelle Caisse added a comment -

        (api2 + api2-legacy) * (trunk + branches/2.1) * ??

        Show
        Michelle Caisse added a comment - (api2 + api2-legacy) * (trunk + branches/2.1) * ??
        Hide
        Erik Bengtson added a comment -

        > It applies to 8 files now with the 2.1 branch.

        I dont know what you mean.

        Show
        Erik Bengtson added a comment - > It applies to 8 files now with the 2.1 branch. I dont know what you mean.
        Hide
        Craig L Russell added a comment -

        The patch looks good. If you want to check it in, go ahead. It applies to 8 files now with the 2.1 branch.

        If you don't have time to do it, I'll take care of it later today.

        Show
        Craig L Russell added a comment - The patch looks good. If you want to check it in, go ahead. It applies to 8 files now with the 2.1 branch. If you don't have time to do it, I'll take care of it later today.

          People

          • Assignee:
            Richard Schilling
            Reporter:
            Erik Bengtson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development