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

Dan Allen (JIRA) jira-events at lists.jboss.org
Fri Aug 28 11:31:23 EDT 2009

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

Dan Allen commented on JBSEAM-4393:

I'm sure there is a solution for this problem, but just to provide some background, we are really between a rock and a hardplace between allowing profiles and enabling the project to work in JBoss Tools. Basically, JBoss Tools has no idea about property replacement (for a justifiable reason) and therefore depends on the hardcoded values or a "seed" run of Ant.

Max and I will be discussing this at JBoss World. What it comes down to is that seam-gen is stretched about as far as it can go without snapping at this point. Unless we just abandon using the project in JBoss Tools and go all commandline, it's hard to fix one without breaking the other.

> 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