OpenJPA
  1. OpenJPA
  2. OPENJPA-1105 OpenJPA 2.0 iteration 8 primary task
  3. OPENJPA-1130

Use maven-jar-plugin to create a o-p-j-tests.jar to share base TestCase classes across modules

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-M3
    • Component/s: build / infrastructure
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Propose moving openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/* base testcase classes to a openjpa-testsupport JAR which can be shared between o-p-j, openjpa-slice and new ones being added to openjpa-integration for bean validation and eventually OSGi.

      1. OPENJPA-1130-tests-classifier.patch.txt
        1 kB
        Michael Dick
      2. OPENJPA-1130.patch
        347 kB
        Donald Woods

        Activity

        Hide
        Michael Dick added a comment -

        I believe the ideal solution is to use the maven jar plugin to create an openjpa-persistence-jdbc-test artifact. That artifact can then be used in downstream modules like any other dependency.

        Similarly we could move some of the persistence API agnostic tests to openjpa-kernel or openjpa-jdbc.

        Creating a new module is another way to approach the problem but it seems like overkill to me.

        Show
        Michael Dick added a comment - I believe the ideal solution is to use the maven jar plugin to create an openjpa-persistence-jdbc-test artifact. That artifact can then be used in downstream modules like any other dependency. Similarly we could move some of the persistence API agnostic tests to openjpa-kernel or openjpa-jdbc. Creating a new module is another way to approach the problem but it seems like overkill to me.
        Hide
        Donald Woods added a comment -

        Creating a new module allows us to use the maven depends and potentially the maven-bundle-plugin for OSGi test support. Also, I'm only looking to move about 6 classes over and not all of the testcases.
        We took a similar approach in Apache Geronimo, where we have common testsupport and testsuite classes over in separate modules, which our testsuites then depend upon....
        Ideally, anything that directly extends junit.framework would be moved to this new openjpa-testsupport module, to help facilitate us moving to JUnit 4 (or another framework) in the future.

        Show
        Donald Woods added a comment - Creating a new module allows us to use the maven depends and potentially the maven-bundle-plugin for OSGi test support. Also, I'm only looking to move about 6 classes over and not all of the testcases. We took a similar approach in Apache Geronimo, where we have common testsupport and testsuite classes over in separate modules, which our testsuites then depend upon.... Ideally, anything that directly extends junit.framework would be moved to this new openjpa-testsupport module, to help facilitate us moving to JUnit 4 (or another framework) in the future.
        Hide
        Michael Dick added a comment -

        I'm not sure about the maven-bundle-plugin, but normal depends will work with a test-jar, just need to add <classifier>test</classifier>.

        If there are issues with that approach (ie won't work for OSGi, or downstream consumers) then we can go with a separate module.

        Moving to a different test framework is another interesting problem. I suppose splitting out some of the tests would help with memory usage though.

        Show
        Michael Dick added a comment - I'm not sure about the maven-bundle-plugin, but normal depends will work with a test-jar, just need to add <classifier>test</classifier>. If there are issues with that approach (ie won't work for OSGi, or downstream consumers) then we can go with a separate module. Moving to a different test framework is another interesting problem. I suppose splitting out some of the tests would help with memory usage though.
        Hide
        Donald Woods added a comment -

        Patch file of the proposed changes, where the base TestCase classes in openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ are moved to a new openjpa-testsupport module.
        Lots of updates, due to the package renaming/moving of the 10 testcase support classes.

        Show
        Donald Woods added a comment - Patch file of the proposed changes, where the base TestCase classes in openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ are moved to a new openjpa-testsupport module. Lots of updates, due to the package renaming/moving of the 10 testcase support classes.
        Hide
        Michael Dick added a comment -

        I'd prefer something like this since it doesn't move any of the classes and creates test jars for all our modules. Making the test classes available might produce some side benefits, users can easily download our unit tests and run in their environment (as opposed to building them from source). I think this is the way I'd like to go in the long term.

        There is a problem with the install goal though. Maven builds a tests jar for the parent pom and that jar doesn't include LICENSE.txt and NOTICE.txt so the ianal plugin fails. I'd guess this is a bug in the maven-jar-plugin, but I want to do some more investigation first.

        Show
        Michael Dick added a comment - I'd prefer something like this since it doesn't move any of the classes and creates test jars for all our modules. Making the test classes available might produce some side benefits, users can easily download our unit tests and run in their environment (as opposed to building them from source). I think this is the way I'd like to go in the long term. There is a problem with the install goal though. Maven builds a tests jar for the parent pom and that jar doesn't include LICENSE.txt and NOTICE.txt so the ianal plugin fails. I'd guess this is a bug in the maven-jar-plugin, but I want to do some more investigation first.
        Hide
        Donald Woods added a comment -

        Cool! Thanks for the patch. I'll give this way a try with the bean validation integration tests and see if it'll work.
        BTW - By only putting the test-jar goal on openjpa-persistence-jdbc/pom.xml, then we don't have ianal failures, which were being caused by other modules that had package == pom instead of jar.

        Show
        Donald Woods added a comment - Cool! Thanks for the patch. I'll give this way a try with the bean validation integration tests and see if it'll work. BTW - By only putting the test-jar goal on openjpa-persistence-jdbc/pom.xml, then we don't have ianal failures, which were being caused by other modules that had package == pom instead of jar.
        Hide
        Donald Woods added a comment -

        Well, so far using test-jar isn't working, as when I try to use the enhancer on classes in my validation tests, I'm getting unresolved class references for items included in the tests jar....

        Show
        Donald Woods added a comment - Well, so far using test-jar isn't working, as when I try to use the enhancer on classes in my validation tests, I'm getting unresolved class references for items included in the tests jar....
        Hide
        Michael Dick added a comment -

        The enhancer has never handled jarred classes very well.

        If we rely on the enhancer my guess would be that doing a top down build would work (maven operates on target/test-classes in this case), but building just the module will fail (maven picks up the jar from .m2/repository). I'd expect the same behavior for test-jar or a separate module though.

        Maybe I need to read more on the validation aspect of JPA 2.0. Are we relying on the entities having been enhanced, or do we need to re-enhance them? If it's the former we can probably reorder the enhancement to occur before test-jar does its work. For the latter we'll have to unjar or improve the enhancer to handle jarred classes.

        Show
        Michael Dick added a comment - The enhancer has never handled jarred classes very well. If we rely on the enhancer my guess would be that doing a top down build would work (maven operates on target/test-classes in this case), but building just the module will fail (maven picks up the jar from .m2/repository). I'd expect the same behavior for test-jar or a separate module though. Maybe I need to read more on the validation aspect of JPA 2.0. Are we relying on the entities having been enhanced, or do we need to re-enhance them? If it's the former we can probably reorder the enhancement to occur before test-jar does its work. For the latter we'll have to unjar or improve the enhancer to handle jarred classes.
        Hide
        Donald Woods added a comment -

        I'm trying to enhance classes in a new openjpa-integration/validation/src/test/main directory for my validation specific testing (as the entities will be using bean validation annotations that are not available in the normal openjpa-persistence-jdbc builds.)

        The enhancer error I'm seeing, is due to existing entities in the test jar -
        . . .
        628 WARN [main] openjpa.MetaData - Found duplicate metadata or mapping for "class org.apache.openjpa.persistence.jdbc.order.BaseTestElement3". Ignoring.
        629 TRACE [main] openjpa.MetaData - Parsing class "org.apache.openjpa.persistence.jdbc.order.BaseTestEntity3".
        629 WARN [main] openjpa.MetaData - Found duplicate metadata or mapping for "class org.apache.openjpa.persistence.jdbc.order.BaseTestEntity3". Ignoring.
        629 TRACE [main] openjpa.MetaData - Finished parsing metadata resource "jar:file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa-persistence-jdbc/2.0.0-SNAPSHOT/openjpa-persistence-jdbc-2.0.0-SNAPSHOT-tests.jar!/org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml".
        629 TRACE [main] openjpa.MetaData - Set persistence-capable superclass of "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper" to "null".
        631 TRACE [main] openjpa.MetaData - Resolving metadata for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091".
        631 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.id".
        639 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.mid".
        639 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.name".
        641 TRACE [main] openjpa.MetaData - Preparing mapping for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper".
        641 TRACE [main] openjpa.MetaData - Resolving mapping for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091".
        641 INFO [main] openjpa.Enhance - Enhancing type "class org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper".
        java.io.FileNotFoundException: file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa/2.0.0-SNAPSHOT/openjpa-2.0.0-SNAPSHOT.jar!/org/apache/openjpa/persistence/access/xml/XMLMixedMappedSuper.class (No such file or directory)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
        at serp.bytecode.BCClass.write(BCClass.java:179)
        at org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:595)
        at org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:581)
        at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4602)
        . . .
        [INFO] ------------------------------------------------------------------------
        [ERROR] BUILD ERROR
        [INFO] ------------------------------------------------------------------------
        [INFO] An Ant BuildException has occured: The following error occurred while executing this line:
        /Users/drwoods/openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml:51: The following error occurred while executing this line:
        /Users/drwoods/openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml:79: java.io.FileNotFoundException: file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa/2.0.0-SNAPSHOT/openjpa-2.0.0-SNAPSHOT.jar!/org/apache/openjpa/persistence/access/xml/XMLMixedMappedSuper.class (No such file or directory)

        Show
        Donald Woods added a comment - I'm trying to enhance classes in a new openjpa-integration/validation/src/test/main directory for my validation specific testing (as the entities will be using bean validation annotations that are not available in the normal openjpa-persistence-jdbc builds.) The enhancer error I'm seeing, is due to existing entities in the test jar - . . . 628 WARN [main] openjpa.MetaData - Found duplicate metadata or mapping for "class org.apache.openjpa.persistence.jdbc.order.BaseTestElement3". Ignoring. 629 TRACE [main] openjpa.MetaData - Parsing class "org.apache.openjpa.persistence.jdbc.order.BaseTestEntity3". 629 WARN [main] openjpa.MetaData - Found duplicate metadata or mapping for "class org.apache.openjpa.persistence.jdbc.order.BaseTestEntity3". Ignoring. 629 TRACE [main] openjpa.MetaData - Finished parsing metadata resource "jar: file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa-persistence-jdbc/2.0.0-SNAPSHOT/openjpa-persistence-jdbc-2.0.0-SNAPSHOT-tests.jar!/org/apache/openjpa/persistence/jdbc/order/order-orm-3.xml ". 629 TRACE [main] openjpa.MetaData - Set persistence-capable superclass of "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper" to "null". 631 TRACE [main] openjpa.MetaData - Resolving metadata for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091". 631 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.id". 639 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.mid". 639 TRACE [main] openjpa.MetaData - Resolving field "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091.name". 641 TRACE [main] openjpa.MetaData - Preparing mapping for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper". 641 TRACE [main] openjpa.MetaData - Resolving mapping for "org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper@353678091". 641 INFO [main] openjpa.Enhance - Enhancing type "class org.apache.openjpa.persistence.access.xml.XMLMixedMappedSuper". java.io.FileNotFoundException: file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa/2.0.0-SNAPSHOT/openjpa-2.0.0-SNAPSHOT.jar!/org/apache/openjpa/persistence/access/xml/XMLMixedMappedSuper.class (No such file or directory) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:179) at java.io.FileOutputStream.<init>(FileOutputStream.java:70) at serp.bytecode.BCClass.write(BCClass.java:179) at org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:595) at org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:581) at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4602) . . . [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] An Ant BuildException has occured: The following error occurred while executing this line: /Users/drwoods/openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml:51: The following error occurred while executing this line: /Users/drwoods/openjpa/trunk/openjpa-integration/validation/src/main/ant/enhancer.xml:79: java.io.FileNotFoundException: file:/Users/drwoods/.m2/repository/org/apache/openjpa/openjpa/2.0.0-SNAPSHOT/openjpa-2.0.0-SNAPSHOT.jar!/org/apache/openjpa/persistence/access/xml/XMLMixedMappedSuper.class (No such file or directory)
        Hide
        Donald Woods added a comment -

        Now that we upgraded to maven-jar-plugin-2.2 in OPENJPA-1131, Mike's proposed test-jar solution can be used.

        Show
        Donald Woods added a comment - Now that we upgraded to maven-jar-plugin-2.2 in OPENJPA-1131 , Mike's proposed test-jar solution can be used.

          People

          • Assignee:
            Donald Woods
            Reporter:
            Donald Woods
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development