<?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>redstream &#187; General</title>
	<atom:link href="http://www.redstream.nl/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redstream.nl</link>
	<description>Pragmatic Integrators</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Command-line Execution of Maven Plugins with Default Configuration</title>
		<link>http://www.redstream.nl/2011/10/31/command-line-execution-of-maven-p/</link>
		<comments>http://www.redstream.nl/2011/10/31/command-line-execution-of-maven-p/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 14:17:31 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2889</guid>
		<description><![CDATA[In Maven, plugins can be coupled to a Maven lifecycle phase and the configuration can be stored in your pom.xml. This is very convenient if you would like to perform some extra steps when, for example, you are deploying a &#8230; <a href="http://www.redstream.nl/2011/10/31/command-line-execution-of-maven-p/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F31%2Fcommand-line-execution-of-maven-p%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F31%2Fcommand-line-execution-of-maven-p%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In Maven, plugins can be coupled to a <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference" target="_blank">Maven lifecycle phase</a> and the configuration can be stored in your pom.xml. This is very convenient if you would like to perform some extra steps when, for example, you are deploying a web application. </p>
<p>But, what if you would like to execute a specific goal of a plugin and use the configuration in your pom.xml? </p>
<p><span id="more-2889"></span></p>
<p>As an example, I&#8217;ll use the <code>wagon-maven-plugin</code> plugin. The plugin is used to copy a number of XSL stylesheets to a target environment when deploying a web application. In the following snippet, you&#8217;ll see that the execution of the plugin is coupled with the <code>deploy</code> phase.</p>

<div class="wp_codebox"><table><tr id="p28894"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p2889code4"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.mojo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>wagon-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-beta-3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload-xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/main/resources/xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**/*.xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.url}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.xsl.toDir}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The used configuration will only be in effect when the plugin is executed as a result of the <code>deploy</code> phase. When executing the command <code>mvn clean compile wagon:upload</code>, you&#8217;ll be confronted with the message:</p>

<div class="wp_codebox"><table><tr id="p28895"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p2889code5"><pre class="script" style="font-family:monospace;">[INFO] --- wagon-maven-plugin:1.0-beta-1:upload (default-cli) @ demo-project ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.404s
[INFO] Finished at: Mon Oct 31 14:56:18 CET 2011
[INFO] Final Memory: 21M/554M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-1:upload (default-cli) on project demo-project 
The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-1:upload are missing or invalid -&gt; [Help 1]</pre></td></tr></table></div>

<p>The answer lies in the resulting message. It refers to execution Id <code>default-cli</code>. This reserved Id is used when executing Maven goals from the command-line. So, add another <code>execution</code> for the <code>wagon-maven-plugin</code> with id=default-cli and add your most favorite configuration. See following snippet:</p>

<div class="wp_codebox"><table><tr id="p28896"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p2889code6"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.mojo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>wagon-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-beta-3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload-xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/main/resources/xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**/*.xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.url}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.xsl.toDir}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default-cli<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/main/resources/xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**/*.xsl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.url}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.xsl.toDir}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Now you can execute, the <code>maven-wagon-plugin</code> as part of the build process and separate using a CLI command.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/10/31/command-line-execution-of-maven-p/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating tarballs on OSX _without_ the garbage</title>
		<link>http://www.redstream.nl/2011/10/04/creating-tarballs-on-osx-_without_-the-garbage/</link>
		<comments>http://www.redstream.nl/2011/10/04/creating-tarballs-on-osx-_without_-the-garbage/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 10:22:36 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2855</guid>
		<description><![CDATA[Just spent a costly 30 minutes finding out how to create a tgz tarball on OSX Lion without all the hidden ._ files. These files are the result of using the HFS or HFS+ filesystem. What I got when issuing &#8230; <a href="http://www.redstream.nl/2011/10/04/creating-tarballs-on-osx-_without_-the-garbage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F04%2Fcreating-tarballs-on-osx-_without_-the-garbage%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F04%2Fcreating-tarballs-on-osx-_without_-the-garbage%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Just spent a costly 30 minutes finding out how to create a tgz tarball on OSX Lion without all the hidden <code>._</code> files. These files are the result of using the HFS or HFS+ filesystem.</p>
<p>What I got when issuing a <code>tar -zcvf my-package.tar.gz dir1/</code> was a structure like this:</p>

<div class="wp_codebox"><table><tr id="p28559"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p2855code9"><pre class="script" style="font-family:monospace;">.
._dir1
dir1
  ._file1
  file1
  ._file2
  file2
  ._subdir
  subdir
    ._file3
    file3</pre></td></tr></table></div>

<p>When extracting this tarball on Linux, you&#8217;ll get all the unnecessary <code>._</code> files.</p>
<p>To prevent them from being packaged in the first place, issue the following command from your Terminal: <code>export COPYFILE_DISABLE=true</code></p>
<p>PS: You could make this setting &#8216;stick&#8217; by adding them to your <code>~/.bash_profile</code></p>
<p>The result now will be a nice and clean tarball:</p>

<div class="wp_codebox"><table><tr id="p285510"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2855code10"><pre class="script" style="font-family:monospace;">.
dir1
  file1
  file2
  subdir
    file3</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/10/04/creating-tarballs-on-osx-_without_-the-garbage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set up Web Service Proxy with Mule3</title>
		<link>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/</link>
		<comments>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 14:06:48 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Mule3]]></category>
		<category><![CDATA[SoapUI]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2826</guid>
		<description><![CDATA[In this post I show you how I setup a little test to see if and how easy I could manage to route the traffic to and from a web service through Mule ESB. The business case for this is &#8230; <a href="http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post I show you how I setup a little test to see if and how easy I could manage to route the traffic to and from a web service through <a href="http://www.mulesoft.org/">Mule ESB</a>. The business case for this is an issue that one of our customers ran into when using web services. In a program hundreds of calls are done in a relative short period. Most of the time this isn&#8217;t a problem but sometimes vague issues occur. To get a better insight in this issue I want to put Mule in the middle so I can log the request and response and hopefully get a better idea about what is sent across the line. This is called the Web Service Proxy pattern and is commonly used to validate and audit the web service calls. For more background info about this pattern see <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">this article</a>.<br />
<span id="more-2826"></span><br />
To get started I downloaded the <a href="http://www.mulesoft.org/download-mule-esb-community-edition">Mule Standalone edition</a> here and installed it. That isn&#8217;t very hard, just untar the thing and set the MULE_HOME property. Go to the bin directory and give &#8216;./mule&#8217; and off you go (except for a warning when running on MacOS 64-bit, but it doesn&#8217;t seem to harm so far…):<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/warning.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/warning-300x222.jpg" alt="" title="warning" width="300" height="222" class="aligncenter size-medium wp-image-2829" /></a></p>
<p>To create a test web service I setup a MockService in SoapUI. Like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06-300x193.jpg" alt="" title="SoapUI MockService" width="300" height="193" class="aligncenter size-medium wp-image-2846" /></a><br />
All you need is a WSDL available. I just picked one from a previous project for testing purposes. With this MockService started you can fire your SOAP requests and will receive a (predefined) response from the MockService:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54-300x137.jpg" alt="" title="SoapUi Response" width="300" height="137" class="aligncenter size-medium wp-image-2847" /></a></p>
<p>Next step is create a new Mule project (I still favor <a href="http://maven.apache.org/">Maven</a> above the <a href="http://www.mulesoft.org/documentation/display/MULESTUDIO/Home">Mule Studio</a>):</p>
<ul>
<li>create new Maven project with</li>
<p><code>mvn mule-project-archetype:create -DartifactId=WSProxy -DmuleVersion=3.1.2</code></p>
<li>Set up the WS Proxy</li>
<p>To create WS Proxy I followed the description <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">here</a><br />
Note: to make use of the pre-defined &#8216;pattern&#8217; you must add the following dependency to the pom:</p>

<div class="wp_codebox"><table><tr id="p282613"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2826code13"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.mule.patterns<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-patterns-all<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>My Mule config file looks like this:</p>

<div class="wp_codebox"><table><tr id="p282614"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2826code14"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/core&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:pattern</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/pattern&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    Proxies a Web Service
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-transformer&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.proxy.wsproxy.MyTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object-to-string-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pattern:web-service-proxy</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-order-ws-proxy&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">inboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8090/my-order&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">responseTransformer-refs</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer my-transformer&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">outboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8088/mockDataServiceSoapBinding&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<li>Fire up the proxy</li>
<p>To run the Mule application just make sure your Mule installation is running and in your project execute the command &#8216;mvn clean install&#8217;<br />
You should see a message in your Mule console like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54-300x82.jpg" alt="" title="Mule console" width="300" height="82" class="aligncenter size-medium wp-image-2840" /></a>
</ul>
<p>Now we can put the proxy at work by redirecting the SoapUI request to the url: http://Pascal-Almas-MacBook-Pro.local:8090/my-order. It should the be forwarded to the original url and the translator I put in between should output the content to the Mule console:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57-300x114.jpg" alt="" title="MuleLogging" width="300" height="114" class="aligncenter size-medium wp-image-2849" /></a> </p>
<p>However if you try this for the first time big chance you will run into <a href="http://www.mulesoft.org/jira/browse/MULE-5363">this</a> issue (at least I did). To get around this issue modify the soapUI settings like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52-300x219.jpg" alt="" title="soapui-prefs" width="300" height="219" class="aligncenter size-medium wp-image-2850" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unit test your Spring/Hibernate and MongoDB setup</title>
		<link>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/</link>
		<comments>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 08:00:12 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2807</guid>
		<description><![CDATA[In my previous post I described how you can setup Spring and Hibernate in combination with the MongoDB. In this post I show you how you can write your unit test for this setup including a workaround for the fact &#8230; <a href="http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F27%2Funit-test-your-springhibernate-and-mongodb-setup%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F27%2Funit-test-your-springhibernate-and-mongodb-setup%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In my <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">previous</a> post I described how you can setup <a href="http://www.springsource.org/">Spring</a> and <a href="http://www.hibernate.org/">Hibernate</a> in combination with the <a href="http://www.mongodb.org/">MongoDB</a>. In this post I show you how you can write your unit test for this setup including a workaround for the fact that there isn&#8217;t an embedded version of MongoDB.<br />
<span id="more-2807"></span><br />
Of course you can check manually if your code works by checking the content of the MongoDB. You can use <a href="http://www.mongodb.org/display/DOCS/mongo+-+The+Interactive+Shell">the MongoDB shell</a> or the REST interface by using &#8216;curl&#8217; (when using REST make sure you start the database with the &#8216;&#8211;rest&#8217; option). For example see the result of <code>curl 'http://localhost:28017/redstream/logItem/'</code> </p>
<blockquote><p>
pascal@~$ curl &#8216;http://localhost:28017/redstream/logItem/&#8217;<br />
{<br />
  &#8220;offset&#8221; : 0,<br />
  &#8220;rows&#8221;: [<br />
    { "_id" : { "$oid" : "4e1c2ffca0eee881985e04f0" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 0" } ,<br />
    { "_id" : { "$oid" : "4e1c2ffda0eee881985e04f1" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 1" } ,<br />
    { "_id" : { "$oid" : "4e1c2ffda0eee881985e04f2" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 2" } ,<br />
    { "_id" : { "$oid" : "4e1c4289a0ee3d15a8af39d3" }, "_class" : "nl.redstream.mongo.entity.LogItem", "message" : "just some text 0" }<br />
  ],<br />
  &#8220;total_rows&#8221; : 3 ,<br />
  &#8220;query&#8221; : {} ,<br />
  &#8220;millis&#8221; : 0<br />
}<br />
pascal@~$
</p></blockquote>
<p>However, when building software you want your test to be performed automatically so we use JUnit to perform the tests and checks. And I use JUnit to start and stop my local MongoDB instance. Here is how it works (I assume you have the same project setup as I created in my <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">previous</a> post):</p>
<ul>
<li>Wire the Spring beans in your test context</li>
<p>I created a SpringContext class for testing purposes:</p>

<div class="wp_codebox"><table><tr id="p280718"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p2807code18"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.context.ApplicationContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.context.support.ClassPathXmlApplicationContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Only to be used in test classes!!
 * 
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyTestApplicationContext <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> MyTestApplicationContext testContext <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    ApplicationContext context <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> MyTestApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> MyTestApplicationContext getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>testContext <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            testContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyTestApplicationContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            testContext.<span style="color: #006633;">initialise</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> testContext<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initialise<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassPathXmlApplicationContext<span style="color: #009900;">&#40;</span>
                <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;spring-config.xml&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> getBean<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> context.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ApplicationContext getSpringContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> context<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With this class I can access my Spring beans easily in my Unit tests.</p>
<li>Write the test class</li>
<p>I use <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/ProcessBuilder.html">ProcessBuilder</a> to start and stop the local MongoDB instance before the test class is executed. The base Testclass looks like this:</p>

<div class="wp_codebox"><table><tr id="p280719"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code" id="p2807code19"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.After</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.AfterClass</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.BeforeClass</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MongoDBTest <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>MongoDBTest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprocess+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Process</span></a> p <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    @Before
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//@Todo Run mongo with a test specific .js file to produce initial data state</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @After
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//@Todo Drop database</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @BeforeClass
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> beforeClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> command <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;/Users/pascal/development/mongodb-osx-x86_64-1.8.2/bin/mongod&quot;</span>, <span style="color: #0000ff;">&quot;--dbpath&quot;</span>, <span style="color: #0000ff;">&quot;/Users/pascal/development/mongodb/data&quot;</span>, <span style="color: #0000ff;">&quot;--rest&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        ProcessBuilder pb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ProcessBuilder<span style="color: #009900;">&#40;</span>command<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        p <span style="color: #339933;">=</span> pb.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Process started with pid: &quot;</span> <span style="color: #339933;">+</span> p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @AfterClass
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> afterClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Stop mongod process</span>
        <span style="color: #000066; font-weight: bold;">boolean</span> processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>p <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>processClosed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                    p.<span style="color: #006633;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; Process destroyed: &quot;</span> <span style="color: #339933;">+</span> p.<span style="color: #006633;">exitValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalthreadstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalThreadStateException</span></a> itse<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    logger.<span style="color: #006633;">warn</span><span style="color: #009900;">&#40;</span>itse<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    processClosed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And the actual test class:</p>

<div class="wp_codebox"><table><tr id="p280720"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p2807code20"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.Assert</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.mongo.entity.LogItem</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.mongo.services.LogService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.bson.types.ObjectId</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogServiceTest <span style="color: #000000; font-weight: bold;">extends</span> MongoDBTest <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>LogServiceTest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> LogService<span style="color: #339933;">&lt;</span>LogItem<span style="color: #339933;">&gt;</span> service <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCreateAndFindLog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
        ObjectId id <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            LogItem log <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LogItem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            log.<span style="color: #006633;">setMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;just some text &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            id <span style="color: #339933;">=</span> service.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>log<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log.id = &quot;</span> <span style="color: #339933;">+</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        LogItem logFound <span style="color: #339933;">=</span> service.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log = &quot;</span> <span style="color: #339933;">+</span> logFound.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertNotNull</span><span style="color: #009900;">&#40;</span>logFound<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Before
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setting up test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        service <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LogService<span style="color: #339933;">&lt;</span>LogItem<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> MyTestApplicationContext.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;logService&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//@TODO Run mongo with a test specific .js file to produce initial data state</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<li>Run it!</li>
<p>The test output shows it ran successfully:</p>
<blockquote><p>
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 T E S T S<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Running nl.redstream.mongo.LogServiceTest<br />
DEBUG [main] nl.redstream.mongo.MongoDBTest: Process started with pid: java.lang.UNIXProcess@603b1d04<br />
INFO  [main] nl.redstream.mongo.LogServiceTest: setting up test<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fdf<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fe0<br />
DEBUG [main] nl.redstream.mongo.services.MongoDBLoggerServiceImpl: Adding a new LogItem instance<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log.id = 4e2fc241a0eea3de77684fe1<br />
DEBUG [main] nl.redstream.mongo.LogServiceTest: log = LogItem [id=4e2fc241a0eea3de77684fe1, message=just some text 2, timestamp=null]<br />
INFO  [main] nl.redstream.mongo.MongoDBTest:  Process destroyed: 12<br />
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.798 sec</p>
<p>Results :</p>
<p>Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</p></blockquote>
</ul>
<p>There is definitely room for improvement, like adding the possibility to run &#8216;.js&#8217; scripts to set the database in a predefined state in the @Before method of the test class and remove the database in the @After method.<br />
Another thing that bothered me is the &#8216;Thread.sleep&#8217; that I had to add at some places to make it work. Nevertheless I showed how to setup a basic test case with MongoDB/Spring combination and if you have a better solution please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/27/unit-test-your-springhibernate-and-mongodb-setup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use Spring and Hibernate with MongoDB</title>
		<link>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/</link>
		<comments>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 09:12:53 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2801</guid>
		<description><![CDATA[One of the requirements we have for one of our Mule ESB implementations is to log the messages that went through the ESB (especially handy during development and testing). There has been written a lot already about logging with Mule &#8230; <a href="http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F14%2Fuse-spring-and-hibernate-with-mongodb%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F14%2Fuse-spring-and-hibernate-with-mongodb%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the requirements we have for one of our Mule ESB implementations is to log the messages that went through the ESB (especially handy during development and testing). There has been written a lot already about logging with Mule so I am not going to discuss that again. In this post I&#8217;ll only show you how you can use Spring/Hibernate and <a href="http://www.mongodb.org/">MongoDB</a> to store your messages in the MongoDB, because a document-oriented database like MongoDB is a nice fit for this requirement.<br />
<span id="more-2801"></span></p>
<p>The first thing to do is to install MongoDB on your machine (unfortunately it is not yet possible to run it embedded so we use a local instance instead). For installation see <a href="http://www.mongodb.org/display/DOCS/Quickstart+OS+X">this</a>.</p>
<p>After MongoDB is installed we can create a new standard Maven project and modify the generated pom.xml to the following <a href="http://www.redstream.nl/wp-content/uploads/2011/07/pom.xml">pom.xml</a>.</p>
<p>Next step is the creation of the Hibernate Entity class like this:</p>

<div class="wp_codebox"><table><tr id="p280124"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code" id="p2801code24"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mongo.entity</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.bson.types.ObjectId</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Model object 
 * @author pascal
 */</span>
@<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aentity+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Entity</span></a>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;logItems&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogItem <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserializable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Serializable</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
    @Id
    <span style="color: #000000; font-weight: bold;">private</span> ObjectId id<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> timestamp<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ObjectId getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span>ObjectId id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> message<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMessage<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">message</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getTimestamp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> timestamp<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setTimestamp<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> timestamp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">timestamp</span> <span style="color: #339933;">=</span> timestamp<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;LogItem [id=&quot;</span> <span style="color: #339933;">+</span> id <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, message=&quot;</span> <span style="color: #339933;">+</span> message <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, timestamp=&quot;</span> <span style="color: #339933;">+</span> timestamp <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you might notice I have used the ObjectId as primary Id. I was forced to this by bug <a href="https://jira.springsource.org/browse/DATADOC-176">DATADOC-176</a> which only recently got fixed.</p>
<p>The Dao and Service object classes that are used to access the MongoDB are:</p>
<ul>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/BaseDao.java">BaseDao.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/AbstractBaseDao.java">AbstractBaseDao.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/LogItemDaoImpl.java">LogItemDaoImpl.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/LogService.java">LogService.java</a></li>
<li><a href="http://www.redstream.nl/wp-content/uploads/2011/07/MongoDBLoggerServiceImpl.java">MongoDBLoggerServiceImpl.java</a></li>
</ul>
<p>Now wire this all together with the following spring config files:</p>

<div class="wp_codebox"><table><tr id="p280125"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p2801code25"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=</span>
<span style="color: #009900;">               <span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans</span>
<span style="color: #009900;">                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;spring-mongodb-config.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;logService&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.mongo.services.MongoDBLoggerServiceImpl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dao&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;logDao&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;logDao&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.mongo.dao.LogItemDaoImpl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>and the &#8216;spring-mongodb-config.xml&#8217; (as described <a href="http://static.springsource.org/spring-data/data-document/docs/1.0.0.M3/reference/html/#mongodb-connectors">here</a>):</p>

<div class="wp_codebox"><table><tr id="p280126"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p2801code26"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:mongo</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/data/mongo&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=</span>
<span style="color: #009900;">               <span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans</span>
<span style="color: #009900;">                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</span>
<span style="color: #009900;">                http://www.springframework.org/schema/data/mongo</span>
<span style="color: #009900;">                http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Default bean name is 'mongo' --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mongo:mongo</span> <span style="color: #000066;">host</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span> <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;27017&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- OPTIONAL: configure &lt;mongo:options /&gt; --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mongo:mongo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mongo:db-factory</span> <span style="color: #000066;">dbname</span>=<span style="color: #ff0000;">&quot;redstream&quot;</span> <span style="color: #000066;">mongo-ref</span>=<span style="color: #ff0000;">&quot;mongo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mongoTemplate&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.data.document.mongodb.MongoTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;mongoDbFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>That&#8217;s it. Now you have a foundation to start using MongoDB with Spring and Hibernate classes. In the next post I will show how you can test this setup without manually having to start and stop MongoDB.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/14/use-spring-and-hibernate-with-mongodb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing your own Altova MapForce Extension</title>
		<link>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/</link>
		<comments>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 20:24:00 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MapForce]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2703</guid>
		<description><![CDATA[In a previous post, I mentioned that you could extend the function library in Altova MapForce and add your own functions. In this post I&#8217;ll show you (briefly) how to do this using the Java methods from the previous post. &#8230; <a href="http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F05%2Fwriting-your-own-altova-mapforce-extension%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F07%2F05%2Fwriting-your-own-altova-mapforce-extension%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In a <a href="http://www.redstream.nl/2011/03/29/xslt-2-0-and-java-extensions/">previous</a> post, I mentioned that you could extend the function library in Altova MapForce and add your own functions. In this post I&#8217;ll show you (briefly) how to do this using the Java methods from the previous post.</p>
<p><span id="more-2703"></span></p>
<p>The MapForce documentation only contains a little information on how to add your own custom functions. </p>
<p>The base directory in which you installed MapForce contains a directory called <code>MapForceLibraries</code>. Here, you will find a number of, so called, <code>mff</code> files, which stands for MapForce Functions. Inside, the definition is stored of the functions you are able to select from the library when working on a mapping. We will be using this principle to add an extension of our own. The only thing we need to do, is create such a <code>mff</code> file. </p>
<p>As I already said, the MapForce documentation does not contain a lot of information on this subject. But &#8230; what it does include is the XML Schema for the <code>mff</code> file. It is called <code>mff.xsd</code> and it is also located in the <code>MapForceLibraries</code> directory. Open the XML Schema in XMLSpy (or any other XML editor) and select element <code>mapping</code> to get an overview of the library structure. Notice that the XML Schema is well-documented (at least better than the actual MapForce documentation). </p>
<p>We will, briefly, walk through the most important elements. First, element <code>mapping</code>: the root element. </p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-mapping.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-mapping.png" alt="" title="mapforce-mff-mapping" width="338" height="227" class="alignnone size-full wp-image-2709" /></a><br/></p>
<p>First, element <code>implementations</code>. This element refers to the possible implementations of your extension (e.g. Java, XSLT, C#, etc).</p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-implementations.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-implementations.png" alt="" title="mapforce-mff-implementations" width="627" height="253" class="alignnone size-full wp-image-2708" /></a></p>
<p>Functions can be grouped, hence the <code>group</code> element. The <code>component</code> element inside describes how your extension should be called. The <code>target</code> describe your input parameters (if any) and <code>output</code> describes your output.</p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-group.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-mff-group.png" alt="" title="mapforce-mff-group" width="499" height="427" class="alignnone size-full wp-image-2706" /></a></p>
<p>Here&#8217;s what an example XML could look like. We used an <code>xslt2</code> implementation that points to a xslt stylesheet.</p>

<div class="wp_codebox"><table><tr id="p270330"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2703code30"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mapping</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:noNamespaceSchemaLocation</span>=<span style="color: #ff0000;">&quot;file:///C:/Program%20Files/Altova/MapForce2011/MapForceLibraries/mff.xsd&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">library</span>=<span style="color: #ff0000;">&quot;redstream&quot;</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span style="color: #000066;">xmlns:mf</span>=<span style="color: #ff0000;">&quot;http://www.altova.com/MapForce/2010/standard&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;xslt2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setting</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;xsltfilename&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;xlst-redstream-library.xsl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;group</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;demo functions&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;greeting&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datapoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;targets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datapoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/targets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;xslt2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;function</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;rs:greeting&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.XsltUtils&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;short<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>result = 'Hello ' + name + ' !'<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/short<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;long<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Returns friendly message.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/long<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/group<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The related XSLT file looks like this:</p>

<div class="wp_codebox"><table><tr id="p270331"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p2703code31"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:fn</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/xpath-functions&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns:rs</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.utils.XsltUtils&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:function</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;rs:greeting&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;rs:greeting($name)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:function<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Once, you&#8217;ve created your <code>mff</code> and <code>xslt</code> file, copy them into <code>MapForceLibraries</code> directory (make sure MapForce is not running, otherwise you will not be able to write in that directory). Start Altova MapForce, create a new mapping (implemenation <code>xslt2</code> and behold &#8230; your extension will show up in the Library. </p>
<p><a href="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-custom-library.png"><img src="http://www.redstream.nl/wp-content/uploads/2011/05/mapforce-custom-library.png" alt="" title="mapforce-custom-library" width="286" height="165" class="alignnone size-full wp-image-2729" /></a></p>
<p>Now, you can drag-and-drop the function onto your mapping.</p>
<p>The resulting XSLT will look like this:</p>

<div class="wp_codebox"><table><tr id="p270332"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2703code32"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">This file was generated by Altova MapForce 2011sp1</span>
&nbsp;
<span style="color: #808080; font-style: italic;">YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE</span>
<span style="color: #808080; font-style: italic;">OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.</span>
&nbsp;
<span style="color: #808080; font-style: italic;">Refer to the Altova MapForce Documentation for further details.</span>
<span style="color: #808080; font-style: italic;">http://www.altova.com/mapforce</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:fn</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/xpath-functions&quot;</span> </span>
<span style="color: #009900;">                                              <span style="color: #000066;">xmlns:rs</span>=<span style="color: #ff0000;">&quot;java:nl.redstream.XsltUtils&quot;</span> <span style="color: #000066;">exclude-result-prefixes</span>=<span style="color: #ff0000;">&quot;xs fn rs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;xml&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">indent</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dataset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;row<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;dataset/row/column&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;rs:greeting(fn:string(@name))&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/row<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dataset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Unfortunately, you cannot display the results of the customized mapping in MapForce (#featurerequest). Instead, you could use XMLSpy and use the settings from the <a href="http://www.redstream.nl/2011/03/29/xslt-2-0-and-java-extensions/">previous</a> post.</p>
<p>That&#8217;s it &#8230; enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/07/05/writing-your-own-altova-mapforce-extension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mule in the Cloud: First impression</title>
		<link>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/</link>
		<comments>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 07:24:34 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Mule iON]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2746</guid>
		<description><![CDATA[Like I posted before Mulesoft has released a new platform: iPAAS. I just went through the starters guide and I am pretty impressed. Of course the use case in the tutorial is very simple but the whole idea of just &#8230; <a href="http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F17%2Fmule-in-the-cloud-first-impression%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F17%2Fmule-in-the-cloud-first-impression%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Like I posted <a href="http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/">before</a> Mulesoft has released a new platform: <a href="http://www.mulesoft.com/ipaas-integration-platform-as-a-service">iPAAS</a>. I just went through <a href="http://www.mulesoft.org/documentation/display/ION/Build+Your+First+Project+with+Mule+Studio">the starters guide</a> and I am pretty impressed. Of course the use case in the tutorial is very simple but the whole idea of just putting your Mule config into the cloud and it runs sounds good. And I have seen it working (you can check for yourself by submitting text to <a href="http://redstream.muleion.com/services/EchoUMO/echo/text/put%20your%20text%20here">this url</a>. <span id="more-2746"></span><br />
Here is a snapshot of the dashboard you get with you <a href="http://www.mulesoft.org/documentation/display/ION/Getting+Started">Mule iON</a> account:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/06/Screen-shot-2011-06-16-at-10.59.44.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/06/Screen-shot-2011-06-16-at-10.59.44-300x219.jpg" alt="" title="Screen shot 2011-06-16 at 10.59.44" width="300" height="219" class="aligncenter size-medium wp-image-2747" /></a><br />
Although it looks pretty nice at first sight it does raise questions and some topics for further investigation: what about security and in what use cases will this be the best solution? Mulesoft already has answers to those questions (<a href="http://www.mulesoft.org/documentation/display/ION/Secure+Data+Gateway">security</a> and <a href="http://www.mulesoft.org/documentation/display/ION/Use+Cases">use cases</a>) but I am going to find out myself and let you know my opinion. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/06/17/mule-in-the-cloud-first-impression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New products from Mulesoft</title>
		<link>http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/</link>
		<comments>http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 06:56:33 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Mule3]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Mule]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2738</guid>
		<description><![CDATA[Mulesoft recently released some new products, totally different from each other but both very welcome. The first one is MuleStudio. Mule Studio is an Eclipse-based developer tool, that allows to graphically create and test Mule ESB Flows. It is currently &#8230; <a href="http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F16%2Fnew-products-from-mulesoft%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F06%2F16%2Fnew-products-from-mulesoft%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.mulesoft.com/">Mulesoft</a> recently released some new products, totally different from each other but both very welcome.<br />
The first one is <a href="http://www.mulesoft.org/documentation/display/MULESTUDIO/Home">MuleStudio</a>. Mule Studio is an Eclipse-based developer tool, that allows to graphically create and test Mule ESB Flows. It is currently in beta but I think it might be a good reason to go back to Eclipse. Last few years I have been using Netbeans for my Mule/Java development because I liked the combination between Netbeans and Maven better.</p>
<p>The other &#8216;product&#8217; that is released is <a href="http://www.mulesoft.com/how-does-it-work">Mule iON</a>. I think a graphical development tool is nice to have but this iON thing is something that can really become big. It makes you use the cloud as the platform for your integration software. They call it the iPAAS (Integration Platform as a Service).</p>
<p>The coming days I will have a look at both and posts my findings here so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/06/16/new-products-from-mulesoft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Citrus for testing Mule ESB</title>
		<link>http://www.redstream.nl/2011/04/15/setup-citrus-for-testing-mule-esb/</link>
		<comments>http://www.redstream.nl/2011/04/15/setup-citrus-for-testing-mule-esb/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 11:50:27 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Mule2]]></category>
		<category><![CDATA[Citrus]]></category>
		<category><![CDATA[Integration Test]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2634</guid>
		<description><![CDATA[Recently, I ran into an open-source test framework called Citrus. Citrus supports you in testing message interfaces in enterprise applications. Manual testing effort as well as coding mocks and simulators are not necessary. Instead Citrus enables integration testing in an &#8230; <a href="http://www.redstream.nl/2011/04/15/setup-citrus-for-testing-mule-esb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F04%2F15%2Fsetup-citrus-for-testing-mule-esb%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F04%2F15%2Fsetup-citrus-for-testing-mule-esb%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently, I ran into an open-source test framework called <a href="http://www.citrusframework.org/">Citrus</a>. Citrus supports you in testing message interfaces in enterprise applications. Manual testing effort as well as coding mocks and simulators are not necessary. Instead Citrus enables integration testing in an automated way with out-of-the-box simulation of various message transports. We&#8217;ll use it to test our <a href="http://www.mulesoft.com/mule-esb-open-source-esb">Mule</a> based ESB.</p>
<p>Mule, of course, offers great possibility to unit test your application. And we also have a test setup which &#8216;talks&#8217; to other applications. What we didn&#8217;t have was a testing environment which we could use to test the ESB as a blackbox without being dependent on other (external) applications. And this is exactly where Citrus comes in. Citrus makes it possible to test the complete lifecycle of a message flow without being dependent of other systems, actually with Citrus you proxy these dependencies.<br />
In this post I will provide details and tips on how to setup and use Citrus. Although <a href="http://www.citrusframework.org/reference/html/index.html">the documentation</a> that is available is easy to read, it is not complete. It took me quite some effort to get it all running but like I said before the benefits of this framework are huge.<br />
<span id="more-2634"></span><br />
In the reference guide of Citrus there is a <a href="http://www.citrusframework.org/reference/html/index.html#setup-using-maven">chapter</a> about how to use Citrus with Maven. I use that guide as base and add some info that was missing in my case but is essential to get things working. I use the 1.2-SNAPSHOT edition of Citrus.</p>
<p>I took the following steps to get it running:</p>
<ol>
<li>Add repositories to your settings.xml</li>
<p>To have access to the Citrus jars you need to tell Maven where to get them. You can do this by adding the following repositories to your settings.xml (or even better to <a href="http://www.jfrog.com/products.php">Artifactory</a> or similar repository manager):</p>

<div class="wp_codebox"><table><tr id="p263437"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p2634code37"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    [...]
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>consol-labs-release<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://labs.consol.de/maven/repository/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;snapshots<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/snapshots<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;releases<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/releases<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>consol-labs-snapshots<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://labs.consol.de/maven/snapshots-repository/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;snapshots<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Policy: always, daily, interval:xxx (xxx=#minutes, 60*24*7=10080), never --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;updatePolicy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10080<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/updatePolicy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/snapshots<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;releases<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/releases<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    [...]
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<li>Add necessary dependencies to your project&#8217;s pom</li>
<p>Add the following dependencies to the pom of your project (at least the citrus-core, the others are depending on the tests you want to perform).</p>

<div class="wp_codebox"><table><tr id="p263438"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2634code38"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">consol</span>.<span style="color: #006633;">citrus</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>citrus<span style="color: #339933;">-</span>core<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1.2</span><span style="color: #339933;">-</span>SNAPSHOT<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">consol</span>.<span style="color: #006633;">citrus</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>citrus<span style="color: #339933;">-</span>http<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1.2</span><span style="color: #339933;">-</span>SNAPSHOT<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">consol</span>.<span style="color: #006633;">citrus</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>citrus<span style="color: #339933;">-</span>adapter<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1.2</span><span style="color: #339933;">-</span>SNAPSHOT<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<li>Add necessary plugins to your project&#8217;s pom</li>
<p>To generate and execute the Citrus test cases you need to add the Citrus plugins (and extra source path) to your project. This is done by adding the following to your project&#8217;s pom:</p>

<div class="wp_codebox"><table><tr id="p263439"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
</pre></td><td class="code" id="p2634code39"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-compiler-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.build.sourceEncoding}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-resources-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.build.sourceEncoding}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.consol.citrus.mvn<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>citrus-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Redstream Team<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;targetPackage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nl.redstream.test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/targetPackage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-surefire-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;skip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/skip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>citrus-tests<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>integration-test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;skip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/skip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testSourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/citrus/java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testSourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/citrus/java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>*.java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/citrus/tests<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>src/citrus/resources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>**/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testResource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<li>Create a Citrus Test Case</li>
<p>Next step is to use the Maven plugin to create a new Test Case. Run the command </p>
<blockquote><p>mvn citrus:create-test</p></blockquote>
<p> and answer the questions.<br />
Note 1: the name of the testcase is going to be the Java class name so only use the valid characters for a Java class name<br />
Note 2: Make sure the name of the testcase ends with &#8216;Test&#8217; otherwise the test isn&#8217;t found when trying to run it (at least in case you generate a JUnit4 type of test).</p>
<li>Add a &#8216;citrus-context.xml&#8217; to the classpath</li>
<p>This isn&#8217;t mentioned in the guide but is a mandatory step: you need to have a &#8216;citrus-context.xml&#8217; file on the classpath for Citrus to run your tests. Here is a snippet from the config file that can be found in the examples that are delivered with Citrus:</p>

<div class="wp_codebox"><table><tr id="p263440"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code" id="p2634code40"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:citrus</span>=<span style="color: #ff0000;">&quot;http://www.citrusframework.org/schema/config&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:citrus-ws</span>=<span style="color: #ff0000;">&quot;http://www.citrusframework.org/schema/ws/config&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:citrus-http</span>=<span style="color: #ff0000;">&quot;http://www.citrusframework.org/schema/http/config&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span>
<span style="color: #009900;">       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd</span>
<span style="color: #009900;">       http://www.citrusframework.org/schema/config http://www.citrusframework.org/schema/config/citrus-config.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
...
    <span style="color: #808080; font-style: italic;">&lt;!-- Message Validators --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;xmlMessageValidator&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.consol.citrus.validation.xml.DomXmlMessageValidator&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;connectionFactory&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.activemq.ActiveMQConnectionFactory&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;brokerURL&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.server.url}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.consol.citrus.variable.GlobalVariables&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;variables&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;project.name&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Citrus Greeting sample&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
...
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- TestSuite definition --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;citrus-samples-greeting&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.consol.citrus.TestSuite&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</ol>
<p>When all this is done you can run your test with the command:</p>
<blockquote><p>mvn clean integration-test -Dtest=YourTestNameTest</p></blockquote>
<p>In the next posts I will go into more detail about certain Test Scenarios and how to test these with Citrus.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/04/15/setup-citrus-for-testing-mule-esb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TcpTunnelGui: maybe old but still useful</title>
		<link>http://www.redstream.nl/2011/04/08/tcptunnelgui-maybe-old-but-still-useful/</link>
		<comments>http://www.redstream.nl/2011/04/08/tcptunnelgui-maybe-old-but-still-useful/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 09:14:36 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2644</guid>
		<description><![CDATA[Although the TcpTunnelerGui has been around for a while (for about 10 years now) it is still helping me out in several situations. The only thing I keep forgetting is where to get it and what the exact syntax is &#8230; <a href="http://www.redstream.nl/2011/04/08/tcptunnelgui-maybe-old-but-still-useful/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F04%2F08%2Ftcptunnelgui-maybe-old-but-still-useful%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F04%2F08%2Ftcptunnelgui-maybe-old-but-still-useful%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Although the TcpTunnelerGui has been around for a while (for about 10 years now) it is still helping me out in several situations. The only thing I keep forgetting is where to get it and what the exact syntax is to run it. So for future reference I put it in this post (and hope I remember this post&#8230;).</p>
<ol>
<li>Download the jar (soap-2.3.jar) containing the necessary classes <a href="http://mirrors.ibiblio.org/pub/mirrors/maven2/soap/soap/2.3/soap-2.3.jar">here</a></li>
<li>Open a command prompt/ terminal and go the location where the jar is located</li>
<li>Run the following command</li>
<blockquote><p>java -classpath soap-2.3.jar org.apache.soap.util.net.TcpTunnelGui 8081 localhost 8080</p></blockquote>
</ol>
<p>For more info about the tunneler see <a href="http://www.techrepublic.com/article/debug-soap-apps-with-apache-tcp-tunnelmonitor/1049605">here</a>. So, now when I need this tunneler in the future I know where I can find it and how to use it :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/04/08/tcptunnelgui-maybe-old-but-still-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

