<?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; Testing</title>
	<atom:link href="http://www.code3.dk/tag/testing/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>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>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>Using python SUDS for web service testing</title>
		<link>http://www.code3.dk/using-python-suds-for-web-service-testing/</link>
		<comments>http://www.code3.dk/using-python-suds-for-web-service-testing/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 12:43:06 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SUDS]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=212</guid>
		<description><![CDATA[

I used to use something like SoapUI for casual calling of webservices. But most of the time a GUI feels [...]]]></description>
			<content:encoded><![CDATA[<div class="entry">
<div class="snap_preview">
<p>I used to use something like <a href="http://www.soapui.org/" rel="nofollow">SoapUI</a> for casual calling of webservices. But most of the time a GUI feels like overkill for just calling one webservice function.</p>
<p>Recently I found the <a href="https://fedorahosted.org/suds/" rel="nofollow">python SUDS</a> library . It is so simple that I now just launch my all webservice calls from the command line.</p>
<pre class="brush: python">
from suds import WebFault
from suds.client import Client

client = Client(&#039;http://localhost:8080/myapp/mywebservice?wsdl&#039;)

print client

print client.service.MyFunction(&#039;Hello&#039;)
</pre>
<p>The “print client” in the middle prints an overview of the functions defined in the wsdl (nice to have). It is really easy. The only problem is that SUDS is not packaged in Debian/Ubuntu yet, so it is a little more trouble to install than just “apt-get install ….”. Maybe I should try to do something about that.</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/using-python-suds-for-web-service-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

