<?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>Cato&#039;s Place</title>
	<atom:link href="http://www.catosplace.net/blogs/personal/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.catosplace.net/blogs/personal</link>
	<description>Pete Sellars&#039; Blogsphere Presence</description>
	<lastBuildDate>Mon, 05 Jul 2010 11:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ant, Ivy, JUnit 4.8.2 and OpenPojo &#8211; Part 1: Challenges</title>
		<link>http://www.catosplace.net/blogs/personal/?p=555</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=555#comments</comments>
		<pubDate>Mon, 05 Jul 2010 11:12:13 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Build Process]]></category>
		<category><![CDATA[Ivy]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ivy]]></category>
		<category><![CDATA[OpenPojo]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=555</guid>
		<description><![CDATA[After announcing my plans to compare Ant, Maven and Gradle implementations in my previous post Ant, Maven, Gradle...or something else... almost 2 months ago, I have finally found some time to begin my little experiment.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">
<div id="attachment_565" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/07/justdoit.jpg"><img class="size-medium wp-image-565" title="justdoit" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/07/justdoit-300x226.jpg" alt="Just Do It!" width="300" height="226" /></a><p class="wp-caption-text">Just Do It!</p></div>
<p style="text-align: left;">After announcing my plans to compare Ant, Maven and Gradle implementations in my previous post <a title="Ant, Maven, Gradle...or something else..." href="http://www.catosplace.net/blogs/personal/?p=504" target="_blank">Ant, Maven, Gradle&#8230;or something else&#8230;</a> almost 2 months ago, I have finally found some time to begin my little experiment.</p>
<p style="text-align: left;">The initial implementation involves the use of <a title="Apache Ant" href="http://ant.apache.org/" target="_blank">Ant</a> with <a title="Apache Ivy" href="http://ant.apache.org/ivy/" target="_blank">Ivy</a>, to build and test a simple Java class. Dependencies including Ivy itself, <a title="JUnit" href="http://www.junit.org/" target="_blank">JUnit</a> 4.8.2 and <a title="OpenPojo" href="http://code.google.com/p/openpojo/" target="_blank">OpenPojo</a> should be obtained as part of the build itself. Anyone wishing to use the build should only require a working Java environment and Ant installed. It appeared to be simple enough in principle. It turns out to be a little more complicated in practice.</p>
<p style="text-align: left;"><span id="more-555"></span></p>
<p>Challenges encountered with this implementation thus far:</p>
<ul>
<li>Bootstrapping of Apache Ivy (this was expected)</li>
<li>JUnit 4.8.2 has not been released into any Maven repositories</li>
<li>OpenPojo doesn&#8217;t exist in any Maven repositories</li>
</ul>
<p style="text-align: left;">The repository issues will affect all of the implementations. This lead me to consider adding a local repository manager (to which I could install the required artifacts) to the experiment.</p>
<p style="text-align: left;">With Ant/Ivy I can bootstrap the appropriate artifacts and install them locally. I believe adding a local repository manager such as <a title="Artifactory" href="http://www.jfrog.org/products.php" target="_blank">Artifactory</a>, <a title="Archiva" href="http://archiva.apache.org/" target="_blank">Archiva</a> or <a title="Nexus" href="http://nexus.sonatype.org/" target="_blank">Nexus</a> would provide a better solution &#8211; but at the expense of adding  a requirement that the user have a repository manager installed (with the appropriate artifacts) for the build to run successfully. Thus for the Ant/Ivy implementation I don&#8217;t plan to use a repository manager.</p>
<p style="text-align: left;">So that leaves me with the 3 challenges to meet. I shall deal with each of these in a separate blog entry, as and when I have completed a reasonable solution. I shall also post the relevant code to <a title="GitHub" href="http://github.com/" target="_blank">GitHub</a> for those interested in testing it and providing feedback.</p>
<p style="text-align: left;">Do you have any comments about the implementation? Should I be using a repository manager? What is the best way to bootstrap the required artifacts? Any suggestions/ideas? If so please add them in a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=555</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ant, Maven, Gradle&#8230;or something else&#8230;</title>
		<link>http://www.catosplace.net/blogs/personal/?p=504</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=504#comments</comments>
		<pubDate>Sun, 02 May 2010 07:28:53 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Build Process]]></category>
		<category><![CDATA[Gradle]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[build frameworks ant ivy maven gradle gant]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=504</guid>
		<description><![CDATA[Do you use a build framework? Which build framework do you use? Is your build framework open-source, commercial or even custom? Ant, Maven and Gradle are three open-source build frameworks that I plan to use in a build experiment.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">
<div id="attachment_517" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/05/arrested.jpg"><img class="size-full wp-image-517" title="arrested" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/05/arrested.jpg" alt="Arrested for not using a build tool!!" width="300" height="199" /></a><p class="wp-caption-text">Arrested for not using a build tool!!</p></div>
<p style="text-align: left;">Do you use a build framework? Which build framework do you use? Is your build framework open-source, commercial or even custom? <a title="Apache Ant" href="http://ant.apache.org/" target="_blank">Ant</a>, <a title="Maven" href="http://maven.apache.org/" target="_self">Maven</a> and <a title="Gradle" href="http://www.gradle.org/" target="_blank">Gradle</a> are three open-source build frameworks that I plan to use in a build experiment.</p>
<p style="text-align: left;">The experiment is intended to be the first of many set around the build process. Future planned experiments include the integration of these frameworks with repository managers, continuous build integration, static code analysis/error detection and reporting capabilities to determine technical debt.</p>
<p style="text-align: left;"><span id="more-504"></span><span style="text-decoration: underline;"><strong>The Experiement</strong></span></p>
<p style="text-align: left;">I intend to create a simple build using each of these frameworks. Each build is required to:</p>
<ul>
<li> Use <a title="JUnit" href="http://www.junit.org/" target="_blank">JUnit</a> 4.8.2</li>
<li>The latest version of <a title="OpenPojo" href="http://code.google.com/p/openpojo/" target="_blank">OpenPojo</a> (used in the small application to test)</li>
<li>The build framework is the only requirement to perform the build in a Java environment</li>
<li>Dependencies should be retrieved or bootstrapped when required</li>
</ul>
<p style="text-align: left;">Once each of the builds has been created I intend to compare them. Comparisons should provide useful feedback for the builds in this context. Current comparisons I am considering involve comparison of:</p>
<ul>
<li>Implementation time and complexity</li>
<li>Dependency management flexibility</li>
<li>The ability to tailor the build configuration</li>
</ul>
<p><span style="text-decoration: underline;"><strong>The Frameworks</strong></span></p>
<ul><span style="text-decoration: underline;"><strong> </strong></span></ul>
<p style="text-align: left;"><strong>Ant </strong><a title="Apache Ant" href="http://ant.apache.org/" target="_blank">[Apache Ant Website]</a><strong><br />
</strong></p>
<p style="text-align: left;">I have been using Ant as part of my Java development for as long as I can remember. Having hand crafted numerous build files using Ant&#8217;s verbose XML syntax and extended Ant via custom tasks, it is my staple build framework of choice. I enjoy the flexibility it provides and the ability it offers to tailor builds to meet specific requirements.</p>
<p style="text-align: left;">For this experiment I am conscious that Ant will require the bootstrapping of <a title="Apache Ivy" href="http://ant.apache.org/ivy/" target="_blank">Apache Ivy</a> to enable dependency management. This means there will be added complexity from the start for the Ant build. This added complexity though is tempered by the flexibility Ant will offer me to perform the other tasks.</p>
<p><strong>Maven </strong><a title="Maven" href="http://maven.apache.org/" target="_blank">[Maven Website]</a><strong><br />
</strong></p>
<p style="text-align: left;">I have experience using Maven but have not yet been convinced it is worthy of replacing Ant in my build processes. Maven 1.0 and 2.0 had failed to convince me that I should ditch Ant just yet, maybe Maven 3.0 will change that! When working with Maven I have encountered the need to revert back to Ant for certain unorthodox build steps. Maven does appear to have some flexibility issues, and I have been privy to several discussions around these issues. I do believe the tool does have benefits, such as its dependency management, and have included it in this experiment as a chance for Maven to demonstrate that it has what it takes to be considered as my build tool of choice.</p>
<p style="text-align: left;">Most of my Maven experience has involved the maintenance of and the addition of functionality to existing pom files rather than building the pom from scratch. The Maven build should prove simple to implement unless the specific JUnit version  requirement causes the test phase of the build issues. I am hoping Maven can pleasantly surprise me with its simplicity to meet the experiment requirements.</p>
<p><strong>Gradle </strong><a title="Gradle" href="http://www.gradle.org/" target="_blank">[Gradle Website]</a><strong><br />
</strong></p>
<p style="text-align: left;">Gradle is the new kid on the build framework block. Having recently built a Grails application and delved into the world of Groovy I am eager to see if this framework can compete with the more established Ant and Maven. Will it prove to have the flexibility of Ant enhanced by a Groovy script implementation along with dependency management comparable to that of Maven?</p>
<p style="text-align: left;">I have not even download Gradle yet! Some time ago I intended to look at <a title="GAnt" href="http://gant.codehaus.org/" target="_blank">GAnt</a> as an Ant alternative. GAnt is not a build framework. It enables Ant builds to be built using the Groovy syntax rather than using the Ant verbose XML equivalent. Gradle uses Apache Ivy for dependency management (as the Ant build will do). Having experienced the increased efficiency Groovy can provide utilizing the power of Groovy scripts in the build process is very appealing to me.</p>
<p><span style="text-decoration: underline;"><strong><span style="text-decoration: underline;"><strong>The Expectations</strong></span></strong></span></p>
<p style="text-align: left;">I believe Ant whilst offering the most flexibility will prove to be the most complex of the builds largely due to the need to bootstrap dependency management and its verbose XML syntax.</p>
<p style="text-align: left;">Maven has excellent dependency management built in but the requirement to use a specific version of JUnit may cause issues with the built in test phase?</p>
<p style="text-align: left;">If Gradle does provide the flexibility of Ant along with dependency management comparable to that of Maven combined with a Groovy scripting nature it could prove to be my build tool of the future.</p>
<p style="text-align: left;"><em>I am interested in hearing about alternative build frameworks worthy of investigation, as well as build experiences relevant to this experiment. I would also be interested in ideas to extend this experiment that would provide more realistic project comparisons &#8211; really pushing the framework limits etc.</em></p>
<p style="text-align: left;"><em>I will be storing the build scripts on <a title="GitHub" href="http://github.com/" target="_blank">GitHub</a> and will post the link once the first implementation has been committed.<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=504</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>JUnit 4 Test Logging Tips using SLF4J</title>
		<link>http://www.catosplace.net/blogs/personal/?p=442</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=442#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:01:31 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[JUnit]]></category>
		<category><![CDATA[SLF4J]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=442</guid>
		<description><![CDATA[When writing JUnit tests developers often add log statements that can help provide information on test failures. During the initial attempt to find a failure a simple System.out.println() statement is usually the first resort of most developers. Replacing these System.out.println() statements with log statements is the first improvement on this technique. Using SLF4J (Simple Logging [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><a href="http://www.slf4j.org" target="_blank"><img class="size-full wp-image-444 aligncenter" title="slf4j-logo" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/02/slf4j-logo.jpg" alt="SLF4J Logo" width="305" height="130" /></a>When writing <a title="JUnit" href="http://www.junit.org" target="_blank">JUnit</a> tests developers often add log statements that can help provide information on test failures. During the initial attempt to find a failure a simple <em>System.out.println() </em>statement is usually the first resort of most developers.</p>
<p style="text-align: left;">Replacing these <em>System.out.println()</em> statements with log statements is the first improvement on this technique. Using <a title="SLF4J" href="http://www.slf4j.org" target="_blank">SLF4J</a> (Simple Logging Facade for Java) provides some neat improvements using parameterized messages. Combining SLF4J with JUnit 4 rule implementations can provide more efficient test class logging techniques.</p>
<p style="text-align: left;"><span id="more-442"></span></p>
<p style="text-align: left;">Some examples will help to illustrate how SLF4J and JUnit 4 rule implementation offers improved test logging techniques. As mentioned the inital solution by developers is to use System.out.println() statements. The simple example code below shows this method.</p>
<pre class="brush: java;">
import org.junit.Test;

public class LoggingTest {

  @Test
  public void testA() {
    System.out.println(&quot;testA being run...&quot;);
  }

  @Test
  public void testB() {
    System.out.println(&quot;testB being run...&quot;);
  }
}
</pre>
<p style="text-align: left;">The obvious improvement here is to use logging statements rather than the <em>System.out.println()</em> statements. Using SLF4J enables us to do this simply whilst allowing the end user to plug in their desired logging framework at deployment time. Replacing the System.out.println() statements with SLF4J log statements directly results in the following code.</p>
<pre class="brush: java;">
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingTest {

  final Logger logger =
    LoggerFactory.getLogger(LoggingTest.class);

  @Test
  public void testA() {
    logger.info(&quot;testA being run...&quot;);
  }

  @Test
  public void testB() {
    logger.info(&quot;testB being run...&quot;);
  }
}
</pre>
<p style="text-align: left;">Looking at the code it feels that the hard coded method name in the log statements would be better obtained using the @Rule <a title="TestName JUnit API JavaDoc" href="http://kentbeck.github.com/junit/javadoc/4.8/org/junit/rules/TestName.html" target="_blank">TestName</a> JUnit 4 class. This Rule makes the test name available inside method blocks. Replacing the hard coded string value with the TestName rule implementation results in the following updated code.</p>
<pre class="brush: java;">
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingTest {

  @Rule public TestName name = new TestName();

  final Logger logger =
    LoggerFactory.getLogger(LoggingTest.class);

  @Test
  public void testA() {
    logger.info(name.getMethodName() + &quot; being run...&quot;);
  }

  @Test
  public void testB() {
    logger.info(name.getMethodName() + &quot; being run...&quot;);
  }
}
</pre>
<p style="text-align: left;"><a title="SLF4J Logging Performance" href="http://www.slf4j.org/faq.html#logging_performance" target="_blank">SLF4J offers an improved method to the log statement in the example above which provides faster logging</a>. Use of parameterized messages enable SLF4J to evaluate whether or not to log the message at all. The message parameters will only be resolved if the message will be logged. According to the SLF4J manual this can provide an improvement of a factor of at least 30, in case of a disabled logging statement.</p>
<p style="text-align: left;">Updating the code to use SLF4J parameterized messages results in the following code.</p>
<pre class="brush: java;">
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingTest {

  @Rule public TestName name = new TestName();

  final Logger logger =
    LoggerFactory.getLogger(LoggingTest.class);

  @Test
  public void testA() {
    logger.info(&quot;{} being run...&quot;, name.getMethodName());
  }

  @Test
  public void testB() {
    logger.info(&quot;{} being run...&quot;, name.getMethodName());  }
  }
}
</pre>
<p style="text-align: left;">Quite clearly the logging statements in this code don&#8217;t conform to the DRY principle.</p>
<p style="text-align: left;">Another JUnit 4 Rule implementation enables us to correct this issue. Using the <a title="TestWatchman JUnit API JavaDoc" href="http://kentbeck.github.com/junit/javadoc/4.8/org/junit/rules/TestWatchman.html" target="_blank">TestWatchman</a> we are able to create an implementation that overrides the <em>starting(FrameworkMethod method) </em>to provide the same functionality whilst maintaining the DRY principle. The TestWatchman Rule also enables developers to override methods invoked when the test finishes, fails or succeeds.</p>
<p style="text-align: left;">Using the TestWatchman Rule results in the following code.</p>
<p style="text-align: left;">
<pre class="brush: java;">
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.MethodRule;
import org.junit.rules.TestWatchman;
import org.junit.runners.model.FrameworkMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingTest {

  @Rule public MethodRule watchman = new TestWatchman() {
    public void starting(FrameworkMethod method) {
      logger.info(&quot;{} being run...&quot;, method.getName());
    }
  };

  final Logger logger =
    LoggerFactory.getLogger(LoggingTest.class);

  @Test
  public void testA() {

  }

  @Test
  public void testB() {

  }
}
</pre>
<p style="text-align: left;">And there you have it. A nice test code logging technique using JUnit 4 rules taking advantage of SLF4J parameterized messages.</p>
<p style="text-align: left;">I would be interested to hear from anyone using this or similar techniques based on JUnit 4 rules and SLF4J.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=442</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GalleryView jQuery Plugin 2.0 Example</title>
		<link>http://www.catosplace.net/blogs/personal/?p=399</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=399#comments</comments>
		<pubDate>Sun, 17 Jan 2010 10:27:07 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery Tips]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=399</guid>
		<description><![CDATA[Prior to Christmas I came across another list of great jQuery Plugins. This list (11 Amazing JQuery Gallery) contained the GalleryView Plugin which was visually impressive but looked quite simple to implement. The plugin website states that it: aims to provide jQuery users with a flexible, attractive content gallery that is both easy to implement [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_401" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/01/galleryview.jpg"><img class="size-medium wp-image-401" title="galleryview" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/01/galleryview-300x163.jpg" alt="GalleryView Plugin Example" width="300" height="163" /></a><p class="wp-caption-text">GalleryView Plugin Example</p></div>
<p style="text-align: left;">Prior to Christmas I came across another list of great jQuery Plugins. <a title="11 Amazing JQuery Gallery (sic)" href="http://www.denbagus.net/11-amazing-jquery-gallery/" target="_blank">This list (11 Amazing JQuery Gallery)</a> contained the <a title="GalleryView: A jQuery Content Gallery Plugin" href="http://spaceforaname.com/galleryview" target="_blank">GalleryView Plugin</a> which was visually impressive but looked quite simple to implement. The plugin website states that it:</p>
<blockquote>
<p style="text-align: left;">aims to provide jQuery users with a flexible, attractive content gallery that is both easy to implement and a snap to customize.</p>
</blockquote>
<p style="text-align: left;">
<p style="text-align: left;">The Plugin website has several demos. These demos show the flexibility of the plugin. As well as the <a title="GalleryView: Default Implementation" href="http://spaceforaname.com/gallery-light.html" target="_blank">default implementation</a> there are demos that show how to use the Plugin as a <a title="GalleryView: Lightbox Style" href="http://spaceforaname.com/panels.html" target="_blank">LightBox style</a> replacement and even how to create an <a title="GalleryView: HTML Content Panel" href="http://spaceforaname.com/horoscopes.html" target="_blank">HTML content panel</a> using the Plugin. It is well worth checking out all of the demos to get a feel for just what the Plugin is capable of.</p>
<p style="text-align: left;">Worth a special mention is the implementation on the <a title="Evolution using GalleryView Plugin" href="http://spaceforaname.com/evolution.html" target="_blank">sites evolution page</a>. On this page the GalleryView Plugin is used to show the evolution of the site in pictures during 8 days of development. A great example of ingenious ways to use this flexible Plugin.</p>
<p style="text-align: left;">I was interested in a simple and visually impressive gallery viewer, but this Plugin delivers more than that. I could see uses for this Plugin when creating dynamic content viewers, work portfolios and much, much more. So time for some implementation&#8230;</p>
<p style="text-align: left;">I begun my implementation by following the usage section on the Plugin sites homepage&#8230;and ended up with a complete mess! I had failed to notice the authors note at the top of the page:</p>
<blockquote>
<p style="text-align: left;">this entire page is now out of date, as it talks about GalleryView 1.1.  For the lastest version, 2.0, please check out <a href="http://plugins.jquery.com/project/galleryview">http://plugins.jquery.com/project/galleryview</a>.</p>
</blockquote>
<p style="text-align: left;">Being away from home (with no internet access) for the break I had downloaded copies of the relevant pages. At this time I considered putting my attempts to get the example up and running on hold. This seemed to be a bit of a cop out to me. So I delved into the 2.0 source code in an attempt to determine the markup and styles required. I found the source code quite easy to read and understand, and soon had an almost fully functioning example. I was still having an issue with the filmstrip &#8211; so decided to complete the example when I returned from my break.</p>
<h3 style="text-align: left;">Implementation</h3>
<div id="attachment_433" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/01/my-galleryview.jpg"><img class="size-full wp-image-433" title="My GalleryView Example" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/01/my-galleryview.jpg" alt="My GalleryView Example" width="300" height="148" /></a><p class="wp-caption-text">My GalleryView Example</p></div>
<p><a title="GalleyView Example" href="http://www.catosplace.net/jquery_sandbox/galleryview/index.html" target="_blank">View the example</a></p>
<p style="text-align: left;">In order to use the Plugin you need to use the jQuery javascript library, the GalleryView Plugin, the <a title="JQuery Timers Plugin" href="http://plugins.jquery.com/project/timers" target="_blank">jQuery Timer Plugin</a> and the <a title="JQuery Easing Plugin" href="http://gsgd.co.uk/sandbox/jquery/easing/" target="_blank">jQuery Easing Plugin</a>. The dependencies are included in the GalleryView Plugin download. Include these libraries in any pages you wish to use the Plugin.</p>
<p style="text-align: left;">Only a very simple piece of JavaScript is required to get the Plugin up and running:</p>
<pre class="brush: jscript;">

&lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function(){
    $('#photos').galleryView({
      panel_width: 800,
      panel_height: 300,
      frame_width: 75,
      frame_height: 75
    });
  });
&lt;/script&gt;
</pre>
<p style="text-align: left;">This simple bit of script calls the Plugins galleryView method with a minimum configuration set. Our panel and filmstrip frames will be set to the pixel sizes specified here. There are many more configurations available. If you want to know what configuration options there are check out the <a title="GalleryView 2.0 Release Notes" href="http://plugins.jquery.com/node/7953" target="_blank">2.0 release notes</a> as well as those listed on the Plugin site.</p>
<p style="text-align: left;">There are links from the out of date Plugin website (in the comments) to some example of 2.0 code provided by a third party. These links were not working when I tried them. I was able to track down the right pages on the linked to site though. So with a bit of help from <a title="GalleyView 2.0 Example at Appleton.me" href="http://appleton.me/2009/08/gallery-view/">this example</a> on <a title="Appleton.me" href="http://appleton.me/" target="_blank">appleton.me</a> I was able to create a fully functioning example with the following very clear and concise bit of HTML:</p>
<pre class="brush: xml;">
&lt;ul id=&quot;photos&quot;&gt;
 &lt;li&gt;
   &lt;span&gt;Auckland City from North Head, Devonport&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/auckland.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;Lion Rock, Piha&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/lion_rock.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;Rangitoto&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/rangitoto.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;Fern&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/fern.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;River&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/river.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;Waves&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/waves.jpg&quot; /&gt;
 &lt;/li&gt;
 &lt;li&gt;
   &lt;span&gt;Piha: Looking towards 'The Gap'&lt;/span&gt;
   &lt;img src=&quot;../../img/gallery/towards_the_gap.jpg&quot; /&gt;
 &lt;/li&gt;
&lt;/ul&gt;
</pre>
<p style="text-align: left;">The example page seems to be the most active page for the Plugin at this time. It even seems the developer has put the Plugin out to seed at this time. Jack Wanders stated on<a title="Jack Wanders on Twitter" href="http://twitter.com/jackwanders" target="_blank"> his Twitter account</a> on 6th July 2009:</p>
<blockquote>
<p style="text-align: left;">My apologies, but GalleryView and spaceforaname.com are officially dead in the water until further notice; occupied w/ other matters atm</p>
</blockquote>
<p style="text-align: left;">Hopefully either he or someone else will pick up the Plugin as it certainly does have some great uses. If you are aware of the latest news related to the Plugin please let me know.</p>
<p style="text-align: left;">One thing I would particularly like to see is the IE7 Panel Overlay fade in/out issue fixed sometime soon (maybe I should do that myself after delving in to the source code) as I feel this could be a &#8216;BLOCKER&#8217; for production uses. Setting the panels to not fade and switch instantly is a workaround in most situations.</p>
<p>Lists of other jQuery Gallery Plugins etc I have come across:</p>
<ul>
<li><a title="Top 14 jQuery Photo Slideshow / Gallery Plugins" href="http://blueprintds.com/2009/01/20/top-14-jquery-photo-slideshow-gallery-plugins/" target="_blank">Top 14 jQuery Photo Slideshow / Gallery Plugins</a></li>
<li><a title="15 Amazing jQuery Image Gallery/Slideshow Plugins and Tutorials" href="http://speckyboy.com/2009/06/03/15-amazing-jquery-image-galleryslideshow-plugins-and-tutorials/" target="_blank">15 Amazing jQuery Image Gallery/Slideshow Plugins and Tutorials</a></li>
<li><a title="25 jQuery Slider/Image Gallery Tutorials and Plugins" href="http://vandelaydesign.com/blog/web-development/jquery-image-galleries/" target="_blank">25  jQuery Slider/Image Gallery Tutorials and Plugins</a></li>
<li><a title="15 jQuery Plugins For A Better Photo Gallery And Slideshow" href="http://www.webdesignbooth.com/15-jquery-plugins-for-a-better-photo-gallery-and-slideshow/" target="_blank">15  jQuery Plugins For A Better Photo Gallery And Slideshow</a></li>
</ul>
<p style="text-align: left;">If the GalleryView Plugin doesn&#8217;t meet your needs or is not your cup of tea, maybe you will find something in these lists that does.</p>
<div id="attachment_362" class="wp-caption aligncenter" style="width: 160px"><a href="http://www.manning.com/affiliate/idevaffiliate.php?id=1100_176"><img class="size-full wp-image-362  " title="JQuery In Action" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2010/01/jQuery_in_action.jpg" alt="Purchase JQuery In Action 2nd Edition MEAP Edition" width="150" height="188" /></a><p class="wp-caption-text">Purchase JQuery In Action 2nd Edition MEAP Edition</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=399</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple WordPress Embedded Content, JUnit Updates and introducing Tohu!</title>
		<link>http://www.catosplace.net/blogs/personal/?p=372</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=372#comments</comments>
		<pubDate>Mon, 21 Dec 2009 09:29:55 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[Drools]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Solnet Solutions]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tohu]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=372</guid>
		<description><![CDATA[Java has announced closures in Java 7, WordPress and JUnit have been updated, JUnit has also had a bug release update pushed out already! In this entry I will outline the best WordPress functionality added by the update, the main reason for the JUnit releases and let you know about exciting developments at work.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">With my dad and step-mum currently visiting from the UK I have found it hard to find blogging time of late. A lot has been going on in my technical areas of interest lately, Java has announced <a title="Java Closures - Not a moment to lose" href="http://blogs.sun.com/mr/entry/jdk7" target="_blank">closures in Java 7</a>, WordPress and JUnit have been updated, JUnit has also had a bug release update pushed out already! In this entry I will outline the best WordPress functionality added by the update, the main reason for the JUnit releases and let you know about exciting developments at work.</p>
<p style="text-align: left;">WordPress has recently been updated to version 2.9. This new version includes a super easy way to include embeddable media in posts via <a title="Embeds - WordPress Codex" href="http://codex.wordpress.org/Embeds" target="_blank">Embeds</a>. Thought I would give this new feature a work out by embedding one of my favourite television moments of all time&#8230;from classic BBC Comedy <a title="Only Fools And Horses" href="http://www.bbc.co.uk/comedy/onlyfools/" target="_blank">Only Fools and Horses</a> &#8211; Del Boy prepares to make a move on some hot chicks whilst out on the town with Trigger&#8230;</p>
<p><object width="450" height="363"><param name="movie" value="http://www.youtube.com/v/_IBgk05iL3Y&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_IBgk05iL3Y&#038;fs=1" type="application/x-shockwave-flash" width="450" height="363" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p style="text-align: left;">Am sure I will find more uses for this great new feature. To find out what other new features are included check out the <a title="WordPress 2.9 Release Blog Post" href="http://wordpress.org/development/2009/12/wordpress-2-9/" target="_blank">release blog post</a>.</p>
<p style="text-align: left;">JUnit has also recently been updated to version <a title="JUnit 4.8.1 Release Announcement" href="http://www.junit.org/node/582" target="_blank">4.8.1</a>. This version  follows close on the heals of the <a title="JUnit 4.8 Release Announcement" href="http://www.junit.org/node/581" target="_blank">4.8 release</a> which introduced Categories to JUnit. Check out the Category changes and implementations  in the <a title="JUnit 4.8 Release Notes" href="http://kentbeck.github.com/junit/doc/ReleaseNotes4.8.html" target="_blank">release notes</a>.  The Categories implementation is marked by the authors as preliminary, not sure what is meant by that &#8211; as surely it would be difficult to remove it once people start using it! 4.8.1 fixes bugs in the Categories documentation and implementation reported by early implementors. I shall be taking a look at the implementation ASAP.</p>
<p style="text-align: left;">Lately I have been working on an interesting project at work that implemented a Grails/Groovy server and a .NET Extraction client. Most of my time was spent on the .NET client extractor which has been an interesting, if somewhat frustrating experience.</p>
<p style="text-align: left;">Today I got moved to a new project which looks like it could be really interesting. It involves the use of <a title="Tohu JBoss Community" href="http://jboss.org/tohu" target="_blank">Tohu</a>, an open source JBoss Drools based library for use in dynamic questionnaire based implementations. <a title="Solnet Solutions" href="http://www.solnetsolutions.co.nz/" target="_blank">Solnet Solutions</a> are the main developers of this open source implementation. I have been interested in making commercial use of <a title="JBoss Drools" href="http://www.jboss.org/drools/" target="_blank">Drools</a> for a long time, and this project will give me the opportunity to get some real experience in this area. Tohu also currently only supports a <a title="JQuery" href="http://jquery.com/" target="_blank">JQuery</a> UI. With JQuery being another of the technologies I have dabbled in but never really used in earnest as yet.</p>
<p style="text-align: left;">I have set myself a few goals for the coming months. Among them is blogging about the JUnit Categories updates and completing my review of the 3.7 changes. I will outline more of my plans and goals for the year in upcoming blog posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=372</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JUnit Goodness &#8211; Slideshare Presentation</title>
		<link>http://www.catosplace.net/blogs/personal/?p=364</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=364#comments</comments>
		<pubDate>Fri, 20 Nov 2009 11:42:32 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[Slideshare]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[java junit testing presentation slideshow slideshare]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=364</guid>
		<description><![CDATA[Link to the JUnit Goodness presentation outlined in my previous blog entry now posted on Slideshare]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<div id="attachment_365" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-365 " title="talk_nerdy_to_me" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/11/talk_nerdy_to_me-300x225.jpg" alt="Talk Nerdy To Her :)" width="300" height="225" /><p class="wp-caption-text">Off for a chat....</p></div>
<p style="text-align: left;">I have uploaded the slides from my JUnit Goodness presentation to <a title="Slideshare" href="http://www.slideshare.net/" target="_blank">Slideshare</a>.</p>
<p style="text-align: left;">I outlined the presentation in my <a title="JUnit Goodness" href="http://www.catosplace.net/blogs/personal/?p=327" target="_blank">last blog entry</a>. The slideshow can be reached by clicking on the link below:</p>
<p style="text-align: left;"><a title="JUnit Goodness on Slideshare" href="http://www.slideshare.net/catosplace/junit-goodness" target="_blank">JUnit Goodness on Slideshare</a></p>
<p style="text-align: left;">Would appreciate any feedback and comments that viewers wish to provide. I shall upload the example code sometime next week and am considering turning the slideshow into a videocast.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=364</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JUnit Goodness</title>
		<link>http://www.catosplace.net/blogs/personal/?p=327</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=327#comments</comments>
		<pubDate>Fri, 13 Nov 2009 10:37:12 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=327</guid>
		<description><![CDATA[Discover the JUnit Goodness - Parameterized Tests, Matcher Assertions and the @Ignore Annotation.]]></description>
			<content:encoded><![CDATA[<div id="attachment_333" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-333 " title="lack_of_tests_disturbing" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/11/lack_of_tests_disturbing-300x240.jpg" alt="Testing: The Dark Side?" width="300" height="240" /><p class="wp-caption-text">Testing: The Dark Side?</p></div>
<p style="text-align: left;">It feels like an eternity since I last sat down to write some blog content!!</p>
<p style="text-align: left;">The last month or so I have been busy updating a <em><strong>&#8216;JUnit Goodness&#8217;</strong> </em>presentation for use at the <a title="Auckland Java User Group : MeetUp" href="http://www.meetup.com/auckland-jug/" target="_blank">Auckland JUG</a> <a title="Auckland JUG October 2009 MeetUp" href="http://www.meetup.com/auckland-jug/calendar/11666518/" target="_blank">October 2009 meeting</a>. The presentation focuses on 3 aspects of <a title="JUnit" href="http://www.junit.org/" target="_blank">JUnit</a> 4 that I feel may have slipped under the radar of developers introduced to JUnit at version 3. Parameterized tests, matcher assertions and the <em>@Ignore</em> annotation were the 3 aspects I chose to include in this presententation.</p>
<p>The parameterzied test section of the presentation attempts to outline a process that may lead a developer to utilize a parameterized test. The realization that duplicated code can be replaced by a looping test leads the devloper naturally in  the direction of a parameterized test. The presentation aims to offer answers regarding why and when to use parameterized tests and how to write them. Also included in the presentation is a named parameterized test extension and an XML data driven parametrized test extension that I had recently implemented.</p>
<p>Matcher assertions arrived in JUnit 4 via <a title="JMock" href="http://www.jmock.org/" target="_blank">JMock</a>. The presentation aims to demonstrate the advantages of using matcher assertions compared to the legacy JUnit assertions. Matcher assertion readability, clarity of failure messages, combination matcher usage and the benefits of list matchers are all presented. The creation of custom matchers is also present, albeit through a crude over simplified example.  To finish the presentation there is a look at the somewhat under utilized IMHO <em>@Ignore</em> annotation and how it can fit in to improved testing practices.</p>
<div id="attachment_343" class="wp-caption alignleft" style="width: 190px"><a href="http://www.meetup.com/auckland-jug/"><img class="size-full wp-image-343 " title="Auckland JUG Duke" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/11/auckland_duke.jpeg" alt="Auckland JUG Duke" width="180" height="125" /></a><p class="wp-caption-text">Auckand JUG Duke</p></div>
<p style="text-align: left;">The majority of those present at the presentation were still using JUnit even though <a title="TestNG" href="http://testng.org/doc/index.html" target="_blank">TestNG</a> has built up quite a following and viewed by some as the next generation test tool. TestNG has useful features such as parallel testing and data driven testing using the <em>@DataProvider</em> annotation that JUnit does not. Why has there not been a shift to this next generation test tool? Is it down to the lazy developer syndrome? The we know this tool, why waste time learning a similar tool attitude? Some of the attendees were aware of TestNG and the benefits it offers when writing certain types of tests &#8211; yet still used JUnit for there project test needs.</p>
<p style="text-align: left;">Many of those present were unaware of the benefits that the 3 aspects presented provided. There was the odd attendee who had dabbled with one or two of the aspects, but none had really dug too deep. Hopefully I provided everyone with something to think about whenever they are writing JUnit tests in the future.</p>
<p style="text-align: left;">I had expected the parameterized tests section, particularly the named and XML data-driven extensions would be the &#8216;WOW&#8217; factor of this particular presentation. This was not the case though. The actual &#8216;WOW&#8217; factor turned out to be the clarity of the matcher assertion failure messages compared to their legacy equivalents. Flicking between the two versions on the big projector screen seemed to exacerbate the clarity.</p>
<p style="text-align: left;">I would be surprised to see any of the developers present not using matcher assertions from now on based on what they saw. The <em>@Ignore</em> annotation usage did lead into a group discussion regarding how useful it was, how it could be abused and the best ways to use it.</p>
<p style="text-align: left;">I plan to upload a slightly updated version of the presentation to <a title="Slideshare - Share PowerPoint Presentations Online" href="http://www.slideshare.net/" target="_blank">SlideShare</a> later this week.</p>
<p style="text-align: center;">
<div id="attachment_362" class="wp-caption aligncenter" style="width: 160px"><a href="http://www.manning.com/affiliate/idevaffiliate.php?id=1100_131"><img class="size-full wp-image-362  " title="junit_in_action_2E" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/11/junit_in_action_2E.jpg" alt="Purchase JUnit In Action 2nd Edition MEAP Edition" width="150" height="188" /></a><p class="wp-caption-text">Purchase JUnit In Action 2nd Edition MEAP Edition</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JUnit 4.7 Verifier Core Rule</title>
		<link>http://www.catosplace.net/blogs/personal/?p=235</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=235#comments</comments>
		<pubDate>Sat, 10 Oct 2009 02:26:37 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=235</guid>
		<description><![CDATA[A look at the new Verifier core rule in JUnit 4.7. A clarification of the Verifier core rule and an implementation of a custom rule based on the Verifier rule.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">
<div id="attachment_293" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-293" title="Mommy Little Test Developer" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/10/mommys_little_test_developer-300x300.jpg" alt="Mommy's Little Test Developer" width="300" height="300" /><p class="wp-caption-text">Mommy&#39;s Little Test Developer</p></div>
<p style="text-align: left;">Continuing with my look at the new core rules in JUnit 4.7 this blog entry will look at the Verifier core rule. This rule is the base class for rules like the <a title="JUnit 4.7 ErrorCollector Core Rule" href="http://www.catosplace.net/blogs/personal/?p=198" target="_blank">ErrorCollector rule</a> which I looked at in a <a title="Error Collector Rule Blog Entry" href="http://www.catosplace.net/blogs/personal/?p=198" target="_blank">previous post</a>. Using the Verifier core rule it is possible to turn tests which would otherwise pass into failing tests based on a verification state.</p>
<p style="text-align: left;">There is a single method in the Verifier class that implementors of this rule need to override. The verify method is declared with a throwable exception which should be thrown to indicate verification failure. Here is the method declaration from the Verifier class:</p>
<pre class="brush: java;">
/**
 * Override this to add verification logic.
 * Overrides should throw an exception to indicate that verification failed.
 */
protected void verify() throws Throwable {}
</pre>
<p style="text-align: left;">When the Verifier rule is applied the following apply method is used.</p>
<pre class="brush: java;">
public Statement apply(final Statement base, FrameworkMethod method,
  Object target) {
    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        base.evaluate();
        verify();
      }
   };
}
</pre>
<p style="text-align: left;">As can be seen once the base statement evaluation is completed the overriden verify method will be run. This enables the implementation class to fail tests which would otherwise pass.</p>
<p style="text-align: left;">So how could this be employed in a useful manner? Under what circumstances would it make sense to fail a passing test based on an object state ending up in an incorrect state. John Smart recently wrote an article about <a title="Testing Exceptions in JUnit 4.7" href="http://weblogs.java.net/blog/johnsmart/archive/2009/09/27/testing-exceptions-junit-47" target="_blank">Testing Exceptions in JUnit 4.7</a> in which he implements the verify method in order to check a user is not logged in.</p>
<p style="text-align: left;">John states that his implementation is probably not the intended use of the Verifier rule, but I don&#8217;t think he was far from an intended use. John did provide me with a use case for the Verifier rule though. So my implementation will be used to verify that a user is still in the session once the test has run.</p>
<p style="text-align: left;">All John failed to implement in his example is a version of the verify method that throws an exception. Following the same pattern as the ErrorCollector rule for my UserInSessionVerifier class that extends Verifier I implemented a verify method that throws a NoUserInSessionException. Below is my UserInSessionVerifier class code:</p>
<p style="text-align: left;">
<pre class="brush: java;">
import javax.servlet.http.HttpSession;
import org.junit.rules.Verifier;

public class UserInSessionVerifier extends Verifier {

  HttpSession session;

  public UserInSessionVerifier(HttpSession session) {
    this.session = session;
  }

  @Override
  protected void verify() throws Throwable {
    NoUserInSessionException.assertNotEmpty(session);
  }
}
</pre>
<p style="text-align: left;">As can be seen this is a fairly simple class which extends the Verifier rule class and overrides the verify method. This overriden method throws a NoUserInSessionException if the session user state verification fails, that happens if the session does not contain a user. The session property is initialized in the constructor, which is then passed by parameter to the assertNotEmpty static method of the NoUserInSessionException class. Lets take a look at that class now:</p>
<p style="text-align: left;">
<pre class="brush: java;">
import javax.servlet.http.HttpSession

public class NoUserInSessionException extends Exception {

  private static final long serialVersionUID = 1L;
  private final HttpSession session;

  public NoUserInSessionException(HttpSession session) {
    this.session = session;
  }

  public HttpSession getSession() {
    return this.session;
  }

  public static void assertNotEmpty(HttpSession session) throws Throwable {
    if (session.getAttribute(&quot;userName&quot;) == null
          || session.getAttribute(&quot;userName&quot;).equals(&quot;&quot;)) {
      throw new NoUserInSessionException(session);
    }
  }
}
</pre>
<p style="text-align: left;">This standard exception class extends a Throwable subclass, it also  implements the static assertNotEmpty method that contains the user state verification code. In this trivial example if the userName attribute in the session is empty or null a NoUserInSessionException is thrown &#8211; as the user state is not what we expected it to be. If the user state is as we expect &#8211; that is to say it is populated then this method will not throw an exception and the verify method in UserInSessionVerifier will not cause any tests to fail.</p>
<p>Having looked at our Verifier rule (UserInSessionVerifier) and its associated exception (NoUserInSessionException), lets now look at a test that uses our new UserInSessionVerifier rule.</p>
<pre class="brush: java;">

import static org.junit.Assert.assertTrue;

import javax.servlet.http.HttpSession;

import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.mock.web.MockHttpSession;

public class UserInSessionVerifierExample {

 public HttpSession session = new MockHttpSession();

 @Rule
 public UserInSessionVerifier verifyUserInSession = new UserInSessionVerifier(session);
 @Rule
 public ExpectedException thrown = ExpectedException.none();

 @Test
 public void userInSessionPasses() {
   // Add user to the session.
   session.setAttribute(&quot;userName&quot;, &quot;testUser&quot;);
   assertTrue(true);
 }

 @Test
 public void userNotInSessionFails() {
   // No user added to session
   assertTrue(true);
 }

 // This fails
 // - Because the exception is not returned by base.evaluate() but
 // by the verify() call in the Verifier class apply() method.
 @Test(expected = NoUserInSessionException.class)
 public void userNotInSessionUncaught() {
   // No user added to session
   assertTrue(true);
 }

 @Test
 public void userNotInSessionCaught() {
   // No user added to session
   thrown.expect(NoUserInSessionException.class);
   assertTrue(true);
 }

 @After
 public void removeUserFromSession() {
   if (session.getAttribute(&quot;userName&quot;) != null) {
         session.removeAttribute(&quot;userName&quot;);
   }
 }
}
</pre>
<p style="text-align: left;">Looking at this class you will notice that there are  2 JUnit 4.7 rules, 4 tests and an @After annotated method in it. Lets look closer at these aspects of the test class now.</p>
<p style="text-align: left;">The first rule declared is the UserInSessionVerifier rule that we implemented. We pass this rule the MockHttpSession as an argument to the constructor. This rule will be evaluated after each test is run, so if there is no user in the session at the end of a test the rule will fail verification. The second rule used is an ExpectedException rule which will be used to test that when the verification fails we actually recieve a NoUserInSessionException.</p>
<p style="text-align: left;">The 4 tests all contain a simple passing assertTrue(true) statement which means they should all run successfully. The difference comes in the verification state once the tests complete.  The userInSessionPasses test places a user into the session, thus when the verification rule is applied the state is verified and the test passes successfully. The userNotInSessionFails test does not place a user in the session and although the base statement passes the test fails due to the verification state.</p>
<p style="text-align: left;">The other 2 tests show how the NoUserInSessionException thrown by the  UserInSessionVerifier method gets handled. The userNotInSessionUncaught method shows that using the expected exception attribute to catch the NoUserInSessionException fails. This fails as the base evaluate method does not throw the exception &#8211; which is what the expected exception attribute checks. The exception is thrown by the verfiy method. Using the ExpectedException rule which catches exceptions even during the verification state we can catch this exception. The userNotInSessionCaught test passes as the ExpectedException rules expect method rule is met &#8211; the NoUserInSessionException is thrown.</p>
<p style="text-align: left;">The @After method simply clears the user from the session. As can seen this runs after the verification rule, otherwise the userInSessionPasses test would fail. I included it to test when the verification rule gets fired. I wanted to check that the rule was being fired before any clean up methods.</p>
<p style="text-align: left;">I belive that John could  update his verifier to check if a user was logged in based on the example presented here. I would be interested to know if he thinks such an implementation would prove to be scalable or not. Shall follow up with him.</p>
<p style="text-align: left;">Hopefully this has provided you with some ideas on how to use the Verifier rule. Would be great to hear about implementations of it you create and how it gets used. I shall move on to investigate the  TestWatchman rule  in my next installment, so hopefully you will be back for more!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=235</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails Development IDE Issues</title>
		<link>http://www.catosplace.net/blogs/personal/?p=248</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=248#comments</comments>
		<pubDate>Sun, 04 Oct 2009 02:41:19 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Groovy Eclipse Plugin]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=248</guid>
		<description><![CDATA[After several months of &#8216;garage&#8217; Groovy and Grails development I have recently spent some time on a commercial Grails based project. This blog aims to share some of the issues I have had with IDE support during this project. I will endeavor to update this entry in the future based on my experiences. My IDE [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">
<div id="attachment_282" class="wp-caption aligncenter" style="width: 310px"><img class="size-full wp-image-282  " title="GRRRR!! My IDE keeps crashing...." src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/10/frustrated_developer.jpg" alt="GRRRR!! My IDE keeps crashing...." width="300" height="242" /><p class="wp-caption-text">GRRRR!! My IDE keeps crashing....</p></div>
<p style="text-align: left;">After several months of &#8216;garage&#8217; <a title="Groovy" href="http://groovy.codehaus.org/" target="_blank">Groovy</a> and <a title="Grails Website" href="http://grails.org/" target="_blank">Grails</a> development I have recently spent some time on a commercial <a title="Grails Website" href="http://grails.org/" target="_blank">Grails</a> based project. This blog aims to share some of the issues I have had with IDE support during this project. I will endeavor to update this entry in the future based on my experiences.</p>
<p style="text-align: left;">My IDE of choice has been Eclipse for a number of years, but during the project I found reason to switch to <a title="NetBeans" href="http://www.netbeans.org/" target="_blank">NetBeans</a> . The cause for this radical IDE change was the <a title="Groovy Eclipse Plugin" href="http://groovy.codehaus.org/Eclipse+Plugin" target="_blank">Groovy Eclipse Plugin</a> constantly crashing my Eclipse IDE!</p>
<p style="text-align: left;">The Groovy Eclipse Plugin does have 2 versions. In defense of the plugin, I switched to using version 2 when working on the project, and updated my Eclipse installation to the <a title="Eclipse Galileo" href="http://www.eclipse.org/galileo/" target="_blank">Galileo</a> release. This version is an alpha, and I had not had any issues with version 1 in previous versions of Eclipse. The plugin home page does state that both versions are working with Eclipse 3.5. I am certain that I checked this before installing version 2. Although as an alpha release I do concede that some instabilities are to be expected. I had also updated to the 3.5.1 release when the crashes became too much for me!</p>
<p style="text-align: left;">In attempts to stop the constant IDE crashes I tried several JVM argument updates and even took the more radical step of using a totally different JVM. With each attempt proving futile I decided to browse the <a title="Groovy Eclipse Plugin JIRA Home" href="http://jira.codehaus.org/browse/GRECLIPSE" target="_blank">Groovy Eclipse Plugin JIRA</a> issues for more specific information. Here I found issues related to the Eclipse installation (<a title="GRECLIPSE-409" href="http://jira.codehaus.org/browse/GRECLIPSE-409" target="_blank">GRECLIPSE-409</a>, <a title="GRECLIPSE-413" href="http://jira.codehaus.org/browse/GRECLIPSE-413" target="_blank">GRECLIPSE-413</a>) I have and the Groovy Eclipse Plugin version I am using. (<a title="GRECLIPSE-417" href="http://jira.codehaus.org/browse/GRECLIPSE-417" target="_blank">GRECLIPSE-417</a>).</p>
<p style="text-align: left;">
<div id="attachment_281" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-281  " title="Nope..this one doesn't support it either!" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/10/frustrated_developer_2-300x204.png" alt="GRRRRRRRRRRR!!!!! IDE Support..What IDE Support!" width="300" height="204" /><p class="wp-caption-text">Nope..this one doesn&#39;t support it either!</p></div>
<p style="text-align: left;">On the recommendation of other team members I installed a version of Netbeans 6.7.1 which came with the Grails plugin installed. There are a quite a lot of things that I don&#8217;t like about the Netbeans IDE and the Grails plugin &#8211; but at the time of writing this blog entry &#8211; at least it is stable, doesn&#8217;t crash on me constantly and enables me to actually cut some code. Unfortunatly the Netbeans IDE is slow, the code completion is painfully slow (if it works at all), the Grails plugin hangs in the IDE and the interface is not as familiar to me (as Eclipse).</p>
<p style="text-align: left;">Thus, for the past week I have found myself using the a command line in a command window to build, run and test the Grails application &#8211; much as I did when using Eclipse during the &#8216;garage&#8217; days. Stuck with an intolerably slow IDE with little to no code completion and frustrated by the whole development process. I am considering moving back to Eclipse and downgrading the Groovy Eclipse Plugin. (Any one got any suggestions/thoughs on that one?)</p>
<p style="text-align: left;">I throughly enjoy cutting Groovy/Grails code but would like a more productive IDE experience. I realize that a lot of IDE support is in alpha or beta status, but for Grails to gain some traction in the market place and with developers this support needs to exist.</p>
<p style="text-align: left;">I would love to hear about other peoples experiences with Grails IDE development. Information on plugins that I am unaware of or tips and tricks that would get me back up and running in Eclipse would be appreciated.</p>
<p style="text-align: left;"><strong>UPDATE &#8211; 10/01/2009</strong></p>
<p style="text-align: left;">Almost a week has passed and there have been numerous comments on this blog entry, so I thought I would update it with my current status. I have removed all Eclipse instance from my working machine since the initial writing. These instances have been replaced by the <a title="Spring Source Tools" href="http://www.springsource.com/products/sts" target="_blank">Spring Source Tools</a> (STS) 2.1.0 as recommended in the initial comment on this entry.</p>
<p style="text-align: left;">I have had several issues with this version &#8211; it seems to crash once I install the Subclipse plug-in as per versions of Eclipse 3.5.1. I had to reinstall the STS a few times during the week, but at times it has been stable and quite usable. As it still crashes I don&#8217;t consider this to be the end of my quest &#8211; so will be reviewing the comments that have been made and acting on them this week. I shall update when I have more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=248</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Eclipse Tip #1 &#8211; Static Import Code Completion</title>
		<link>http://www.catosplace.net/blogs/personal/?p=258</link>
		<comments>http://www.catosplace.net/blogs/personal/?p=258#comments</comments>
		<pubDate>Thu, 01 Oct 2009 09:41:11 +0000</pubDate>
		<dc:creator>Peter Sellars</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.catosplace.net/blogs/personal/?p=258</guid>
		<description><![CDATA[If like me Eclipse is your IDE of choice and you find yourself frustrated by having to add an import statement in order to use common static imports then help is at hand. If you use JUnit 4&#8242;s assertThat method, the core Hamcrest matchers or even EasyMock verifiers etc, then this tip will make your [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">If like me <a title="Eclipse" href="http://www.eclipse.org/" target="_blank">Eclipse</a> is your IDE of choice and you find yourself frustrated by having to add an import statement in order to use common static imports then help is at hand. If you use <a title="JUnit" href="http://www.junit.org" target="_blank">JUnit</a> 4&#8242;s assertThat method, the core <a title="Hamcrest" href="http://code.google.com/p/hamcrest/" target="_blank">Hamcrest</a> matchers or even <a title="EasyMock" href="http://easymock.org/" target="_self">EasyMock</a> verifiers etc, then this tip will make your life easier.</p>
<p style="text-align: left;">In order to simplify using these static methods add them to your Eclipse static import favourites. This little gem of functionality is found under <span style="font-style: italic;">Preferences -&gt; Java -&gt; Editor -&gt; Content Assist -&gt; Favorites.</span></p>
<p style="text-align: left;"><span style="font-style: italic;"> </span></p>
<div id="attachment_261" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-261  " title="static_favourites_assert" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/10/static_favourites_assert-300x214.gif" alt="Eclipse Static Import Favouries" width="300" height="214" /><p class="wp-caption-text">Eclipse Static Import Favouries</p></div>
<p style="text-align: left;">In the above example I have added the org.junit.Assert.* package to my favourites. Now when I am working on some java code and want to use a static import from this package it will be available in the code completion box, as can be seen below.</p>
<div id="attachment_262" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-262" title="assertThat_static_import" src="http://www.catosplace.net/blogs/personal/wp-content/uploads/2009/10/assertThat_static_import-300x126.gif" alt="Code Completion Static Imports in Eclipse" width="300" height="126" /><p class="wp-caption-text">Code Completion Static Imports in Eclipse</p></div>
<p style="text-align: left;">Acknowledgment for this simple tip and a few more must go to <a title="Benjamin Winterberg" href="http://bwinterberg.blogspot.com/" target="_blank">Benjamin Winterberg</a> who provided this in his <a title="5 Tips for Customizing Eclipse" href="http://bwinterberg.blogspot.com/2009/09/eclipse-tips-hints.html" target="_blank">5 Tips for Customizing Eclipse</a> blog entry. Vote his entry up on <a title="DZone" href="http://www.dzone.com" target="_self">DZone</a> by voting <a title="Vote at DZone for 5 Tips for Customizing Eclipse" href="http://www.dzone.com/links/5_tips_for_customizing_eclipse.html" target="_blank">here</a>.  Hopefully this tip will make your Eclipse static import use a pleasure and not a frustration from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catosplace.net/blogs/personal/?feed=rss2&amp;p=258</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.699 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-10 03:06:39 -->
