<?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>On The Rhoads/Brad &#187; testing</title>
	<atom:link href="http://ontherhoads.org/brad/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://ontherhoads.org/brad</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 00:00:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calling A Service From The Grails Console</title>
		<link>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/</link>
		<comments>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 07:47:05 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=54</guid>
		<description><![CDATA[I&#8217;m doing my first project in Grails and intend to blog some of thing things I&#8217;m learning.
During development, the grails console is very useful for testing specific pieces of code without having to go through your whole system to get to that particular bit of code.
For the most part, you can just enter grails commands [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing my first project in Grails and intend to blog some of thing things I&#8217;m learning.</p>
<p>During development, the grails console is very useful for testing specific pieces of code without having to go through your whole system to get to that particular bit of code.</p>
<p>For the most part, you can just enter grails commands and hit execute. But apparently dependency inject doesn&#8217;t happen in the console. So there&#8217;s a bit of a trick to execute a service from the console.</p>
<p>If you had a service named MySecretService with a function named secretSquirell, you could access it via dependency injection in a domain class, a controller or another service by first adding</p>
<p><code>def mySecretService</code></p>
<p>then later you can say<br />
<code>def result = mySecretService.secretSquirell()</code></p>
<p>But to test in the console you need to do this:</p>
<p><code>def service = ctx.getBean("mySecretService")</code><br />
<code>def result = service.secretSquirell()</code></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;t=Calling+A+Service+From+The+Grails+Console" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

