<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eric Lefevre-Ardant on Java &#38; Agile &#187; spring</title>
	<atom:link href="http://ericlefevre.net/wordpress/category/java/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericlefevre.net/wordpress</link>
	<description>Eric&#039;s Earnest Elucidations</description>
	<lastBuildDate>Mon, 06 Feb 2012 06:08:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Back from Open Source eXchange</title>
		<link>http://ericlefevre.net/wordpress/2008/11/12/back-from-open-source-exchange/</link>
		<comments>http://ericlefevre.net/wordpress/2008/11/12/back-from-open-source-exchange/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 22:31:06 +0000</pubDate>
		<dc:creator>Eric Lefevre-Ardant</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ericlefevre.net/wordpress/?p=491</guid>
		<description><![CDATA[Interesting day at Open Source eXchange, a conference organized by Xebia and SkillsMatter. It was fun meeting Wendy Devolder (now CEO of SkillsMatter) formerly from Valtech (I worked with her at Valtech London back in 2001-2002) and Michael Isvy (with &#8230; <a href="http://ericlefevre.net/wordpress/2008/11/12/back-from-open-source-exchange/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="Conference Sign by elefevre7, on Flickr" href="http://www.flickr.com/photos/elefevre/3026105030/"><img class="alignright" src="http://farm4.static.flickr.com/3245/3026105030_d660e0df90_m.jpg" alt="Conference Sign" width="180" height="240" /></a>Interesting day at <a href="http://skillsmatter.com/event/home/skills-matter-open-source-exchange">Open Source eXchange</a>, a conference organized by <a href="http://www.xebia.fr/">Xebia</a> and <a href="http://skillsmatter.com/">SkillsMatter</a>.</p>
<p>It was fun meeting Wendy Devolder (now CEO of SkillsMatter) formerly from Valtech (I worked with her at Valtech London back in 2001-2002) and Michael Isvy (with SpringSource) also ex-former. Also had nice chats with <a href="http://glaforge.free.fr/">Guillaume Laforge</a>, <a href="http://blogs.sun.com/alexismp/">Alexis Moussine-Pouchkine</a>, <a href="http://www.antoniogoncalves.org/">Antonio Goncalvez</a> and many others, including 2 more Valtech alumni.</p>
<p>Aside from the presenters, most of the participants seemed to be tech guys working for blue chips.</p>
<p><strong>Overview of the presentations</strong></p>
<p>Michael Isvy from <a href="http://www.springsource.com/">SpringSource</a> did a valuable demonstration of <a href="http://www.springsource.com/products/suite/dmserver">DM Server</a>. I find it surprising that it bets on <a href="http://www.osgi.org/">OSGi</a> (I cannot get myself to like it). But it seems mostly to become a good server, further strengthened by <a href="http://blog.valtech.fr/wordpress/2008/11/11/springsource-rachete-g2one-que-deviennent-groovy-grails/">the recent addition of Groovy to their portfolio (post in French)</a>.</p>
<p>Spring DM Server seems to be mainly Tomcat + Spring Framework + OSGi. Supposed to be 100% OSS, but it is not easy to guess when looking at their <a href="http://www.springsource.com/products/suite/dmserver">website</a>&#8230;</p>
<p><a href="http://tugdualgrall.blogspot.com/">Tugdual Grall</a> did an entertaining presentation of <a href="http://www.exoplatform.com/">eXo Platform</a>. The <a href="http://www.exoplatform.com/portal/public/en/product/webos/overview">WebOS part</a> is impressive (but run from the local machine, so presumably much slower when used over the net). But I can&#8217;t imagine it winning most hearts. My money is currently on using separate apps such as <a href="http://docs.google.com/">Google Docs</a>.</p>
<p>Guillaume Laforge, formely from <a href="http://www.g2one.com/">G2One</a> and now with SpringSource, did his classic Groovy/Grails presentation. Not much to add to what <a href="http://www.parisjug.org/xwiki/bin/view/Meeting/20080909">he has said at Paris JUG in September</a>.</p>
<p>Oh yes, one thing: he hopes that Groovy will be used to script deployment under Spring DM Server. I totally agree.</p>
<p>Antonio Goncalvez presented JEE6, due for release in 2009 Q2. My feeling is that it is just getting too complex, in the sense that it is getting impossible to know about all its various standards and API (reminding me of the whole <a href="http://72.249.21.88/nonintersecting/?year=2006&amp;monthnum=11&amp;day=15&amp;name=the-s-stands-for-simple&amp;page=">SOAP fiasco</a>). The JEE6 team knows about this and has a plan where only subsets would be used. As for me, I think most developers will just stick with Spring or some other simpler options (though I guess Spring is getting less and less simple&#8230;).</p>
<p>Another thing: it seems <a href="http://www.eclipse.org/eclipselink/">EclipseLink</a> is used as the reference implementation for JPA by GlassFish. EclipseLink is in fact TopLink, only Open Source. Interesting comeback, for a tool considered as dead after the Hibernate landslide.</p>
<p>Alexis Moussine-Pouchkine talked about <a href="https://glassfish.dev.java.net/">GlassFish</a> as a full-fledged JEE Server, open source, much faster and still as powerful than Weblogic and WebSphere. Strangely, few references to <a href="http://www.jboss.org/">JBoss</a>, except to mention that it (GlassFish) seems to have more downloads.</p>
<p><a href="http://metacosm.wordpress.com/">Christophe Laprun</a> from <a href="http://jboss-portal.org/">JBoss</a> had a session on JBoss Portal. I didn&#8217;t follow all of it (did work for Valtech instead). Portals and portlets are not that interesting to me. I&#8217;m glad other people work on them.</p>
<p><em><span style="font-style: normal;">Hughes le Bars</span></em> &amp; Oktay Istanbullu from Yahoo! presented <a href="http://hadoop.apache.org/">Hadoop,</a> a solution to do grid computing for storage of very large data sets (in the order of PetaBytes). I couldn&#8217;t quite understand all the presentation, but the whole thing seems terribly interesting. It is used for web search and ads matching by Yahoo!</p>
<p>Oh, Hughes also mentioned <a href="http://wiki.apache.org/incubator/PigProposal">PIG</a>, apparently an equivalent of SQL, just better (!).</p>
<p>Drinks were paid after the conference, and a good time was had by all.</p>
<p>Check out <a href="http://flickr.com/photos/elefevre/sets/72157608987860166/">my pictures of the conference on flickr</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericlefevre.net/wordpress/2008/11/12/back-from-open-source-exchange/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merging lists in a Spring configuration file</title>
		<link>http://ericlefevre.net/wordpress/2008/04/02/merging-lists-in-a-spring-configuration-file/</link>
		<comments>http://ericlefevre.net/wordpress/2008/04/02/merging-lists-in-a-spring-configuration-file/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 09:09:19 +0000</pubDate>
		<dc:creator>Eric Lefevre-Ardant</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ericlefevre.net/wordpress/2008/04/02/merging-lists-in-a-spring-configuration-file/</guid>
		<description><![CDATA[Spring provides useful types for creating lists of values. However, it is not as good for merging lists. Here is an option. A list usually looks like this in a Spring configuration file: &#60;bean id="aList" class="org.springframework.beans.factory.config.ListFactoryBean"&#62; &#60;property name="sourceList"&#62; &#60;list&#62; &#60;value&#62;a &#8230; <a href="http://ericlefevre.net/wordpress/2008/04/02/merging-lists-in-a-spring-configuration-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://springframework.org/">Spring</a> provides useful types for creating <a href="http://static.springframework.org/spring/docs/2.0.x/reference/beans.html">lists</a> of values. However, it is not as good for <em>merging</em> lists. Here is an option.</p>
<p><span id="more-168"></span> A list usually looks like this in a Spring configuration file:</p>
<blockquote><p><code>&lt;bean id="aList" class="org.springframework.beans.factory.config.ListFactoryBean"&gt;<br />
&lt;property name="sourceList"&gt;<br />
&lt;list&gt;<br />
&lt;value&gt;a list element&lt;/value&gt;<br />
&lt;value&gt;another list element&lt;/value&gt;<br />
&lt;/list&gt;<br />
&lt;/property&gt;<br />
&lt;/bean&gt;</code></p></blockquote>
<p>Or, if you are the fun-loving type, you can write this as follows:</p>
<blockquote><p><code>&lt;util:list id="someList"&gt;<br />
&lt;value&gt;a list element&lt;/value&gt;<br />
&lt;value&gt;another list element&lt;/value&gt;<br />
&lt;/util:list&gt;</code></p></blockquote>
<p>&#8230;as long as you provide the appropriate schema with <code>xmlns:util="http://www.springframework.org/schema/util"</code>, as described in the <a href="http://static.springframework.org/spring/docs/2.0.x/reference/xsd-config.html">Spring documentation</a>.</p>
<p>What you cannot do, however, is merge two lists. You add can a list bean to your list, but it will only be considered as a separate item; it won&#8217;t be merged.</p>
<p>A solution is to provide a new Spring bean that supports lists.</p>
<blockquote><p><code><br />
package com.company.utils.spring;<br />
import java.util.*;<br />
import org.springframework.beans.factory.config.ListFactoryBean;<br />
public class ListMergerFactory extends ListFactoryBean {<br />
private final List listOfLists;<br />
public ListMergerFactory(List listOfLists) throws Exception {<br />
this.listOfLists = listOfLists;<br />
setSourceList(new ArrayList());<br />
}<br />
protected Object createInstance() {<br />
List listOrigin = (List) super.createInstance();<br />
for (Iterator iter = listOfLists.iterator(); iter.hasNext();) {<br />
List element = (List) iter.next();<br />
listOrigin.addAll(element);<br />
}<br />
return listOrigin;<br />
}<br />
}</code></p></blockquote>
<p>This will let you define a list as follows (I don&#8217;t have the source for this part anymore, so some details may be wrong):</p>
<blockquote><p><code>&lt;bean id="aList" class="com.company.utils.spring.ListMergerFactory"&gt;<br />
&lt;constructor-arg value="myOtherList"/&gt;<br />
&lt;property name="sourceList"&gt;<br />
&lt;list&gt;<br />
&lt;value&gt;a list element&lt;/value&gt;<br />
&lt;value&gt;another list element&lt;/value&gt;<br />
&lt;/list&gt;<br />
&lt;/property&gt;<br />
&lt;/bean&gt;</code></p></blockquote>
<p>The downside is that you cannot use the <code>util:list</code> shortcut for defining a list that is made of another list.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericlefevre.net/wordpress/2008/04/02/merging-lists-in-a-spring-configuration-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unitils: a better Gienah?</title>
		<link>http://ericlefevre.net/wordpress/2007/09/06/unitils-a-better-gienah/</link>
		<comments>http://ericlefevre.net/wordpress/2007/09/06/unitils-a-better-gienah/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 10:59:26 +0000</pubDate>
		<dc:creator>Eric Lefevre-Ardant</dc:creator>
				<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://ericlefevre.net/wordpress/2007/09/06/unitils-a-better-gienah/</guid>
		<description><![CDATA[On my current project, I am using Gienah as a way to integrate JUnit tests with Spring. I am rather pleased with the result, keeping my unit tests quite clean. I just heard today about Unitils, a more ambitious tool. &#8230; <a href="http://ericlefevre.net/wordpress/2007/09/06/unitils-a-better-gienah/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On my current project, <a href="http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/">I am using Gienah</a> as a way to integrate JUnit tests with Spring. I am rather pleased with the result, keeping my unit tests quite clean.</p>
<p>I just heard today about <a href="http://unitils.sourceforge.net/">Unitils</a>, a more ambitious tool. In addition to Spring, it supports TestNG, DbUnit, EasyMock, and Hibernate (ie. almost all that we are using here!). It also provides a number of additional services, such as helper asserts.</p>
<p>Especially intriguing are two things:</p>
<ul>
<li>they recommend temporarily removing some db constraints, and provide help to do so (&#8220;<em>To keep database tests maintainable, test data files have to be as small as possible. (Referential) constraints however don&#8217;t help you to achieve this. We advise to disable all foreign key and not null constraints. Doing so makes it possible to specify only the data that matters for your test.</em>&#8220;)</li>
<li>they handle database versions is a way very similar to Ruby on Rails (&#8220;<em>The database maintainer monitors a directory on the filesystem that contains DDL scripts for creating the structure of the database. The name of these scripts should comply with following naming convention: &lt;version&gt;_&lt;some name&gt;.sql. For example: 001_create_person_table.sql, 002_create_car_table.sql</em>&#8220;)</li>
</ul>
<p>See <a href="http://unitils.sourceforge.net/spring_article.html">here</a> for details.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericlefevre.net/wordpress/2007/09/06/unitils-a-better-gienah/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run XFire 1.x with Spring 2.x and Maven 2.x</title>
		<link>http://ericlefevre.net/wordpress/2007/04/23/how-to-run-xfire-1x-with-spring-2x-and-maven-2x/</link>
		<comments>http://ericlefevre.net/wordpress/2007/04/23/how-to-run-xfire-1x-with-spring-2x-and-maven-2x/#comments</comments>
		<pubDate>Mon, 23 Apr 2007 16:13:04 +0000</pubDate>
		<dc:creator>Eric Lefevre-Ardant</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[xfire]]></category>

		<guid isPermaLink="false">http://ericlefevre.net/wordpress/2007/04/23/how-to-run-xfire-1x-with-spring-2x-and-maven-2x/</guid>
		<description><![CDATA[In version 1.2.5 of XFire, a module called xfire-spring is necessary to run it together with , well, Spring. The issue is that the POM file for it is designed to run with Spring 1.2.x. This is an excerpt from &#8230; <a href="http://ericlefevre.net/wordpress/2007/04/23/how-to-run-xfire-1x-with-spring-2x-and-maven-2x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In version 1.2.5 of <a href="http://xfire.codehaus.org/">XFire</a>, a module called xfire-spring is necessary to run it together with , well, Spring. The issue is that the <a href="http://maven.apache.org/ref/2.0.4/maven-model/maven.html">POM</a> file for it is designed to run with  Spring 1.2.x.</p>
<p><span id="more-98"></span> This is an excerpt from file xfire-spring-1.2.5.pom:</p>
<blockquote><p><code>&lt;dependency&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring-mock&lt;/artifactId&gt;<br />
&lt;version&gt;1.2.6&lt;/version&gt;<br />
&lt;scope&gt;test&lt;/scope&gt;<br />
&lt;/dependency&gt;<br />
...<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring&lt;/artifactId&gt;<br />
&lt;/dependency&gt;</code></p></blockquote>
<p>This last bit is especially deceitful, as it refers to a &#8216;spring&#8217; module&#8230; that only exists in Spring 1.x, not in Spring 2.x.</p>
<p>Suppose that you have your own POM where both Spring 2.x and XFire are configured:</p>
<blockquote><p><code>&lt;dependency&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring-core&lt;/artifactId&gt;<br />
&lt;version&gt;2.0.2&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
...<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.codehaus.xfire&lt;/groupId&gt;<br />
&lt;artifactId&gt;xfire-spring&lt;/artifactId&gt;<br />
&lt;version&gt;1.2.5&lt;/version&gt;<br />
&lt;/dependency&gt;</code></p></blockquote>
<p>Apparently, because of the configuration of xfire-spring, when running mvn compile, the classpath uses modules from Spring 1.x, although as runtime, modules from Spring 2.x are correctly used.</p>
<p>As long as you are using methods available both in Spring 1.x and Spring 2.x, this won&#8217;t really be a problem. This is in fact often the case, which might explain why I never found any reference to this problem on the web</p>
<p>But if you are, like me, using methods only in Spring 2., you&#8217;ll get a compilation error.</p>
<p>The fix is to direct Maven to explicitly exclude Spring 1.x:</p>
<blockquote><p><code><br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.codehaus.xfire&lt;/groupId&gt;<br />
&lt;artifactId&gt;xfire-spring&lt;/artifactId&gt;<br />
&lt;version&gt;1.2.5&lt;/version&gt;<br />
&lt;exclusions&gt;<br />
&lt;exclusion&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring&lt;/artifactId&gt;<br />
&lt;/exclusion&gt;<br />
&lt;/exclusions&gt;<br />
&lt;/dependency&gt;</code></p></blockquote>
<p>Update (25/04/07):  another thing seems necessary to get this to work.</p>
<p>The example provided with the XFire distribution has a service.xml file that looks like this:</p>
<blockquote><p><code>&lt;beans xmlns="http://xfire.codehaus.org/config/1.0"&gt;<br />
&lt;service&gt;<br />
&lt;name&gt;LotDonneesService&lt;/name&gt;<br />
...</code></p></blockquote>
<p>In practice, it seems to work with Spring 1.x but not with Spring 2.x. The correct syntax is:</p>
<blockquote><p><code> &lt;beans&gt;<br />
&lt;service xmlns="http://xfire.codehaus.org/config/1.0"&gt;<br />
&lt;name&gt;LotDonneesService&lt;/name&gt;<br />
...</code></p></blockquote>
<p>This issue is, in fact, described in the <a href="http://xfire.codehaus.org/services.xml+Reference">official documentation for XFire</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericlefevre.net/wordpress/2007/04/23/how-to-run-xfire-1x-with-spring-2x-and-maven-2x/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Gienah: inject Spring dependencies in your JUnit 4 tests</title>
		<link>http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/</link>
		<comments>http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/#comments</comments>
		<pubDate>Wed, 14 Mar 2007 14:08:29 +0000</pubDate>
		<dc:creator>Eric Lefevre-Ardant</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/</guid>
		<description><![CDATA[I wanted a way of using my test with dependencies coming from my Spring definition. The first approach is by requesting the bean from Spring before the tests are being executed: public class MyDaoImplTest { @BeforeClass public static void setup() &#8230; <a href="http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wanted a way of using my test with dependencies coming from my Spring definition.<br />
<span id="more-90"></span></p>
<p>The first approach is by requesting the bean from Spring before the tests are being executed:</p>
<p><code> </code></p>
<pre>
<blockquote>

public class MyDaoImplTest {
	@BeforeClass
	public static void setup() {
		myDao = (MyDaoImpl) TestSpringUtil.getFactory().getBean("myDao");
	}
}</blockquote>
</pre>
<p>Notice that you need a specific SpringUtil class if you want (like me) to have a slightly different configuration for your beans under test. In my case, I needed them to point to a test database instance, not to the production instance.<br />
The code was for JUnit 4, of course, but that&#8217;s extremely similar in JUnit 3.x:</p>
<blockquote><p><code> </code></p>
<pre>
public class MyDaoImplTest extends TestCase {
	public void setUp() {
		myDao = (MyDaoImpl) TestSpringUtil.getFactory().getBean("myDao");
	}
}</pre>
</blockquote>
<p>(written from the top of my head)</p>
<p>If you do not want to get the bean manually from Spring, one option is to declare your tests in your Spring configuration. Quite ugly of course: I do not want to burden my configuration with tests (though that can be mitigated by having a separate, additional Spring configuration for test classes).</p>
<p>An alternative is to use the class AbstractDependencyInjectionSpringContextTests (cute name) from Spring. That will allow you <a href="http://www.springframework.org/docs/reference/testing.html#testing-fixture-di">declare your dependencies in your test classes and wait for Spring to populate them</a>.</p>
<blockquote>
<pre><code>public class MyDaoImplTest extends
        AbstractDependencyInjectionSpringContextTests {

	private MyDaoImpl myDao;

	public void setMyDao(MyDaoImpl myDao) {
		this.myDao = myDao;
	}

	// specifies the Spring configuration to load for this fixture
	protected String[] getConfigLocations() {
		// applicationContext-dbaccess-test.xml is the place where access to my test db
		// is defined and overrides access defined in applicationContext.xml
		return new String[] {
		        "classpath:com/company/application/applicationContext-dbaccess-test.xml",
		        "classpath:com/company/application/applicationContext.xml" };
	}
}</code></pre>
</blockquote>
<p>The drawback, though, is that you are stuck with JUnit 3.x. The Spring team has not ported their class to JUnit 4.x yet.</p>
<p>Enter <a href="http://code.google.com/p/gienah-testing/">Gienah Testing</a>.</p>
<p><a href="http://code.google.com/p/gienah-testing/">Gienah</a> is a very simple tool that let you weave declaratively your test classes with their dependencies:</p>
<blockquote>
<pre><code>@RunWith(value = SpringRunner.class)
@Configuration(locations = {
        "classpath:com/company/application/applicationContext-dbaccess-test.xml",
        "classpath:com/company/application/applicationContext.xml" })
public class MyDaoImplTest {

	@Dependency
	private MyDaoImpl myDao;

}</code></pre>
</blockquote>
<p>That&#8217;s it! Clean and easy.</p>
<p>Gienah is still in version E0.3, but seems already very useful. Check out their <a href="http://groups.google.com/group/gienah-testing/web/project-5-minutes-tutorial">5 mins tutorial</a>, it&#8217;s well worth it.</p>
<p>A last word: Gienah can handle transactional contexts as well, so that you can test your collections in your unit tests, even if they are lazy loaded. Just add the @Transactional annotation:</p>
<blockquote><p><code> </code></p>
<pre>	@Test
	@Transactional
	public void testListEmpty() {
		assertEquals(0, myDao().getAnObject().getDependentObjectList().size());
	}</pre>
</blockquote>
<p>However, a limitation on that is the name of the transaction manager in your Spring configuration <strong>must</strong> be exactly &#8220;transactionManager&#8221;, not &#8220;txManager&#8221; or anything else. I couldn&#8217;t find a way to specify it. This is unfortunate as Spring claims to find the transaction manager whatever its name is. See <a href="http://www.springframework.org/docs/reference/testing.html#testing-tx">Testing &#8211; Transaction Management</a>:</p>
<blockquote><p>AbstractTransactionalSpringContextTests  depends on a PlatformTransactionManager bean being defined in the application context. The name doesn&#8217;t matter, due to the use of autowire by type.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ericlefevre.net/wordpress/2007/03/14/gienah-inject-dependencies-in-your-junit-4-tests/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

