<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Step By Step Guide &#8211; Setup Seam 2.2.0.GA based Integration testing with Maven TestNG Cobertura</title>
	<atom:link href="http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/</link>
	<description>My Code Notes (mostly JavaEE or JEE)</description>
	<lastBuildDate>Sun, 02 May 2010 18:29:30 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karthikeyan C</title>
		<link>http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/comment-page-1/#comment-243</link>
		<dc:creator>Karthikeyan C</dc:creator>
		<pubDate>Sun, 02 May 2010 18:29:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.karthikeyanc.com/blog/?p=140#comment-243</guid>
		<description>&lt;a href=&quot;#comment-242&quot; rel=&quot;nofollow&quot;&gt;@Jasper Vandaele &lt;/a&gt; 
Sorry to reply and approve your comments late. Thanks for your comments as it would be helpful for me as well as other readers of this post (to be specific the exclusion of main persistence.xml)</description>
		<content:encoded><![CDATA[<p><a href="#comment-242" rel="nofollow">@Jasper Vandaele </a><br />
Sorry to reply and approve your comments late. Thanks for your comments as it would be helpful for me as well as other readers of this post (to be specific the exclusion of main persistence.xml)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper Vandaele</title>
		<link>http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/comment-page-1/#comment-242</link>
		<dc:creator>Jasper Vandaele</dc:creator>
		<pubDate>Sun, 02 May 2010 18:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.karthikeyanc.com/blog/?p=140#comment-242</guid>
		<description>I found a solution to override the main persistence.xml with a test one.  (Google is still my friend :).

The thing is that the embedded Jboss does not simply load the first persistence.xml in the classpath. I haven&#039;t found out what happens exactly, but the mvn test work and can deploy the app without touching a file or skipping tests.

So I have a persistence.xml in src/main/resources with the tomcat jndi name and one in src/test/resources with the jndi name for jboss.
The first thing to do is to exclude the main persistence.xml from the main resources:
&lt;resources&gt;
  &lt;resource&gt;
    &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
    &lt;excludes&gt;
	&lt;exclude&gt;META-INF/persistence*&lt;/exclude&gt;
    &lt;/excludes&gt;
  &lt;/resource&gt;
&lt;/resources&gt;

Now the persistence.xml in the main resources got invisible and the tests pass.

To have the right persistence.xml in the final app, I use the ant plugin in the prepare-package phase:

&lt;plugin&gt;
    &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
    &lt;executions&gt;
		&lt;execution&gt;
                  &lt;phase&gt;prepare-package&lt;/phase&gt;
		  &lt;configuration&gt;
				&lt;tasks&gt;
					&lt;copy todir=&quot;${project.build.outputDirectory}&quot;&gt;
						&lt;fileset dir=&quot;${basedir}/src/main/resources&quot;&gt;
							&lt;include name=&quot;META-INF&quot; /&gt;
						&lt;/fileset&gt;
					&lt;/copy&gt;
				&lt;/tasks&gt;
		  &lt;/configuration&gt;
		  &lt;goals&gt;
				&lt;goal&gt;run&lt;/goal&gt;
		  &lt;/goals&gt;
		&lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;


I must add that I had some unexplainable &quot;unknown entity&quot; errors in the tests. I solved this by explicitly adding the entity classes in the test persistence.xml with &lt;class&gt; tags.

Hope this can help.</description>
		<content:encoded><![CDATA[<p>I found a solution to override the main persistence.xml with a test one.  (Google is still my friend <img src='http://www.karthikeyanc.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>The thing is that the embedded Jboss does not simply load the first persistence.xml in the classpath. I haven&#8217;t found out what happens exactly, but the mvn test work and can deploy the app without touching a file or skipping tests.</p>
<p>So I have a persistence.xml in src/main/resources with the tomcat jndi name and one in src/test/resources with the jndi name for jboss.<br />
The first thing to do is to exclude the main persistence.xml from the main resources:<br />
&lt;resources&gt;<br />
  &lt;resource&gt;<br />
    &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;<br />
    &lt;excludes&gt;<br />
	&lt;exclude&gt;META-INF/persistence*&lt;/exclude&gt;<br />
    &lt;/excludes&gt;<br />
  &lt;/resource&gt;<br />
&lt;/resources&gt;</p>
<p>Now the persistence.xml in the main resources got invisible and the tests pass.</p>
<p>To have the right persistence.xml in the final app, I use the ant plugin in the prepare-package phase:</p>
<p>&lt;plugin&gt;<br />
    &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;<br />
    &lt;executions&gt;<br />
		&lt;execution&gt;<br />
                  &lt;phase&gt;prepare-package&lt;/phase&gt;<br />
		  &lt;configuration&gt;<br />
				&lt;tasks&gt;<br />
					&lt;copy todir=&quot;${project.build.outputDirectory}&quot;&gt;<br />
						&lt;fileset dir=&quot;${basedir}/src/main/resources&quot;&gt;<br />
							&lt;include name=&quot;META-INF&quot; /&gt;<br />
						&lt;/fileset&gt;<br />
					&lt;/copy&gt;<br />
				&lt;/tasks&gt;<br />
		  &lt;/configuration&gt;<br />
		  &lt;goals&gt;<br />
				&lt;goal&gt;run&lt;/goal&gt;<br />
		  &lt;/goals&gt;<br />
		&lt;/execution&gt;<br />
    &lt;/executions&gt;<br />
&lt;/plugin&gt;</p>
<p>I must add that I had some unexplainable &#8220;unknown entity&#8221; errors in the tests. I solved this by explicitly adding the entity classes in the test persistence.xml with &lt;class&gt; tags.</p>
<p>Hope this can help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper Vandaele</title>
		<link>http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/comment-page-1/#comment-240</link>
		<dc:creator>Jasper Vandaele</dc:creator>
		<pubDate>Thu, 29 Apr 2010 21:38:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.karthikeyanc.com/blog/?p=140#comment-240</guid>
		<description>OK,

Second try to post the pom.xml parts:

&lt;code&gt;
&lt;plugin&gt;
		        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
		        &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
		        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
		        &lt;configuration&gt;
		        	&lt;update&gt;true&lt;/update&gt;
		        	&lt;mode&gt;both&lt;/mode&gt;
		        	&lt;contextFile&gt;src/main/resources/META-INF/context.xml&lt;/contextFile&gt;
		        	&lt;username&gt;jasper&lt;/username&gt;
		        	&lt;password&gt;tomcat&lt;/password&gt;
		        &lt;/configuration&gt;
		    &lt;/plugin&gt;
&lt;!-- ... --&gt;

&lt;pluginRepositories&gt;
		&lt;pluginRepository&gt;
			&lt;id&gt;mojo.snapshots&lt;/id&gt;
			&lt;url&gt;http://snapshots.repository.codehaus.org/&lt;/url&gt;
			&lt;releases&gt;
				&lt;enabled&gt;false&lt;/enabled&gt;
			&lt;/releases&gt;
			&lt;snapshots&gt;
				&lt;updatePolicy&gt;daily&lt;/updatePolicy&gt;
			&lt;/snapshots&gt;
		&lt;/pluginRepository&gt;
	&lt;/pluginRepositories&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>OK,</p>
<p>Second try to post the pom.xml parts:</p>
<p>&lt;code&gt;<br />
&lt;plugin&gt;<br />
		        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
		        &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;<br />
		        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br />
		        &lt;configuration&gt;<br />
		        	&lt;update&gt;true&lt;/update&gt;<br />
		        	&lt;mode&gt;both&lt;/mode&gt;<br />
		        	&lt;contextFile&gt;src/main/resources/META-INF/context.xml&lt;/contextFile&gt;<br />
		        	&lt;username&gt;jasper&lt;/username&gt;<br />
		        	&lt;password&gt;tomcat&lt;/password&gt;<br />
		        &lt;/configuration&gt;<br />
		    &lt;/plugin&gt;<br />
&lt;!&#8211; &#8230; &#8211;&gt;</p>
<p>&lt;pluginRepositories&gt;<br />
		&lt;pluginRepository&gt;<br />
			&lt;id&gt;mojo.snapshots&lt;/id&gt;<br />
			&lt;url&gt;http://snapshots.repository.codehaus.org/&lt;/url&gt;<br />
			&lt;releases&gt;<br />
				&lt;enabled&gt;false&lt;/enabled&gt;<br />
			&lt;/releases&gt;<br />
			&lt;snapshots&gt;<br />
				&lt;updatePolicy&gt;daily&lt;/updatePolicy&gt;<br />
			&lt;/snapshots&gt;<br />
		&lt;/pluginRepository&gt;<br />
	&lt;/pluginRepositories&gt;<br />
&lt;/code&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jasper Vandaele</title>
		<link>http://www.karthikeyanc.com/blog/index.php/2009/12/step-by-step-guide-setup-seam-2-2-0-ga-based-integration-testing-with-maven-testng-cobertura/comment-page-1/#comment-239</link>
		<dc:creator>Jasper Vandaele</dc:creator>
		<pubDate>Thu, 29 Apr 2010 21:12:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.karthikeyanc.com/blog/?p=140#comment-239</guid>
		<description>Great article!

This is the only clear explanation that I could find of how to run SeamTests with m2 that actually works.

What I normally do to use a different configuration for testing than for the main code, is the put the a file on the same location in the src/test/resources. If you use a maven version &gt; 2.0.8 and surefire &gt;= 2.4.3 the test resources are loaded first in the classpath. There were some bugs in previous version of maven and surefire where the classpath was inversed.

So, I tried to put a persistence.xml in src/test/resources/META-INF/persistence.xml
But for some reason, the one under src/main/resources is used in the test phase :( If some one knows why my theory is not working, or knows another way to solve the difference in the JNDI names,  your thoughts on this are always welcome.

I also use the maven-tomcat plugin to deploy the app. Here goes the plugin config:


		        org.codehaus.mojo
		        tomcat-maven-plugin
		        1.0-SNAPSHOT
		        
		        	true
		        	both
		        	src/main/resources/META-INF/context.xml
		        	configure.this.user.in.tomcat-users.xml.with.role.manager
		        	thepassword
		        
		    

With this plugin you can deploy the war on a running tomcat with mvn tomcat:deploy . I have to skip the tests due to the JNDI name problem.

To download the plugin, you can use this repository:


		
			mojo.snapshots
			http://snapshots.repository.codehaus.org/
			
				false
			
			
				daily
			
		
	

Enjoy</description>
		<content:encoded><![CDATA[<p>Great article!</p>
<p>This is the only clear explanation that I could find of how to run SeamTests with m2 that actually works.</p>
<p>What I normally do to use a different configuration for testing than for the main code, is the put the a file on the same location in the src/test/resources. If you use a maven version &gt; 2.0.8 and surefire &gt;= 2.4.3 the test resources are loaded first in the classpath. There were some bugs in previous version of maven and surefire where the classpath was inversed.</p>
<p>So, I tried to put a persistence.xml in src/test/resources/META-INF/persistence.xml<br />
But for some reason, the one under src/main/resources is used in the test phase <img src='http://www.karthikeyanc.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  If some one knows why my theory is not working, or knows another way to solve the difference in the JNDI names,  your thoughts on this are always welcome.</p>
<p>I also use the maven-tomcat plugin to deploy the app. Here goes the plugin config:</p>
<p>		        org.codehaus.mojo<br />
		        tomcat-maven-plugin<br />
		        1.0-SNAPSHOT</p>
<p>		        	true<br />
		        	both<br />
		        	src/main/resources/META-INF/context.xml<br />
		        	configure.this.user.in.tomcat-users.xml.with.role.manager<br />
		        	thepassword</p>
<p>With this plugin you can deploy the war on a running tomcat with mvn tomcat:deploy . I have to skip the tests due to the JNDI name problem.</p>
<p>To download the plugin, you can use this repository:</p>
<p>			mojo.snapshots<br />
			<a href="http://snapshots.repository.codehaus.org/" rel="nofollow">http://snapshots.repository.codehaus.org/</a></p>
<p>				false</p>
<p>				daily</p>
<p>Enjoy</p>
]]></content:encoded>
	</item>
</channel>
</rss>
