<?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>The eflow blog &#187; spring</title>
	<atom:link href="http://blog.eflow.org/archives/tag/spring/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eflow.org</link>
	<description>Insert some amazingly witty tagline here</description>
	<lastBuildDate>Fri, 23 Apr 2010 03:19:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Migrating from Junit3 to Junit4</title>
		<link>http://blog.eflow.org/archives/63</link>
		<comments>http://blog.eflow.org/archives/63#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:37:52 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[openmrs]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.eflow.org/?p=63</guid>
		<description><![CDATA[While migrating from JUnit 3.x to the new 4.x framework, one method I found that was missing was Spring&#8217;s getLoadCount() method on the 
AbstractDepenpendencyInjectionTest. The value returned allowed us to tell whether a test was running by itself or in a group a tests (like with the ant junit-report target or right-clicking on /test/src and [...]]]></description>
			<content:encoded><![CDATA[<p>While migrating from <a href="http://www.junit.org/">JUnit</a> 3.x to the new 4.x framework, one method I found that was missing was <a href="http://www.springframework.org">Spring</a>&#8217;s <a href="http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/test/AbstractDependencyInjectionSpringContextTests.html#getLoadCount()">getLoadCount()</a> method on the <a href='http://junit.org'><img src="http://blog.eflow.org/wp-content/uploads/2008/08/junit-logo.jpg" alt="" title="junit logo" align="right" border="0" /></a><br />
<a href="http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/test/AbstractDependencyInjectionSpringContextTests.html">AbstractDepenpendencyInjectionT</a><a href="http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/test/AbstractDependencyInjectionSpringContextTests.html">est</a>. The value returned allowed us to tell whether a test was running by itself or in a group a tests (like with the ant junit-report target or right-clicking on /test/src and choosing run-as junit test).</p>
<p>Having this method was useful for two reasons:</p>
<ol>
<li>A test like <a href="http://dev.openmrs.org/browser/openmrs/trunk/test/api/org/openmrs/test/CreateInitialDataSet.java">CreateInitialDataSet</a> that is meant to be configured and run alone.  If this test sees that its being run in a group, it returns early and doesn&#8217;t actually run the test</li>
<li>The module tests needed to have the application context refreshed before running.  To do this, I made the previous test mark the context as &#8220;dirty&#8221; so that the test directly following it would have a fresh app context.</li>
</ol>
<p>There were actually two separate solutions:</p>
<ol>
<li>All tests extend <a href="http://dev.openmrs.org/browser/openmrs/trunk/test/api/org/openmrs/test/BaseContextSensitiveTest.java">BaseContextSensitiveTest</a> for convenience methods and setup.  Every junit class will invoke this class and its constructor.  By adding a static variable <code>loadCount</code> and incrementing that in the constructor, I am able to know how many tests have been run up to that point.</li>
<li>The application context doesn&#8217;t need to be marked as dirty.  The dummy method could actually be removed without replacement.</li>
</ol>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=63" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/63/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenMRS Hibernate Transactions</title>
		<link>http://blog.eflow.org/archives/24</link>
		<comments>http://blog.eflow.org/archives/24#comments</comments>
		<pubDate>Fri, 18 Jan 2008 18:11:32 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[openmrs]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[transacation annotations]]></category>

		<guid isPermaLink="false">http://eflow.org/blog/archives/24</guid>
		<description><![CDATA[I&#8217;m going to post this here as a reminder to other OpenMRS developers (and myself) and to hopefully save a few hours/days of debugging.  The key to getting transactions to work correctly in the webapp is to, well, tell Spring that we&#8217;re in a transaction.  You can do this by simply putting an [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to post this here as a reminder to other OpenMRS developers (and myself) and to hopefully save a few hours/days of debugging.  The key to getting transactions to work correctly in the webapp is to, well, tell Spring that we&#8217;re in a transaction.  You can do this by simply putting an <code>@Transactional</code> annotation in the *Service java interface.</p>
<p>Without that key piece of text, the service and its methods will still work.  However, they&#8217;ll work in a readonly kind of way.  All data written to the database will be rolled back when the body of work has completed.  This little error manifested itself recently after our reporting code-a-thon.  During the event we had to create a new API service, which is only done maybe a few times a year.  The service didn&#8217;t get the @Transactional tag and so therefore all database editing failed that went through the ReportService.  The unit tests set up for the object passed, but that is because a unit test happens all within a single transaction &#8212; the rollback is always done after the completion of the test anyway.</p>
<p>I added a note to http://openmrs.org/wiki/OpenMRS_API about the requirement, but I&#8217;m sure there will be an OpenMRS developer in the future struggling with their object not saving or updating in the database and be completely baffled by it.</p>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=24" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/24/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenMRS Tomcat Startup Error</title>
		<link>http://blog.eflow.org/archives/25</link>
		<comments>http://blog.eflow.org/archives/25#comments</comments>
		<pubDate>Thu, 17 Jan 2008 18:07:09 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[openmrs]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://eflow.org/blog/archives/25</guid>
		<description><![CDATA[I recently had a very frustrating error that I want to document here for future Googling&#8217;s sake.  After a non-ideal shutdown of Tomcat and/or the jvm I was unable to start the OpenMRS webapp. Tomcat was giving this error in its log file:
Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans.xsd'
This is somewhat expected with the move [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a very frustrating error that I want to document here for future Googling&#8217;s sake.  After a non-ideal shutdown of Tomcat and/or the jvm I was unable to start the OpenMRS webapp. Tomcat was giving this error in its log file:</p>
<p><code>Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans.xsd'</code></p>
<p>This is somewhat expected with the move from Spring 2.0 to 2.5.  As of <a href="http://www.springframework.org/">Spring Framework</a> 2.5 the new url to use in the application context is</p>
<p><code>http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</code></p>
<p>but  even after making this change in the code and redeploying the webapp, Tomcat refused to start giving the same url (with just spring-beans.xsd).</p>
<p>Solution:</p>
<p>A Spring definition file (namely applicationContext-service.xml) was being cached in Tomcat&#8217;s work directory and not being replaced on webapp deploy for some reason.  I uninstalled the webapp and then deleted all files under &lt;tomcathome&gt;/work/localhost.  Upon installing openmrs and starting Tomcat again everything started up as expected.</p>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=25" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/25/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
