[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-4393) seam-gen produces wrong persistence unit configuration for unit tests

Marcello Nuccio (JIRA) jira-events at lists.jboss.org
Tue Nov 24 13:10:29 EST 2009


    [ https://jira.jboss.org/jira/browse/JBSEAM-4393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12496401#action_12496401 ] 

Marcello Nuccio commented on JBSEAM-4393:
-----------------------------------------

As suggested in http://relation.to/10827.lace
I also needed to add the following line in resources/META-INF/persistence-test.xml to get it working (substitute PROJECTNAME)

  <property name="jboss.entity.manager.factory.jndi.name" value="java:/PROJECTNAMEEntityManagerFactory"/>



> seam-gen produces wrong persistence unit configuration for unit tests
> ---------------------------------------------------------------------
>
>                 Key: JBSEAM-4393
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-4393
>             Project: Seam
>          Issue Type: Bug
>            Reporter: Christian Bauer
>            Assignee: Dan Allen
>         Attachments: test.zip
>
>
> I've just generated a seam-gen project from 2.2 head and added a unit test. The test setup is wrong in build.xml:
>     <target name="buildtest" depends="init,compiletest,copytestclasses" description="Build the tests">
>         <copy todir="${test.dir}">
>             <fileset dir="${basedir}/resources">
>                 <exclude name="META-INF/persistence*.xml"/>
>                 <exclude name="import*.sql"/>
>                 <exclude name="${project.name}-*-ds.xml"/>
>                 <exclude name="components-*.properties"/>
>             </fileset>
>             <fileset dir="${basedir}/view"/>
>         </copy>
>         <copy tofile="${test.dir}/META-INF/persistence.xml" 
>               file="${basedir}/resources/META-INF/persistence-test.xml"/>
>         <copy tofile="${test.dir}/import.sql" 
>               file="${basedir}/resources/import-test.sql"/>
>         <!-- Wrong!
>         <copy tofile="${test.dir}/components.properties" 
>               file="${basedir}/resources/components-test.properties"/>
>         -->
>         <!-- Fix! -->
>         <copy tofile="${test.dir}/components.properties" 
>               file="${basedir}/resources/components-test.properties">
>             <filterset >
>                 <filter token="puJndiName" value="java:/${project.name}EntityManagerFactory"/>
>             </filterset>
>         </copy>
>         <copy todir="${test.dir}" flatten="true">
>             <fileset dir="${src.test.dir}">
>                 <include name="**/*Test.xml" />
>             </fileset>
>         </copy>
>     </target>
> The components.properties had hardcoded values for persistence unit configuration, which were wrong. I've added this filter to build.xml and modified the components-test.properties:
> # These properties are used to replace Ant-style tokens in the component descriptor (components.xml) at runtime.
> jndiPattern=#{ejbName}/local
> debug=true
> seamBootstrapsPu=true
> # Wrong!
> #seamEmfRef=#{entityManagerFactory}
> #puJndiName=#{null}
> # Fix!
> seamEmfRef=#{null}
> puJndiName=@puJndiName@
> Also, the readme.txt in the generated test folder doesn't mention that this Ant target has to run before you run the tests in the IDE and that you have to add the ${test.dir} folder to your classpath and NOT create a module dependency on your core application build output classpath etc. I don't know how that works in Eclipse but in IntelliJ I had to create a separate module with a completely separate list of classpath entries, and enable the 'buildtest' Ant target before the test suite runs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list