<?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>the higher you fly</title>
	<atom:link href="http://mikemclean.ca/wp/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikemclean.ca/wp</link>
	<description></description>
	<lastBuildDate>Tue, 22 Nov 2011 23:33:58 +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>Hibernate, Spring Security and list paging</title>
		<link>http://mikemclean.ca/wp/2011/11/22/hibernate-spring-security-and-list-paging/</link>
		<comments>http://mikemclean.ca/wp/2011/11/22/hibernate-spring-security-and-list-paging/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 23:33:58 +0000</pubDate>
		<dc:creator>mikem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/?p=528</guid>
		<description><![CDATA[Of the dangers of using Spring Security, Hibernate and paging Here&#8217;s a tricky one; we need to do paging on one of our listing pages. The obvious solution was the following, which is a common pattern: @Secured(value={Roles.PERSON_READ}) public List&#60;Person&#62; getPeople(int offset, int max) { Criteria criteria = getSession().createCriteria(Person.class); criteria.setFirstResult(offset; criteria.setMaxResults(max); return criteria.list(); } Can you]]></description>
			<content:encoded><![CDATA[<p>Of the dangers of using Spring Security, Hibernate and paging</p>
<p>Here&#8217;s a tricky one; we need to do paging on one of our listing pages. The obvious solution was the following, which is a common pattern:</p>
<pre class="brush:java">
@Secured(value={Roles.PERSON_READ})
public List&lt;Person&gt; getPeople(int offset, int max) {
   Criteria criteria = getSession().createCriteria(Person.class);
   criteria.setFirstResult(offset;
   criteria.setMaxResults(max);
   return criteria.list();
}
</pre>
<p>Can you see it? The bug I mean? See it? How about now? Now?</p>
<p>The problem lies in the @Secured annotation. This little guy is SOOOOOO useful for us, but it will burn you once in a while. This annotation will proxy the method and remove any objects which you aren&#8217;t allowed to get back. i.e.: It will filter the returned list.</p>
<p>I guess you see it now: If I ask Hibernate to give me rows from 20 to 50, I am in no way garanteed to get back 30 results since Spring will remove items from my list AFTER the query has run and Hibernate has created the list.</p>
<p>The solution? I guess that really depends on your own requirements. Given our own volume and requirements, pulling out all the data on each page request is acceptable (we have a query cache enabled, so it&#8217;s not as bad as it may sound).</p>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/11/22/hibernate-spring-security-and-list-paging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-08-15</title>
		<link>http://mikemclean.ca/wp/2011/08/15/links-for-2011-08-15/</link>
		<comments>http://mikemclean.ca/wp/2011/08/15/links-for-2011-08-15/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 20:02:00 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/08/15/links-for-2011-08-15/</guid>
		<description><![CDATA[Perlis Languages (tags: programming languages)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://blog.fogus.me/2011/08/14/perlis-languages/">Perlis Languages</a></div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/Ensonik/programming">programming</a> <a href="http://www.delicious.com/Ensonik/languages">languages</a>)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/08/15/links-for-2011-08-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing http calls with NanoHTTPD</title>
		<link>http://mikemclean.ca/wp/2011/08/02/testing-http-calls-with-nanohttpd/</link>
		<comments>http://mikemclean.ca/wp/2011/08/02/testing-http-calls-with-nanohttpd/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 01:53:31 +0000</pubDate>
		<dc:creator>mikem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/?p=520</guid>
		<description><![CDATA[Well, we finally got tired of over engineering 2 lines of code just to make it testable. I&#8217;m talking about those classes which have some http calls done throughout some code; intermingled with maybe some error handling, some conditional logic, etc .. In other words, you want to test everything around the http call, but]]></description>
			<content:encoded><![CDATA[<p>Well, we finally got tired of over engineering 2 lines of code just to make it testable. I&#8217;m talking about those classes which have some http calls done throughout some code; intermingled with maybe some error handling, some conditional logic, etc ..</p>
<p>In other words, you want to test everything around the http call, but don&#8217;t care about the call actually being made or not. Yes, yes, yes. I know; just abstract out the call to another class, then mock that &#8230; pain in the ass! Use Spring rest template. Pain in the ass and overkill and doesn&#8217;t work well in multi threaded setups.</p>
<p>The solution we now use here is called <a href="http://elonen.iki.fi/code/nanohttpd/" target="_blank">NanoHTTPD</a> which is a tiny, tiny, miniscule http server which can easily run inside a suite of tests. It can easily be extended to intercept calls. For example, we have:</p>
<ul>
<li>A HitCountingNanoHTTPD implementation which counts how many times the server was hit (good for testing that a multi-threaded class actually does the amount of call outs you need)</li>
<li>Another implementation that given a file with key value pairs, will set the response headers using that file.</li>
</ul>
<div>We use it in the following way:</div>
<pre class="brush:java">class HttpHitTest {
     private NanoHTTPD nano;

     @Before
     public void setup() throws Exception {
          nano = new Nano(9999);
     }

     @After
     public void tearDown() throws Exception {
          nano.stop();
     }

     @Test(expected=NoSuchFileException.class)
     public void testHttpHit() {
           HttpGetClass hgc = new HttpGetClass();
           hgc.doGet("http://localhost:9999/resources/myfile.mp3");
      }
}</pre>
<p>See the beauty! NanoHTTPD simply exposes all files found in it&#8217;s working directory. So all test resources simply go into a folder inside the project and the CI server runs it without a hitch. Bonus: test performance and speeds are not affected (this thing is just so tiny).</p>
<p>As well, here&#8217;s what an extension to NanoHTTPD would look like. This example is a very simple something I whipped up to count how many times a server is hit (I needed the counter to be thread safe)</p>
<pre class="brush:java">
public class HitCountingNanoHttpd extends NanoHTTPD {
	private AtomicLong hits = new AtomicLong(0);

	public HitCountingNanoHttpd(int port) throws IOException {
		super(port);
	}

	@Override
	public Response serve(String uri, String method, Properties header, Properties parms, Properties files) {
		hits.incrementAndGet();
		return super.serve(uri, method, header, parms, files);
	}

	public long getHitCount() {
		return hits.longValue();
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/08/02/testing-http-calls-with-nanohttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-07-29</title>
		<link>http://mikemclean.ca/wp/2011/07/29/links-for-2011-07-29/</link>
		<comments>http://mikemclean.ca/wp/2011/07/29/links-for-2011-07-29/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 02:02:26 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/07/29/links-for-2011-07-29/</guid>
		<description><![CDATA[Power Mock (tags: development testing)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://code.google.com/p/powermock/">Power Mock</a></div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/Ensonik/development">development</a> <a href="http://www.delicious.com/Ensonik/testing">testing</a>)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/07/29/links-for-2011-07-29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-06-29</title>
		<link>http://mikemclean.ca/wp/2011/06/29/links-for-2011-06-29/</link>
		<comments>http://mikemclean.ca/wp/2011/06/29/links-for-2011-06-29/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 20:04:54 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/06/29/links-for-2011-06-29/</guid>
		<description><![CDATA[Google web fonts (tags: web fonts)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://www.google.com/webfonts/v2">Google web fonts</a></div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/Ensonik/web">web</a> <a href="http://www.delicious.com/Ensonik/fonts">fonts</a>)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/06/29/links-for-2011-06-29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-06-27</title>
		<link>http://mikemclean.ca/wp/2011/06/27/links-for-2011-06-27/</link>
		<comments>http://mikemclean.ca/wp/2011/06/27/links-for-2011-06-27/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 20:03:14 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/06/27/links-for-2011-06-27/</guid>
		<description><![CDATA[Infographic Of The Day: Vizualize.me Instantly Turns Your &#8230; (tags: resume)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://www.fastcodesign.com/1664134/visualizeme-instantly-turns-your-resume-into-an-infographic">Infographic Of The Day: Vizualize.me Instantly Turns Your &#8230;</a></div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/Ensonik/resume">resume</a>)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/06/27/links-for-2011-06-27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveMQ vs. PrimeTime</title>
		<link>http://mikemclean.ca/wp/2011/05/26/activemq-vs-primetime/</link>
		<comments>http://mikemclean.ca/wp/2011/05/26/activemq-vs-primetime/#comments</comments>
		<pubDate>Fri, 27 May 2011 01:58:58 +0000</pubDate>
		<dc:creator>mikem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ActiveMQ]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/?p=513</guid>
		<description><![CDATA[Well &#8230; what have we here. My assessment just might not be as out of line as some may have thought. Good to get a bit of validation. I may sound like I&#8217;m gloating (I sort of am, because honestly some of what happened in the back streets of this story was a bit disgraceful &#8230;), but I&#8217;m]]></description>
			<content:encoded><![CDATA[<p>Well &#8230; what have we <a href="http://goodstuff.im/activemq-not-ready-for-prime-time" target="_blank">here</a>.</p>
<p>My <a href="http://mikemclean.ca/wp/2010/12/07/activemq-not-what-it-used-to-be/" target="_blank">assessment</a> just might not be as out of line as some may have thought. Good to get a bit of validation. I may sound like I&#8217;m gloating (I sort of am, because honestly some of what happened in the back streets of this story was a bit disgraceful &#8230;), but I&#8217;m not; I find it really unfortunate. I am still of those that badly wants ActiveMQ to make it.</p>
<p>&nbsp;</p>
<p><em>Edit: Another follow up entry <a href="http://goodstuff.im/activemq-not-ready-for-prime-time-a-follow-up" target="_blank">here</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/05/26/activemq-vs-primetime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-05-09</title>
		<link>http://mikemclean.ca/wp/2011/05/09/links-for-2011-05-09/</link>
		<comments>http://mikemclean.ca/wp/2011/05/09/links-for-2011-05-09/#comments</comments>
		<pubDate>Mon, 09 May 2011 20:02:14 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/05/09/links-for-2011-05-09/</guid>
		<description><![CDATA[Unusual software bug &#8211; Wikipedia, the free encyclopedia Cool, but obscure unix tools :: KKovacs]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://en.wikipedia.org/wiki/Unusual_software_bug">Unusual software bug &#8211; Wikipedia, the free encyclopedia</a></div>
</li>
<li>
<div class="delicious-link"><a href="http://kkovacs.eu/cool-but-obscure-unix-tools">Cool, but obscure unix tools :: KKovacs</a></div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/05/09/links-for-2011-05-09/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-04-18</title>
		<link>http://mikemclean.ca/wp/2011/04/18/links-for-2011-04-18/</link>
		<comments>http://mikemclean.ca/wp/2011/04/18/links-for-2011-04-18/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 20:02:41 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/04/18/links-for-2011-04-18/</guid>
		<description><![CDATA[elasticsearch &#8211; - Open Source, Distributed, RESTful, Search &#8230;]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://www.elasticsearch.org/">elasticsearch &#8211; - Open Source, Distributed, RESTful, Search &#8230;</a></div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/04/18/links-for-2011-04-18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-03-09</title>
		<link>http://mikemclean.ca/wp/2011/03/09/links-for-2011-03-09/</link>
		<comments>http://mikemclean.ca/wp/2011/03/09/links-for-2011-03-09/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 20:03:16 +0000</pubDate>
		<dc:creator>Delicious</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://mikemclean.ca/wp/2011/03/09/links-for-2011-03-09/</guid>
		<description><![CDATA[Pinboard: social bookmarking for introverts A delicious replacement :)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://pinboard.in/">Pinboard: social bookmarking for introverts</a></div>
<div class="delicious-extended">A delicious replacement :)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mikemclean.ca/wp/2011/03/09/links-for-2011-03-09/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

