<?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>Code3 &#187; Grails</title>
	<atom:link href="http://www.code3.dk/tag/grails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.code3.dk</link>
	<description>Techchat</description>
	<lastBuildDate>Thu, 17 Nov 2011 13:10:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Groovy CPE</title>
		<link>http://www.code3.dk/groovy-cpe/</link>
		<comments>http://www.code3.dk/groovy-cpe/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 19:45:19 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[tr069]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=349</guid>
		<description><![CDATA[I&#8217;ve been working quite a lot on a TR069 AutoConfigurationServer. As part of the prototyping I created a client emulator [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working quite a lot on a TR069 AutoConfigurationServer. As part of the prototyping I created a client emulator to more quickly and easily test out different parts of <a href="http://www.broadband-forum.org/cwmp.php">the TR069 spec</a>. I called the program <a href="http://code.google.com/p/groovycpe/">GroovyCPE</a> and it can be found on Google Code hosting. Hopefully it will be useful for others in initial bringup of TR069 servers, regression testing and performance testing. The code written in Groovy and it is licensed under the GPLv3.</p>
<p>The TR069 schemas which can be found at http://www.broadband-forum.org/cwmp.php define the communication. Unfortunately the CWMProtocol uses ancient technology &#8211; namely XML-RPC. One can find old libraries for XML-RPC on the web, but they look old and crusty. We decided to go with JAXB ( https://jaxb.dev.java.net ) to get Java classes from the schemas. However, JAXB doesn&#8217;t seem to handle the old XML-RPC ideas perfectly, so we have to apply some band-aid (more on the server side than on the client side, though). I&#8217;ll blog about this separately.</p>
<p>To get the JAXB processing to work at all I have deleted <code>fixed="1"</code> from the <code>soapenv:mustUnderstand</code> attributes.</p>
<p>The HTTP communication of GroovyCPE is done with the help of the <a href="http://hc.apache.org/httpclient-3.x/">Apache HttpComponents v3</a> which is a pretty OK library for HTTP communication.</p>
<p>The initial configuration content in testfiles/parameters_tg784/get*.txt is from a Thomson TG784 box.</p>
<p>GroovyCPE is built around a central store of the parameters it reads in. And as much as possible it uses the configuration parameters it self &#8211; eg. for the ManagementServer URL and the PeriodicInformInterval.</p>
<p>What it can do:</p>
<ul>
<li>Immediately send Inform messages with all event types</li>
<li>Run a thread that sends scheduled Inform messages according to the PeriodicInformInterval</li>
<li>Listen for connection requests on the ConnectionRequestURL (and send an Inform if requested</li>
<li>Accept a DownloadRequest and initiate an HTTP download session according to the contents</li>
<li>Respond to GetParameter{Names,Values,Attributes} requests.</li>
<li>Accept SetParameter{Values,Attributes} and set the values</li>
<li>Accept AddObject requests and add objects (but only if the object layout is known from the configuration parameters)</li>
</ul>
<p>I don&#8217;t have any immediate plans for improvements to GroovyCPE. At some point I will probably look at fixing the JAXB classes at generation time with a JAXB plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/groovy-cpe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating, consuming and testing SOAP webservices on Grails</title>
		<link>http://www.code3.dk/creating-consuming-and-testing-soap-webservices-on-grails/</link>
		<comments>http://www.code3.dk/creating-consuming-and-testing-soap-webservices-on-grails/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 09:05:14 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=341</guid>
		<description><![CDATA[We are currently making a backend system, that has its services exposed as webservices. Since making web applications in Grails [...]]]></description>
			<content:encoded><![CDATA[<p>We are currently making a backend system, that has its services exposed as webservices. Since making web applications in Grails is pretty nice, we decided to try it for webservices.</p>
<p>Getting up and running was certainly a breeze.</p>
<p><code><br />
grails create-app ...<br />
grails install-plugin cxf<br />
</code></p>
<p>Grails is a plugin-based framework. And the <a href="http://grails.org/plugin/cxf/">cxf plugin</a> seems to be the best plugin for webservices right now. Exposing the services was then as simple as adding a</p>
<p><code>static expose=['cxf']</code></p>
<p>to the the grails service classes. We wante to allow our service interfaces to operate with complex objects. And to do that best we decided to use the <a href="http://www.grails.org/plugin/dto">DTO plugin</a> and specify our interfaces in terms of DTOs mostly generated from our domain objects. This was only a semi-good idea, I think, as the conversion to/from complex domain objects was not great out of the box (more on that in another post).</p>
<p>To consume webservices, the most straighforward way is to simply dump the <a href="http://groovy.codehaus.org/GroovyWS+installation">minimal jar of the GroovyWS module</a> in the lib folder of the project. Since we already had all the dependencies included by the cxf plugin the minimal jar is all that is needed.</p>
<p>To test the services, most of our test were simply the usual integration tests of the service classes. But for functional tests we used the <a href="http://www.grails.org/plugin/functional-test">functional-tests plugin</a> and the GroovyWS client we already had installed. </p>
<pre class="brush: java">
class MyServiceFunctionalTests extends functionaltestplugin.FunctionalTestCase {

	def myServicePort

	protected void setUp() {
		super.setUp();

		myServicePort = new WSClient(&quot;http://localhost:9091/myservice/services/my?wsdl&quot;, this.class.classLoader)
		myServicePort.initialize()
	}

	public void testAMethod(){
		final List resultVals = myServicePort.aMethod();

		assertEquals(4, resultVals.size());
	}
}
</pre>
<p>It feels a bit wrong to work with old and crufty technology like SOAP with shiny new technology like Groovy on Grails. But with that in mind it works surprisingly well. Points where I found the greatest room for improvement were.</p>
<ul>
<li>Grails has great support for Controllers as entrypoints, with interceptors for logging and authorization. For Services this seems harder if not impossible. I haven&#8217;t succeeded in using either groovys <a href="http://groovy.codehaus.org/Using+invokeMethod+and+getProperty">invokeMethod</a> or the built-in spring support for aspect-oriented-programing.</li>
<li>As mentioned above, the DTO plugin could use a more flexible mapping tool than the one it has.</li>
<li>With code that has no immediate GUI feedback, testing is extremely important. But the Grails test run so slow that it is annoying.</li>
</ul>
<p>Still, would I recommend Grails for a large SOAP project. Yes, I would.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/creating-consuming-and-testing-soap-webservices-on-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first patch to Grails accepted</title>
		<link>http://www.code3.dk/my-first-patch-to-grails-accepted/</link>
		<comments>http://www.code3.dk/my-first-patch-to-grails-accepted/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 10:58:12 +0000</pubDate>
		<dc:creator>mil</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=337</guid>
		<description><![CDATA[I recently wrote a patch for Grails to support dateCreated and lastUpdated when using mockDomain in unit tests.
This patch has [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wrote a patch for Grails to support <code>dateCreated</code> and <code>lastUpdated</code> when using <code>mockDomain</code> in unit tests.</p>
<p>This patch has now been applied to 1.2-SNAPSHOT.</p>
<p><a rel="nofollow" href="http://jira.codehaus.org/browse/GRAILS-4540">http://jira.codehaus.org/browse/GRAILS-4540</a></p>
<p>The <code>mockDomain</code> method makes it possible to test code that uses GORMs dynamic methods, without having to use a real database.</p>
<p>IBM Developerworks has a great article on mock testing in Grails <a rel="nofollow" href="http://www.ibm.com/developerworks/java/library/j-grails10209/index.html">here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/my-first-patch-to-grails-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to debug grails run-app loop</title>
		<link>http://www.code3.dk/how-to-debug-grails-run-app-loop/</link>
		<comments>http://www.code3.dk/how-to-debug-grails-run-app-loop/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 09:21:12 +0000</pubDate>
		<dc:creator>mil</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=331</guid>
		<description><![CDATA[I recently had a problem where grails run-app would start
the server, then immediately recompile 1 class, then restart&#8230; and
repeat.
Google told [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a problem where <code>grails run-app</code> would start<br />
the server, then immediately recompile 1 class, then restart&#8230; and<br />
repeat.</p>
<p>Google told me that the problem probably was an empty Java file in my<br />
project and to look in the<br />
<code>~/.grails/1.2-M4/projects/myproject/classes</code> directory to<br />
see which file kept changing timestamp.</p>
<p>However, no files did that. The solution was to modify<br />
<code>$GRAILS_HOME/scripts/_GrailsCompile.groovy</code> and add<br />
<code>listFiles:true</code> to the compile target:</p>
<pre class="brush: groovy">
ant.groovyc(destdir:classesDirPath,
classpathref:classpathId,
encoding:&quot;UTF-8&quot;,
listFiles:true,
compilerPaths.curry(classpathId, false))
</pre>
<p>And it turned out Google was right, I had a Java file with only the<br />
package specification in it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/how-to-debug-grails-run-app-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Console output from Grails tests</title>
		<link>http://www.code3.dk/console-output-from-grails-tests/</link>
		<comments>http://www.code3.dk/console-output-from-grails-tests/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 07:13:30 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=328</guid>
		<description><![CDATA[For casual testing in Grails, it would be nice to be able to just have the output of the tests [...]]]></description>
			<content:encoded><![CDATA[<p>For casual testing in Grails, it would be nice to be able to just have the output of the tests dumped to the console that the tests were run from. This doesn&#8217;t seem possible in the default setup, but adding these lines </p>
<pre class="brush: java">
		if(argsMap[&#039;no-reports&#039;]){
			println testRunner.out.toString()
			println testRunner.err.toString()
		}
</pre>
<p>should do the trick, if you add them to <strong>$GRAILS_HOME/script/_GrailsTest.groovy</strong> in the &#8220;runTests&#8221; closure, right after &#8221; <code>def result = testRunner.runTests(testSuite)</code>&#8221; </p>
<p>With those lines in place you can run your test like<br />
</br><br />
<code>grails -Dserver.port=9090 test-app -integration -no-reports MyController</code><br />
</br><br />
Specifying the name of the class to test is important since only the output from the last test class will be printed. So we might as well only run one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/console-output-from-grails-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependent dropdowns in Grails</title>
		<link>http://www.code3.dk/dependent-dropdowns-in-grails/</link>
		<comments>http://www.code3.dk/dependent-dropdowns-in-grails/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 10:46:25 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=324</guid>
		<description><![CDATA[It does really seem to be a very common problem with the dependend or chained drop-downs. At least it was [...]]]></description>
			<content:encoded><![CDATA[<p>It does really seem to be a <a href="http://www.code3.dk/dependent-dropdowns-in-seam-and-richfaces/">very common problem</a> with the dependend or chained drop-downs. At least it was one of the first problems I faced in the Grails app I&#8217;m working on now.</p>
<p>The solution is not really more or less elegant than the one for Seam and Richfaces. I followed <a href="http://www.grails.org/AJAX-Driven+SELECTs+in+GSP">the guide on Grails.org</a> but decided to make the solution a bit more general. So I pass the name of the select-element-to-update as a string to the update function. This way I can also put the function in a separate file for inclusion (updateselect.js).</p>
<pre class="brush: javascript">
function updateSelect(e, elemId) {
// The response comes back as a bunch-o-JSON
var values = eval(&quot;(&quot; + e.responseText + &quot;)&quot;) // evaluate JSON

if (values) {
updateSelectFromJSON(values, elemId);
}
}

function updateSelectFromJSON(values, elemId) {
var rselect = document.getElementById(elemId)
// 	Clear all previous options
rselect.options.length = 0

// Rebuild the select
for (var i=0; i &lt; values.length; i++) {
var opt = document.createElement(&#039;option&#039;);
opt.text = values[i].name
opt.value = values[i].id
try {
rselect.add(opt, null) // standards compliant; doesn&#039;t work in IE
} catch(ex) {
rselect.add(opt) // IE only
}
}
}
</pre>
<p>Which is then called like this</p>
<pre class="brush: xml">

...

&lt;form&gt;
optionKey=&quot;id&quot; optionValue=&quot;name&quot; name=&quot;country.name&quot; id=&quot;country.name&quot; from=&quot;${Country.list()}&quot;
onchange=&quot;${remoteFunction(
controller:&#039;country&#039;,
action:&#039;ajaxGetCities&#039;,
params:&#039;&#039;id=&#039; + escape(this.value)&#039;,
onComplete:&#039;&#039;&#039;updateSelect(e, &#039;city&#039;)&#039;&#039;&#039;)}&quot;
&gt;

&lt;/form&gt;</pre>
<p>One thing is missing from this solution, though. Unlike the solution on grails.org, the chained select is not updated based on the default value of the previous select. This can be fixed by inserting the following in the head element of the .gsp page.</p>
<pre class="brush: xml">

function init() {
document.cityform[&#039;country.name&#039;].onchange();
}
window.onload = init;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/dependent-dropdowns-in-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails bash completion</title>
		<link>http://www.code3.dk/grails-bash-completion/</link>
		<comments>http://www.code3.dk/grails-bash-completion/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 10:45:49 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[ant-deb-task]]></category>
		<category><![CDATA[bashcompletion]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=320</guid>
		<description><![CDATA[I&#8217;ve started doing some Grails development. So far it seems great. Here are a couple of notes to start with.
Grails [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started doing some Grails development. So far it seems great. Here are a couple of notes to start with.</p>
<p>Grails is not packaged officially for Ubuntu yet. And the packages that can be downloaded from grails.org don&#8217;t have bash completion. <a href="http://groups.google.com/group/groovyvan/browse_thread/thread/6a2f95ebbfa4c8ea?pli=1">This guy</a> however packaged grails for Debian/Ubuntu, and it include a bash completion script. <a href="http://code.google.com/p/ant-deb-task/">The package</a> seems to work great, and for one of my machines where I already installed grails from the usual tar.gz download, I pulled out the bash completion from the deb-package. To make it work completely with the tar.gz dowload I just had to modify the location of the grails installation (to use $GRAILS_HOME). Ahhhh.</p>
<p>Somewhat less useful (but fun), I also added the Ubuntu &#8220;notify-send&#8221; notification feature <a href="http://colinharrington.net/blog/2009/05/grails-growl-like-notifications-in-linux-ubuntu-904/">described here</a>. I feel all set for Grails development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/grails-bash-completion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

