<?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>Inside the Machine</title>
	<atom:link href="http://insidethemachine.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://insidethemachine.wordpress.com</link>
	<description>Discussing languages and technologies associated with the JVM</description>
	<lastBuildDate>Mon, 08 Apr 2013 23:43:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='insidethemachine.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Inside the Machine</title>
		<link>http://insidethemachine.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://insidethemachine.wordpress.com/osd.xml" title="Inside the Machine" />
	<atom:link rel='hub' href='http://insidethemachine.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How Clojure improved my Groovy</title>
		<link>http://insidethemachine.wordpress.com/2010/01/15/how-clojure-improved-my-groovy/</link>
		<comments>http://insidethemachine.wordpress.com/2010/01/15/how-clojure-improved-my-groovy/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 17:57:42 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=499</guid>
		<description><![CDATA[Dave Thomas and Andy Hunt have been saying for years that you should learn new programming languages. Doing so improves your skill in any language, whether you use the new language or not. I believed this with some skepticism, but decided nonetheless to start learning Clojure after reading The Pragmatic Programmer. I&#8217;m reading and working [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=499&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Dave Thomas and Andy Hunt have been saying for years that you should learn new programming languages.  Doing so improves your skill in any language, whether you use the new language or not.  I believed this with some skepticism, but decided nonetheless to start learning <a href="http://clojure.org/">Clojure</a> after reading <a href="http://www.amazon.com/gp/product/020161622X?ie=UTF8&amp;tag=josbrosblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=020161622X">The Pragmatic Programmer</a>.</p>
<p>I&#8217;m reading and working through <a href="http://www.amazon.com/gp/product/1934356336?ie=UTF8&amp;tag=josbrosblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1934356336">Programming Clojure</a>, and one of the examples in the book looked like this:</p>
<pre class="brush: plain; title: ; notranslate">
(use '[clojure.contrib.str-utils :only (str-join)])
(str-join &quot;-&quot; [&quot;hello&quot;, &quot;clojure&quot;])
</pre>
<p>Then, a week or so later, as I was working on some Groovy code, I saw something like the following:</p>
<pre class="brush: groovy; title: ; notranslate">
def elements = [&quot;It&quot;, &quot;works&quot;, &quot;on&quot;, &quot;my&quot;, &quot;machine!&quot;]

def sb = new StringBuilder()
elements.eachWithIndex { element, index -&amp;gt;
  if (index == 0) {
    sb.append(element)
  } else {
    sb.append(&quot; &quot;)
    sb.append(element)
  }
}

assert sb.toString() == &quot;It works on my machine!&quot;
</pre>
<p>And I thought, &#8220;man, this code would be <em>so much better</em> in Clojure!&#8221;  Since I can&#8217;t use Clojure for my job (yet), I set out to find a better way to do this in Groovy.  I decided to look for something similar to Clojure&#8217;s str-join for Groovy, and I found the join() method.  It does exactly what I needed!</p>
<pre class="brush: groovy; title: ; notranslate">
def elements = [&quot;It&quot;, &quot;works&quot;, &quot;on&quot;, &quot;my&quot;, &quot;machine!&quot;]

def sb = new StringBuilder()
sb.append(elements.join(&quot; &quot;))

assert sb.toString() == &quot;It works on my machine!&quot;
</pre>
<p>And so, I discovered for myself that Dave and Andy were right.  Knowing Clojure (specifically, the clojure-contrib library) helped me to write better Groovy code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/499/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=499&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2010/01/15/how-clojure-improved-my-groovy/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>SnakeYAML and Groovy</title>
		<link>http://insidethemachine.wordpress.com/2010/01/13/snakeyaml-and-groovy/</link>
		<comments>http://insidethemachine.wordpress.com/2010/01/13/snakeyaml-and-groovy/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 13:42:44 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=491</guid>
		<description><![CDATA[I had some fun playing with SnakeYAML and Groovy the other day. Below are some of my results. If you want to run this in your groovyConsole, you need to download SnakeYAML and add the snakeyaml-&#60;version&#62;.jar to your classpath. From YAML to Groovy: From Groovy to YAML: Isn&#8217;t YAML so much simpler and cleaner than [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=491&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I had some fun playing with <a href="http://code.google.com/p/snakeyaml/wiki/readme">SnakeYAML</a> and Groovy the other day.  Below are some of my results.  If you want to run this in your groovyConsole, you need to <a href="http://code.google.com/p/snakeyaml/downloads/list">download SnakeYAML</a> and add the snakeyaml-&lt;version&gt;.jar to your classpath.</p>
<p>From YAML to Groovy:</p>
<pre class="brush: groovy; title: ; notranslate">
import org.yaml.snakeyaml.Yaml

Yaml yaml = new Yaml()
def obj = yaml.load(&quot;&quot;&quot;
a: 1
b: 2
c:
  - aaa
  - bbb&quot;&quot;&quot;)

assert obj.a == 1
assert obj.b == 2
assert obj.c == [&quot;aaa&quot;, &quot;bbb&quot;]
</pre>
<p>From Groovy to YAML:</p>
<pre class="brush: groovy; title: ; notranslate">
import org.yaml.snakeyaml.Yaml

def map = [name: &quot;Pushkin&quot;, aliases: ['P', 'Push']]
Yaml yaml = new Yaml()
String output = yaml.dump(map)

assert output ==
'''name: Pushkin
aliases: [P, Push]
'''
</pre>
<p>Isn&#8217;t YAML so much simpler and cleaner than XML?  Why aren&#8217;t more of us using YAML with Java and Groovy?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/491/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=491&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2010/01/13/snakeyaml-and-groovy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Top 5 posts of 2009</title>
		<link>http://insidethemachine.wordpress.com/2009/12/31/top-5-posts-of-2009/</link>
		<comments>http://insidethemachine.wordpress.com/2009/12/31/top-5-posts-of-2009/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 20:16:54 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=481</guid>
		<description><![CDATA[Our top 5 posts of 2009 by page views: [].inject(&#8220;Groovy&#8221;){} Who needs a mock framework? Mocking and stubbing in Groovy with &#8216;with&#8217; Java 6 and Maven on Mac OS X Leopard Liferay Portal is pretty snazzy Here are a few posts from 2008 (our first year) that were still popular in 2009: Cookies in Firefox [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=481&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Our top 5 posts of 2009 by page views:</p>
<ol>
<li><a href="http://insidethemachine.wordpress.com/2009/01/25/injectgroovy/">[].inject(&#8220;Groovy&#8221;){}</a></li>
<li><a href="http://insidethemachine.wordpress.com/2009/07/26/who-needs-a-mock-framework/">Who needs a mock framework?</a></li>
<li><a href="http://insidethemachine.wordpress.com/2009/10/05/mocking-and-stubbing-in-groovy-with-with/">Mocking and stubbing in Groovy with &#8216;with&#8217;</a></li>
<li><a href="http://insidethemachine.wordpress.com/2009/08/12/java-6-and-maven-on-mac-os-x-leopard/">Java 6 and Maven on Mac OS X Leopard</a></li>
<li><a href="http://insidethemachine.wordpress.com/2009/01/13/liferay-portal-is-pretty-snazzy/">Liferay Portal is pretty snazzy</a></li>
</ol>
<p>Here are a few posts from 2008 (our first year) that were still popular in 2009:</p>
<ul>
<li><a href="http://insidethemachine.wordpress.com/2008/05/18/cookies-in-firefox-and-internet-explorer/">Cookies in Firefox and Internet Explorer</a></li>
<li><a href="http://insidethemachine.wordpress.com/2008/05/04/groovys-each-method/">Groovy&#8217;s each method</a></li>
<li><a href="http://insidethemachine.wordpress.com/2008/11/08/the-executor-framework/">The Executor Framework</a></li>
<li><a href="http://insidethemachine.wordpress.com/2008/11/03/chain-those-crazy-closures-with-currying-case-study-mimicking-intercepting-filter/">Chain those Crazy Groovy Closures with Currying, Case Study: Mimicking Intercepting Filter</a></li>
<li><a href="http://insidethemachine.wordpress.com/2008/05/29/groovy-junit-ant/">Groovy + JUnit + Ant</a></li>
</ul>
<p>And here&#8217;s my favorite post of all time: <a href="http://insidethemachine.wordpress.com/2008/05/04/whats-the-most-fun-youve-ever-had-programming/">What&#8217;s the most fun you&#8217;ve ever had&#8230; programming?</a></p>
<p>Thanks for reading!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/481/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=481&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/12/31/top-5-posts-of-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Upgrading Maven from 2.0.x to 2.1.x &#8211; profiles.xml</title>
		<link>http://insidethemachine.wordpress.com/2009/10/26/upgrading-maven-from-2-0-x-to-2-1-x-profiles-xml/</link>
		<comments>http://insidethemachine.wordpress.com/2009/10/26/upgrading-maven-from-2-0-x-to-2-1-x-profiles-xml/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 00:09:34 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=449</guid>
		<description><![CDATA[When we tried to upgrade from Maven 2.0.x to 2.1.x, our build broke, indicating we had a problem with our profiles.xml. I had a hard time finding out what&#8217;s supposed to be in the profiles.xml, since I couldn&#8217;t find a reference to the schema on the Maven website.  I finally found a profiles.xml in one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=449&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>When we tried to upgrade from Maven 2.0.x to 2.1.x, our build broke, indicating we had a problem with our profiles.xml.  I had a hard time finding out what&#8217;s supposed to be in the profiles.xml, since I couldn&#8217;t find a reference to the schema on the Maven website.  I finally found a profiles.xml in one of our projects at work that referenced the profiles XML schema, which can be found here:</p>
<p><a href="http://maven.apache.org/xsd/profiles-1.0.0.xsd" target="_blank">http://maven.apache.org/xsd/profiles-1.0.0.xsd</a></p>
<p>I&#8217;m still not sure if the schema changed from 2.0.x to 2.1.x, but I know that using <code>&lt;profiles/&gt;</code> as the root element worked in 2.0.x but did not work in 2.1.x.  When you upgrade to 2.1.x, make sure the root element in your profiles.xml is <code>&lt;profilesXml/&gt;</code>.  Actually, you can make the change to your profiles.xml before upgrading to Maven 2.1.x and then upgrade when you&#8217;re ready.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/449/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/449/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=449&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/10/26/upgrading-maven-from-2-0-x-to-2-1-x-profiles-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Mocking and stubbing in Groovy with &#8216;with&#8217;</title>
		<link>http://insidethemachine.wordpress.com/2009/10/05/mocking-and-stubbing-in-groovy-with-with/</link>
		<comments>http://insidethemachine.wordpress.com/2009/10/05/mocking-and-stubbing-in-groovy-with-with/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 00:59:46 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=428</guid>
		<description><![CDATA[I often use metaClass in Groovy to create mocks or stubs in my unit tests. Recently I&#8217;ve discovered that the with method makes this a bit simpler. This: Foo.metaClass.with { doSomething = { return true } anotherThing = {foo -&#62; assertEquals 42, foo } } is slightly shorter than this: Foo.metaClass.doSomething = { return true [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=428&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I often use metaClass in Groovy to create <a href="http://martinfowler.com/articles/mocksArentStubs.html">mocks or stubs</a> in my unit tests.  Recently I&#8217;ve discovered that the <strong>with</strong> method makes this a bit simpler.</p>
<p>This:</p>
<pre>
Foo.metaClass.with {
  doSomething = {
    return true
  }
  anotherThing = {foo -&gt;
    assertEquals 42, foo
  }
}
</pre>
<p>is slightly shorter than this:</p>
<pre>
Foo.metaClass.doSomething = {
  return true
}
Foo.metaClass.anotherThing = {foo -&gt;
  assertEquals 42, foo
}
</pre>
<p>and less code means less bugs.</p>
<p>[Update: For more explanation of why the <strong>with</strong> method is so great, read <a href="http://javajeff.blogspot.com/2008/11/getting-groovy-with-with.html">this post</a>.]<br />
[Update: And for another way to write your mocks and stubs, see my previous post on <a href="http://insidethemachine.wordpress.com/2009/07/26/who-needs-a-mock-framework/">mocking with Groovy</a>.]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/428/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=428&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/10/05/mocking-and-stubbing-in-groovy-with-with/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrating Unit Tests</title>
		<link>http://insidethemachine.wordpress.com/2009/08/19/integrating-unit-tests/</link>
		<comments>http://insidethemachine.wordpress.com/2009/08/19/integrating-unit-tests/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 19:41:28 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[TDD]]></category>
		<category><![CDATA[Responsibility Driven Design]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=414</guid>
		<description><![CDATA[There&#8217;s been a lot of talk about TDD, Responsibility Driven Design, and what constitutes a unit test versus an integration test this week at work.  It got me thinking about the definitions.  I used to think it was very clear cut. Unit tests isolate a single class, integration test don&#8217;t. Is the line so simple [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=414&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There&#8217;s been a lot of talk about TDD, <a title="Responsibility Driven Design" href="http://www.methodsandtools.com/archive/archive.php?id=90">Responsibility Driven Design</a>, and what constitutes a unit test versus an integration test this week at work.  It got me thinking about the definitions.  I used to think it was very clear cut. Unit tests isolate a single class, integration test don&#8217;t.</p>
<p>Is the line so simple though?  What about a unit test that tests a method that uses other methods within the same class to get its work done.  Is testing the results of that method a unit test?</p>
<p>For example:</p>
<blockquote><p>// Say I wanted to test the method.<br />
String makeDeposit( String xmlData ) {<br />
def transaction = parseRequestXml( request )<br />
def receipt = bankBusinessObject.deposit( transaction )<br />
return makeResponseXml( receipt )<br />
}
</p></blockquote>
<p>To be a unit test, I should at least mock the bankBusinessObject, and should probably ask the Mock to fail my test if the deposit method isn&#8217;t called.</p>
<p>But, it seems that to be a true unit test for makeDeposit, I should also mock parseRequestXml and makeResponseXml.  And, for the makeDeposit <strong>unit</strong> test, rather than test that you get the expected xml repsponse data given the controlled input data, just ensure that makeDeposit calls parseRequestXml to parse it, bankBuisinessObject.deposit to act on it, and makeResponseXml to marshal the results.</p></blockquote>
<p>I did some brain storming and came up with a new classification scheme for organizing my tests.</p>
<p><strong>Unit</strong></p>
<ul>
<li><strong>Macro Unit Tests</strong> &#8211; Tests isolated to a single class.  This is where you&#8217;d see testing of methods which call other methods to get some of their work done.</li>
</ul>
<ul>
<li><strong>Micro Unit Tests</strong> &#8211; Tests isolated to a single method.  Completely test the method in isolation, mocking as necessary.   If you work in a language like Groovy and want to unit test a method that calls or depends on other methods in the same class, mock the dependent methods individually and have the mocks fail the test if they&#8217;re not called as expected, in the order expected.  I&#8217;m not sure if that is possible in Java.  (<em>Maybe with some sort of test harness with <a title="AOP" href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">AOP</a></em><em> involved to intercept the method calls during the test??)</em></li>
</ul>
<p><strong>Integration</strong></p>
<ul>
<li><strong>Standard Integration Tests</strong> &#8211; Integration tests that span other methods, classes, depend on other services, databases, etc.</li>
</ul>
<ul>
<li><strong>Requirements Tests</strong> &#8211; Tests for those when you want to test a specific requirement or bug fix.  Very helpful when something changes later that breaks the bug you fixed a few releases back.  Or when the customer opens a ticket asking for functionality that contradicts a previous request.</li>
</ul>
<p style="text-align:center;">
<p style="text-align:center;">
<p style="text-align:center;">Thoughts?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/414/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=414&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/08/19/integrating-unit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/473cc4fb2d829f5060e50a6bf35847a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Eric</media:title>
		</media:content>
	</item>
		<item>
		<title>Java 6 and Maven on Mac OS X Leopard</title>
		<link>http://insidethemachine.wordpress.com/2009/08/12/java-6-and-maven-on-mac-os-x-leopard/</link>
		<comments>http://insidethemachine.wordpress.com/2009/08/12/java-6-and-maven-on-mac-os-x-leopard/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 01:12:16 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=405</guid>
		<description><![CDATA[This morning I was having problems with Java and Maven on my Mac. I had my JAVA_HOME set to /Library/Java/Home, which was pointing to Java 6. When I ran mvn -v, Maven told me it was pointing to Java 5. I couldn&#8217;t figure out what was wrong because running java -version showed me Java 6. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=405&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This morning I was having problems with Java and Maven on my Mac.  I had my JAVA_HOME set to /Library/Java/Home, which was pointing to Java 6.  When I ran <strong>mvn -v</strong>, Maven told me it was pointing to Java 5.  I couldn&#8217;t figure out what was wrong because running <strong>java -version</strong> showed me Java 6.</p>
<p>The solution, which I found in <a href="http://cwash.org/2008/11/19/java-6-and-maven-209-on-leopard/">this post</a>, was to set my JAVA_HOME to the actual place where Java is installed, which is something like:</p>
<blockquote><p>/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home</p></blockquote>
<p>This worked for me, but <a href="http://en.wiktionary.org/wiki/YMMV">YMMV</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/405/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=405&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/08/12/java-6-and-maven-on-mac-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Who needs a mock framework?</title>
		<link>http://insidethemachine.wordpress.com/2009/07/26/who-needs-a-mock-framework/</link>
		<comments>http://insidethemachine.wordpress.com/2009/07/26/who-needs-a-mock-framework/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 02:22:37 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=389</guid>
		<description><![CDATA[In Groovy, you can create mocks &#38; stubs using native language features, so you can forget about learning a mock framework. class Author { def getName() { return 'Josh Brown' } def isFamous() { return false } } Let&#8217;s stub the isFamous method: def author = [isFamous: {true}] as Author assert 'Josh Brown' == author.getName() [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=389&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In Groovy, you can create mocks &amp; stubs using native language features, so you can forget about learning a mock framework.</p>
<pre>
class Author {
  def getName() {
    return 'Josh Brown'
  }
  def isFamous() {
    return false
  }
}
</pre>
<p>Let&#8217;s stub the isFamous method:</p>
<pre>
def author = [isFamous: {true}] as Author
assert 'Josh Brown' == author.getName()
assert author.isFamous()
</pre>
<p>(If you haven&#8217;t already, stick the above code in your groovyConsole, run it, and play around with it.)</p>
<p>When mocking and stubbing are so easy to do with the language itself, using a mock framework is overkill.</p>
<p>[<strong>Update</strong>: Bob Martin recently wrote an excellent post about <a href="http://blog.objectmentor.com/articles/2009/10/28/manual-mocking-resisting-the-invasion-of-dots-and-parentheses">Manual Mocking</a>.]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/389/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/389/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=389&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/07/26/who-needs-a-mock-framework/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>
	</item>
		<item>
		<title>Story time with easyb</title>
		<link>http://insidethemachine.wordpress.com/2009/01/27/story-time-with-easyb/</link>
		<comments>http://insidethemachine.wordpress.com/2009/01/27/story-time-with-easyb/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 02:52:47 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[easyb]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=337</guid>
		<description><![CDATA[Everyone loves a good story.     With easyb, you can write stories in your code! scenario "the Death Star destroys Alderaan", {     given "the Death Star", {}     and "Alderaan", {}     and "Alderaan is targeted by the Death Star", {}     when "the Death Star fires", {}     then "Alderaan is destroyed", [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=337&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Everyone loves a good story.<br />
 </p>
<p><a href="http://www.amazon.com/Star-Wars-Trilogy-Harrison-Ford/dp/B001EN71DG/ref=pd_bbs_sr_1?ie=UTF8&amp;s=dvd&amp;qid=1233110305&amp;sr=8-1&amp;tag=insithemach-20"><img class="alignnone" title="Star Wars Trilogy" src="http://ecx.images-amazon.com/images/I/51wdAFSITQL._SS500_.jpg" alt="Star Wars Trilogy" width="500" height="500" /></a></p>
<p> </p>
<p>With easyb, you can write stories in your code!</p>
<p><code> scenario "the Death Star destroys Alderaan", {<br />
    given "the Death Star", {}<br />
    and "Alderaan", {}<br />
    and "Alderaan is targeted by the Death Star", {}<br />
    when "the Death Star fires", {}<br />
    then "Alderaan is destroyed", {}<br />
 }</code></p>
<p>You probably could&#8217;ve written that with the stakeholders yelling over shoulder. <em>&#8220;</em><em>No &#8211; t</em><em>he Death Star should destroy <strong>Yavin IV</strong>, not <strong>Alderaan</strong><strong>!!!</strong>&#8220;</em> If you&#8217;re writing readable code in front of them, you might be able to get them to make a decision while you&#8217;re at your keyboard.</p>
<p>Now you have executable documentation, and the stakeholders can leave the party.  And once they&#8217;re gone, you can move on to writing some Groovy code to fill in those empty squiggly braces:</p>
<p><code> scenario "the Death Star destroys Alderaan", {<br />
    given "the Death Star", {<br />
        deathStar = new DeathStar()<br />
    }<br />
    and "Alderaan", {<br />
        alderaan = new Planet(name:"Alderaan")<br />
        Galaxy.planets &lt;&lt; alderaan<br />
    }<br />
    and "Alderaan is targeted by the Death Star", {<br />
        deathStar.target = alderaan<br />
    }<br />
    when "the Death Star fires", {<br />
        deathStar.fire()<br />
    }<br />
    then "Alderaan is destroyed", {<br />
        Galaxy.planets.shouldNotHave alderaan<br />
    }<br />
}</code></p>
<p>Now run it and watch it fail.  Ah, the joy of xDD&#8230;</p>
<p>From here, you can write the DeathStar, Planet, and Galaxy classes you need to make it pass.  Run it again!  Refactor!  Repeat!</p>
<p>Now you have documentation that&#8217;s readable, executable, and verifies that your code does what it&#8217;s supposed to do!  Wasn&#8217;t that <a title="easyb" href="http://easyb.org/">easy</a>?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=337&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/01/27/story-time-with-easyb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4a3644f49db41a7d7f42b4c679e7864c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">joshuatbrown</media:title>
		</media:content>

		<media:content url="http://ecx.images-amazon.com/images/I/51wdAFSITQL._SS500_.jpg" medium="image">
			<media:title type="html">Star Wars Trilogy</media:title>
		</media:content>
	</item>
		<item>
		<title>[].inject(&#8220;Groovy&#8221;){}</title>
		<link>http://insidethemachine.wordpress.com/2009/01/25/injectgroovy/</link>
		<comments>http://insidethemachine.wordpress.com/2009/01/25/injectgroovy/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 03:44:20 +0000</pubDate>
		<dc:creator>Peabody</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[fold]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[inject]]></category>

		<guid isPermaLink="false">http://insidethemachine.wordpress.com/?p=343</guid>
		<description><![CDATA[The collection helper methods like each, findAll, and collect are among the clearest productivity advantages of Groovy over Java. For reference, here&#8217;s a list of the common collection helper methods on the Groovy Quick Start page (after opening the link you&#8217;ll have to scroll down to them). The inject method is among the most interesting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=343&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The collection helper methods like each, findAll, and collect are among the clearest productivity advantages of Groovy over Java. For reference, here&#8217;s a list of the common collection helper methods on the <a href="http://groovy.codehaus.org/Quick+Start" target="_blank">Groovy Quick Start page</a> (after opening the link you&#8217;ll have to scroll down to them).</p>
<p>The inject method is among the most interesting of them all but is not utilized often by Groovy developers. It&#8217;s useful but somewhat difficult to understand, relative to the complexity of the other collection helper methods, so many developers get the job done without inject and never bother to learn about it. I encourage everyone to learn inject so that they can understand another approach for attacking their problems and choose the most appropriate approach. The inject method is also a great first step in learning a little about functional programming.</p>
<p><strong>Functional Style &#8211; A stork story for inject</strong><br />
The Scala and Clojure languages on the JVM have aroused interest in functional style programming. Even with an imperative language like Java we can alter our programming style to more of a functional one, so learning the functional tenets can be very valuable to your arsenal.</p>
<p>Let&#8217;s take some Groovy code that calculates the sum of numbers 1 through 10.<br />
def total = 0<br />
(1..10).each{total += it}<br />
return total</p>
<p>Here we apply a closure to each value in the 1..10 range. But as we repeatly apply this closure we also need to keep track of a total variable, which changes with each iteration.</p>
<p>In pure functional programming variables are&#8230; not allowed. This poses an interesting twist to our problem. How can we accomplish the same functionality as the above code without any variables?</p>
<p>The answer to most &#8220;How can I solve this without variables?&#8221; questions: <strong>Recursion.</strong></p>
<p>Let&#8217;s examine how we totaled up values 1 to 10:<br />
(((((((((((0)+1)+2)+3)+4)+5)+6)+7)+8)+9)+10)<br />
Each set of paranthesis describes the value of total at some given point in time starting with 0 and expanding out to its final result of 55. Consequently, total gets set to 11 different values over its lifetime and only the last of those 11 was actually what we wanted.</p>
<p>The other danger here is that another developer might &#8220;refactor&#8221; your code by moving all variable declarations to the top of methods. I&#8217;ve inherited Java code like this quite often, where the beginning of some ginormous method sets a bunch of values like total = 0, even though taking the initializing value out of context actually makes the code more confusing.</p>
<p>With inject we can make the value of total clearer by keeping the calculation within the scope of its declaration. We &#8220;inject&#8221; the initial value of 0 and at each iteration the previousResult value represents what used to be represented by a waffling total variable.<br />
def total = (1..10).inject(0){previousResult, iterationValue -&gt;<br />
&nbsp;&nbsp;previousResult + iterationValue<br />
}</p>
<p>The concept of inject in Groovy is identical to that of a left <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)" target="_blank">fold in functional programming</a>. Ironically, the Groovy&#8217;s implementation of inject does not use recursion for, what I&#8217;m assuming, are performance reasons.</p>
<p><strong>sum()</strong><br />
We&#8217;ve been using a very simple example. Those familiar with Groovy might ask why not just use the sum() method available to lists:<br />
(1..10).sum()</p>
<p>Well, I&#8217;m glad you brought it up because there&#8217;s more to sum() than you may have realized.</p>
<p>You see, sum() allows you to &#8220;inject&#8221; an initial value.<br />
(1..10).sum() // 55<br />
(1..10).sum(0) // 55<br />
(1..10).sum(3) // 58</p>
<p>This doesn&#8217;t seem incredibly valuable at the surface, but let&#8217;s look at why it can be.</p>
<p>Try calling sum() on an empty list:<br />
[].sum() // null</p>
<p>Yes, the result is null. Most folks would assume that the result should be 0. So why <em>isn&#8217;t</em> the result 0? You have to realize that the sum() method merely requires that the objects in the list have a plus() method, which means that Groovy&#8217;s sum() method can&#8217;t assume that the empty list you passed in held Integer values.</p>
<p>For example, you could join strings in a list using sum():<br />
[&quot;strings &quot;,&quot;in &quot;,&quot;a &quot;, &quot;list &quot;].sum() // &quot;strings in a list&quot;</p>
<p>If you had an <em>empty </em>list intended for Strings, a sum() of 0 doesn&#8217;t make sense &#8211; an empty String would be more appropriate, so use sum(&quot;&quot;). If you don&#8217;t &#8220;initialize&#8221; a value into sum() you could end up with null if your list is empty and that could break some assumptions in your code, leading to a NPE. It&#8217;s often a good idea to &#8220;initialize&#8221; the sum() method with a value, much like you would do with inject().</p>
<p><strong>inject() to build collections</strong><br />
Java programmers switching to Groovy often use each{} for everything involving iterations. They write the equivalent of an imperative Java for loop:<br />
def oneToTen = (1..10)<br />
def doubles = []<br />
oneToTen.each{myValue-&gt;<br />
&nbsp;&nbsp;doubles.add(myValue*2);<br />
}<br />
return doubles</p>
<p>They&#8217;re often thrilled to find out that using a different collection helper method makes their code more readable and concise:<br />
def doubles = (1..10).collect{ it*2 }</p>
<p>Always scan your Groovy code for a collection helper method code smell:<br />
<strong>If your each{} or other collection helper method (findAll, collect, etc.) has a variable declaration in the line before it, you&#8217;re likely to benefit by using a <em>different </em>method.</strong></p>
<p>I usually play around in the GroovyConsole (just type groovyConsole in your command line if you have Groovy installed) to decide which collection helper method does the job best. It&#8217;s a fun challenge to include inject into the mix even though it has only emerged once as the victor in my production code&#8230; and honestly I can&#8217;t remember what that was and I don&#8217;t have access to the code any more. Bummers.</p>
<p>There&#8217;s an inject example at the bottom of a post we made on <a href="http://insidethemachine.wordpress.com/2008/11/03/chain-those-crazy-closures-with-currying-case-study-mimicking-intercepting-filter/">chaining and currying closures</a> back in November &#8217;08. Chris made a clever improvement in the comments section of that post as well. Thanks for that, Chris! We greatly welcome any improvements or questions here and we hope to see even more in the future from our readers.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insidethemachine.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/insidethemachine.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=insidethemachine.wordpress.com&#038;blog=2695349&#038;post=343&#038;subd=insidethemachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://insidethemachine.wordpress.com/2009/01/25/injectgroovy/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/8bef60dad7b76b51e532ced4154dcff8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Peabody</media:title>
		</media:content>
	</item>
	</channel>
</rss>
