<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Overiding Singletons For Testing</title>
	<atom:link href="http://blog.james-carr.org/2007/07/07/overiding-singletons-for-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.james-carr.org/2007/07/07/overiding-singletons-for-testing/</link>
	<description>Rants and Musings of an Agile Developer</description>
	<pubDate>Sat, 22 Nov 2008 07:09:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: ScreenCast! : 0xDEADBEEFCAFE</title>
		<link>http://blog.james-carr.org/2007/07/07/overiding-singletons-for-testing/#comment-25534</link>
		<dc:creator>ScreenCast! : 0xDEADBEEFCAFE</dc:creator>
		<pubDate>Sun, 08 Jul 2007 08:08:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.james-carr.org/?p=86#comment-25534</guid>
		<description>[...] Heh, mute the audio and check out my first webcast! This is an experiment, and I don&#8217;t show anything groundbraking, in fact I just recode the problem from James Carr blog. I just wanted to show one usefull pattern in action. [...]</description>
		<content:encoded><![CDATA[<p>[...] Heh, mute the audio and check out my first webcast! This is an experiment, and I don&#8217;t show anything groundbraking, in fact I just recode the problem from James Carr blog. I just wanted to show one usefull pattern in action. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Derricutt</title>
		<link>http://blog.james-carr.org/2007/07/07/overiding-singletons-for-testing/#comment-25445</link>
		<dc:creator>Mark Derricutt</dc:creator>
		<pubDate>Sat, 07 Jul 2007 06:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.james-carr.org/?p=86#comment-25445</guid>
		<description>I was doing something very similar last week to get some tests working.  I ended up actually using a ThreadLocal singleton with a private setter rather than an a subclass.

The tests pass in an anonymous inner implementation specific to the test at hand via a simple helper method:

  final String[] reminderSmsMessage = new String[1];  
  BindUtils.bindSmsSender(new SendSMS() {
    public void sendSms(String to, UserVo userVo, String message, String messageId, String rateCode) {
      reminderSmsMessage[0] = message;
    }
  });


From here I do something and can track the results of the message send.

bindSmsSender() sinply does:

Method method = SendSMS.class.getDeclaredMethod("bind", SendSMS.class);
method.setAccessible(true);
method.invoke(null, sendSMS);</description>
		<content:encoded><![CDATA[<p>I was doing something very similar last week to get some tests working.  I ended up actually using a ThreadLocal singleton with a private setter rather than an a subclass.</p>
<p>The tests pass in an anonymous inner implementation specific to the test at hand via a simple helper method:</p>
<p>  final String[] reminderSmsMessage = new String[1];<br />
  BindUtils.bindSmsSender(new SendSMS() {<br />
    public void sendSms(String to, UserVo userVo, String message, String messageId, String rateCode) {<br />
      reminderSmsMessage[0] = message;<br />
    }<br />
  });</p>
<p>From here I do something and can track the results of the message send.</p>
<p>bindSmsSender() sinply does:</p>
<p>Method method = SendSMS.class.getDeclaredMethod(&#8221;bind&#8221;, SendSMS.class);<br />
method.setAccessible(true);<br />
method.invoke(null, sendSMS);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
