<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CodeDependents &#187; dbunit</title>
	<atom:link href="http://codedependents.com/tag/dbunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://codedependents.com</link>
	<description>Two Geeks Walk Into A Blog</description>
	<lastBuildDate>Fri, 27 Jan 2012 20:53:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codedependents.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>CodeDependents &#187; dbunit</title>
		<link>http://codedependents.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codedependents.com/osd.xml" title="CodeDependents" />
	<atom:link rel='hub' href='http://codedependents.com/?pushpress=hub'/>
		<item>
		<title>11 Lesser Known 3rd Party Libraries For Every Project</title>
		<link>http://codedependents.com/2009/10/26/11-lesser-known-3rd-party-libraries-for-every-project/</link>
		<comments>http://codedependents.com/2009/10/26/11-lesser-known-3rd-party-libraries-for-every-project/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 15:17:18 +0000</pubDate>
		<dc:creator>Benjamin Darfler</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[apache commons]]></category>
		<category><![CDATA[c3p0]]></category>
		<category><![CDATA[dbunit]]></category>
		<category><![CDATA[google collections]]></category>
		<category><![CDATA[hamcrest]]></category>
		<category><![CDATA[joda time]]></category>
		<category><![CDATA[mockito]]></category>
		<category><![CDATA[slf4j]]></category>

		<guid isPermaLink="false">http://codedependents.com/?p=238</guid>
		<description><![CDATA[The Java 3rd party library ecosystem is a wild wild place. While everyone has heard of the big players such as Spring and Hibernate, too often the more humble, but equally important, libraries get left out in the cold.  It is for that reason that I give you the 11 lesser known 3rd party libraries [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&amp;blog=7973493&amp;post=238&amp;subd=codedependents&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-243" title="pennies_in_jar_small" src="http://codedependents.files.wordpress.com/2009/10/pennies_in_jar_small1.jpg?w=106&#038;h=150" alt="pennies_in_jar_small" width="106" height="150" /> The Java 3rd party library ecosystem is a wild wild place. While everyone has heard of the big players such as Spring and Hibernate, too often the more humble, but equally important, libraries get left out in the cold.  It is for that reason that I give you the 11 lesser known 3rd party libraries that no project should be without.</p>
<h2>Unit Testing</h2>
<p>As always, the easiest place to start playing around with new libraries and languages is in unit tests.  I&#8217;m convinced they would be worth writing if only as an outlet for developers to try new and interesting tools, let along the code quality improvements.</p>
<h3>DBUnit</h3>
<p>While we can quibble over including databases in unit tests or if they are integration tests the fact of the matter is that at some point most people write a unit test that requires a database with some preexisting data.  Thats when <a href="http://www.dbunit.org/">DBUnit</a> shines. It has the ability to use xml from a file or a string or any other type of input to clean and populate database tables with ease.  It even has some nice utilities for asserting data after a test has run.</p>
<h3>Mockito</h3>
<p>On the other end of the spectrum from full blown database integration is mocking. When you need to disentangle an object from its myriad of dependancies and test it in isolation mock objects come to the rescue. There are a number of solutions out there but <a href="http://mockito.org/">Mockito</a> takes the cake. To see why I prefer it to EasyMock check out their <a href="http://code.google.com/p/mockito/wiki/MockitoVSEasyMock">comparison</a>. They&#8217;ve even added some <a href="http://mockito.googlecode.com/svn/branches/1.8.0/javadoc/org/mockito/BDDMockito.html">niceties</a> for <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development">BDD</a> style testing.</p>
<h3>Hamcrest Matchers</h3>
<p>Since <a href="http://junit.sourceforge.net/doc/ReleaseNotes4.4.html">Junit 4.4</a>, a core set of <a href="http://code.google.com/p/hamcrest/">hamcrest matchers</a> has been included with the distribution and has gone a long way to simplifying assertions by through a pseduo english DSL. For even more power you can include the whole hamcrest matcher jar and start playing with features such as asserting the contents of collections.</p>
<h2>Apache Commons</h2>
<h3>Configuration</h3>
<p>Most projects start with one properties file and before you know it there are two, then three, then ten and it gets out of control. You have static singletons that pull files off the class path and you&#8217;ve gone off the deep end. Thats why I say start <a href="http://commons.apache.org/configuration/">Commons Configurations</a>, even for that first file. Not only does it greatly simplify dealing with properties from the api point of view but it allows for pulling properties from xml, jdbc, property files, and much more. Its can even work as a simple api for dealing with xml in a jiffy.</p>
<h3>DbUtils</h3>
<p>These days with Spring JDBC, iBatis, Hibernate, ActiveObjects, and a host of other frameworks and libraries for dealing with JDBC its pretty easy to never have to directly touch the stuff.  However, if you find yourself in the hell which is closing a connection, session, and statement (with all the null checks and finals and exceptions and oh dear god) then <a href="http://commons.apache.org/dbutils/">Commons DbUtils </a>is for you.  A simple close() method is provided which handles all the null checking and try catching and so on. So basic and yet so helpful.</p>
<h3>IO</h3>
<p>This one might be a bit more obscure but if you have ever needed to simply read the contents of a file you have no doubt been stymied by which reader gets wrapped by which buffered writer and who flushes what. <a href="http://commons.apache.org/io/">Commons IO</a> provides a beautifully simple api for file reading as well as some nice utility methods, similar to DbUtils, for closing all those annoying objects with out all the hassle.</p>
<h3>Lang</h3>
<p>If there was one library on my list it would come down to this or Google Collections. <a href="http://commons.apache.org/lang/">Commons Lang</a> is the place for every utility method you have ever thought of writing. Every time you have though of creating a null safe version of any of the String methods, StringUtils has your back. If you have though of doing the same for Booleans then BooleanUtils is for you. Same for Object and ObjectUtils. But it doesnt stop there, StringUtils has more methods than you can shake a stick at and then there is the Builder package. The Builder package contains a Hashcode, ToString, Equals and CompareTo builder. Better yet they contain methods to build these values dynamically based on reflection. I&#8217;ve taken to making a base class from which all my domain objects inherit  that simply overrides Hashcode, ToString and Equals with the reflection based builders. Never again do you need to create these annoying methods by hand or have Eclipse generate them only to forget to regenerate when you add another field.</p>
<h2>New Kids On The Block</h2>
<h3>SLF4J</h3>
<p>Logging, everyone needs it. Thats probably why there are at least four major Java logging frameworks.  However, they are not all created equal. <a href="http://java.sun.com/javase/6/docs/api/java/util/logging/package-summary.html">Java util logging </a>is known to have a number of shortcomings when compared to <a href="http://logging.apache.org/log4j/1.2/index.html">Log4J</a> and <a href="http://commons.apache.org/logging/">Commons Logging</a> is just a facade that allows you to switch between the two more easily. Out of this mess comes <a href="http://www.slf4j.org/">SLF4J</a>. Created by the creator of Log4J it is simply a set of interfaces that anyone can implement. The default implementation, also made by the same guy, is called <a href="http://logback.qos.ch/">logback</a> and takes all the best of Log4J and improves on it. Moreover there are converters that route Log4J, CommonsLogging, and Java util logging to SLF4J. Never again do you have to struggle with multiple libraries and configuration files for all of your 3rd party libraries in your project. Simply drop in the converters and everything nicely flows into SLF4J.</p>
<h3>Google Collections</h3>
<p>Like I said before, if there were one library on my list it would come down to Commons Lang and <a href="http://code.google.com/p/google-collections/">Google Collections</a>. If you have every used <a href="http://commons.apache.org/collections/">Commons Collections</a> and cursed at its lack of type safety then Google Collections is for you. If you have ever balked at having to write List&lt;Map&lt;String, List&lt;Integer&gt;&gt;&gt; only to realized you have to type it all over again on the left hand side of the value assignment then Google Collections static methods such as newHashMap() are for you. If you are looking for a poor mans cache then MapMaker is for you. Finally, if you want to play around with functional programing ideas in Java look no farther than Predicate and Function and take it as a challenge to remove all for loops from your application.</p>
<h3>c3p0</h3>
<p>Database pooling, if you connectot to a database you need it. There are a few out there to choose from and the decision is always a bit of an argument but since Hibernate chose <a href="http://www.mchange.com/projects/c3p0/index.html">c3p0</a> as its default connection pool it has gotten significantly more attention than the other options and the prevailing winds seem to suggest that it is the way to go.</p>
<h3>Joda Time</h3>
<p>Not everyone has to deal with time in their programs but if you do, look no farther than <a href="http://joda-time.sourceforge.net/">Joda Time</a>. From simple formatting to the complication of subtracting dates and everything in between, Joda Time is an easy to use api for all your date and time needs. No longer will you have deal with Calendars and wonder what exactly is a Gregorian one.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codedependents.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codedependents.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codedependents.wordpress.com/238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&amp;blog=7973493&amp;post=238&amp;subd=codedependents&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codedependents.com/2009/10/26/11-lesser-known-3rd-party-libraries-for-every-project/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e0132e931569bbd7d6ad6ef56a6f11db?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bdarfler</media:title>
		</media:content>

		<media:content url="http://codedependents.files.wordpress.com/2009/10/pennies_in_jar_small1.jpg?w=106" medium="image">
			<media:title type="html">pennies_in_jar_small</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovin&#039; Up Your Database Tests</title>
		<link>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/</link>
		<comments>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 16:02:33 +0000</pubDate>
		<dc:creator>Benjamin Darfler</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database testing]]></category>
		<category><![CDATA[dbunit]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://bdarfler.wordpress.com/?p=15</guid>
		<description><![CDATA[While TDD proclaims the gospel of fine grained tests and a healthy dose of mock objects, at some point, interaction with a database becomes inevitable.  Luckily, there is DbUnit to assist us.  DbUnit is a fantastic framework which allows for painless setup of database data sets, ensuring repeatable, self contained unit tests. However, there are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&amp;blog=7973493&amp;post=15&amp;subd=codedependents&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While TDD proclaims the gospel of fine grained tests and a healthy dose of mock objects, at some point, interaction with a database becomes inevitable.  Luckily, there is <a href="http://www.dbunit.org">DbUnit</a> to assist us.  DbUnit is a fantastic framework which allows for painless setup of database data sets, ensuring repeatable, self contained unit tests.  However, there are already <a href="http://www.dbunit.org/howto.html">plenty</a> <a href="http://www.onjava.com/pub/a/onjava/2004/01/21/dbunit.html">of</a> <a href="http://www.oreillynet.com/onjava/blog/2005/10/dbunit_made_easy.html">tutorials</a> on the subject.  Instead, what I want to talk about is the dark side of dbunit&#8230; xml.</p>
<p>Using dbunit on any reasonably sized project ends up with an explosion of xml data set files, even if care is taken to factor out common data sets and reuse them when possible.  For the longest time this seemed an unfortunate but necessary evil of using such an amazingly useful library, but that was before I attended the Northeast <a href="http://www.nofluffjuststuff.com">No Fluff Just Stuff</a> in April.  Before that point I had been interested in Groovy and was looking for places to add it to our code base (actually snuck it into a script that ran in the build) but I hadn&#8217;t really pondered the possibilities it provided.  However, NFJS was over flowing with talks and general love for Groovy.  Somewhere between the Groovy unit testing and the Groovy MOP talks it dawned on me.  Why not inline the xml using a Groovy builder?!</p>
<p>Groovy has this fantastic feature called <a href="http://groovy.codehaus.org/Builders">builders</a> which allows for very compact syntax to generate any sort of markup (html, xml, java swing, etc).  Of course the one we want to focus on is the <a href="http://groovy.codehaus.org/Creating+XML+using+Groovy's+MarkupBuilder">xml builder</a>.  By simply changing the file extension from .java to .groovy on the unit test we are already half way there.  After using Groovy&#8217;s syntax for creating xml we simply call .toString() on the underlying writer, wrap it in a new <a href="http://java.sun.com/javase/6/docs/api/java/io/StringReader.html">StringReader</a>() and then pass create a new <a href="http://www.dbunit.org/apidocs/org/dbunit/dataset/xml/FlatXmlDataSet.html">FlatXmlDataSet</a>() with the reader as the only constructor argument.</p>
<p>If you are using <a href="http://ant.apache.org/">Ant</a> for your build you can simply wire up the <a href="http://groovy.codehaus.org/The+groovyc+Ant+Task">groovyc</a> task to compile all of your groovy tests and then call <a href="http://ant.apache.org/manual/OptionalTasks/junit.html">junit</a> on the .class files.  If you want to get this working in Eclipse, best of luck, I was able to kinda get it working under windows xp but now that I have switched to os x the groovy plugin screams bloody murder with 64-bit java under os x in Eclipse.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codedependents.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codedependents.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codedependents.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&amp;blog=7973493&amp;post=15&amp;subd=codedependents&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e0132e931569bbd7d6ad6ef56a6f11db?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bdarfler</media:title>
		</media:content>
	</item>
	</channel>
</rss>
