How To Export Google Reader Feeds Into Opera![]() By Roger Keays, 19 March 2013, 5:07 PM Everyone is up in a storm since Google announced they were killing Google Reader. Although I liked Google Reader, I believe change creates opportunities and unsurprisingly a better solution for feed reading presented itself almost immediately. In fact it was already installed on my system. It's called Opera. I installed Opera to read email when Mozilla killed Thunderbird and after some heavy customisation I'd say it works pretty well. It's much faster than Thunderbird for a start. Now it looks like Opera is not only going to save my RSS feeds, but make my news reading more organised thanks to it's flexible user interface. So here is a quick howto with screenshots for people who need to get off Google Reader and want to try out Opera. |
Preserving JSF Request Parameters and REST URLsBy Roger Keays, 13 February 2013, 1:23 PM Have you ever used a URL pattern something like this?
or perhaps this?
Well, as a JSF developer you've probably already realized a little problem. How do you remember the id from request to request? There are a few simple solutions. |
How To Get The HTTP Status Code In Selenium WebDriver![]() By Roger Keays, 16 November 2012, 2:55 PM One of the first things you'll notice when you start testing your web application with Selenium WebDriver is that there is no API to get the HTTP status code for a page. If you want to know why, you can go and read WebDriver issue #141. Personally I don't care why - I just want to test my HTTP reponse codes (especially 403 Permission Denied). There is a fairly simple workaround you can use for WebDriver, but firstly lets look at how to do it without WebDriver. Nobody said you HAVE to use Selenium right? |
JSF Error Pages That Actually Work![]() By Roger Keays, 27 October 2012, 12:27 PM Here is an annoying problem using JSF error pages for JSF requests. Everything looks just fine, HttpServletResponse.sendError() sends the error page, but JSF continues processing and starts throwing exceptions after the response is complete. This happens even if you call FacesContext.responseComplete(), and also when the error page is sent at different stages of the JSF lifecycle. It seems like invoking the FacesServlet for sendError() breaks the state of the original FacesContext. When sending an error during view build I get this exception: |
Why Is Maven So Slow? [Solved]![]() By Roger Keays, 24 October 2012, 10:46 AM I couldn't figure out why the heck my maven builds where taking so long. I thought Java was supposed to be fast these days and here I am waiting 30 seconds to run a unit test. So I did some digging and eventually found the problem. On Linux, the default JVM is the Server JVM which does all sorts of useful optimisations for long running server process but is absolutely dog slow for building source code (this could also be a reason why the Linux community thinks Java sucks so much). To find out what JVM you are running simply type: $ java -version java version "1.6.0_26" If you see "Server VM" like the example above do me a favor and time your maven compile (mvn clean compile) then switch to the Client VM, time it again and post your results in the comments below. |
How To Sort Your Unit Tests By Layer In TestNG![]() By Roger Keays, 11 October 2012, 11:31 AM Each of my unit tests extends from a different base class depending on what layer of my application they are testing. i.e.
BaseTest
`- BaseDBTest
`- BaseOpsTest
`- BaseUITest
These superclasses are very convenient places to put shared test code like starting a server, opening the database, doing a HTTP get or even just checking that assert is enabled. When testing the whole application, it doesn't make much sense to me to run tests from all layers in random order. There are clear dependencies between the layers and if a lower layer fails I want to know about it before it blows up into the upper layers (if you believe its better to mock unit test dependencies then you might as well stop reading now). |
How To Create Email From JSF TemplatesBy Roger Keays, 1 October 2012, 8:29 PM Hi everybody. In this blog I'm going to share a little trick for creating emails using JSF Facelets templates. The concept is actually independent of JSF and could be used for any servlet-based technology. Right, so the basic idea is to temporarily trick the ServletResponse object into writing all the content to an in-memory buffer, rather than streaming it to the client's browser. We then manually invoke the JSF render phase for the particular view using the special ServletResponse and voila!, the captured output can be put into an email. Let's have a look at some of the code. |
How To Install Ruby On Rails On Ubuntu Hardy 8.04![]() By Roger Keays, 20 September 2012, 4:11 AM Okay, Ubuntu Hardy is pretty old now but my Hardy server is still humming along just fine and I don't see a good reason to break it just to run a few Ruby On Rails apps. The ruby, ruby1.9 and rubygems packages on Hardy simply don't work anymore and the rails package is too old to run my app. So here is how I got the latest rails running on this 4 year old server. I hope it saves you some pain. 1. Install JRuby 1.6.8. The Ubuntu ruby1.9 package just hangs silently when trying to install rubygems, but JRuby does the job.
# cd /opt
2. Install Rubygems 1.8.24
# wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.zip
|
How To Unit Test Private Methods![]() By Roger Keays, 19 September 2012, 8:02 AM I've discovered that one reason I don't write as many unit tests as I should is because they live in a separate source tree, out of sight and out of mind. So I've moved my unit tests to be inner classes on the classes they test. A side effect of this is you can easily test the private methods of a class since the inner class has direct access to these methods. Here is the configuration you will need to do this. Note, I am using TestNG, but it should be pretty similar in JUnit. |
How To Change Maven's Default Resource FolderBy Roger Keays, 31 August 2012, 5:46 AM Sometimes it's nice to have your projects resource files alongside the java source files they're related to. By default, Maven forces you to have a separate resource tree so, for example, whenever you need to a add a String for internationalization you have to go digging through your project's folders. The good news is, you can change change maven's default resource folder this with this little bit of XML magic in Maven pom.xml. <build> Note this overrides the default location, so make sure src/main/resources is empty, or add to the pom.xml like this. <build> Don't forget to exclude the java files unless you want to ship your source code! |
The Ultimate VIM TODO List![]() By Roger Keays, 9 August 2012, 2:18 PM With a TODO list of over 500 items I clearly need advanced software to manage my tasks. And finally I have found just the tool for the job... VIM After trying web based project trackers, spreadsheets, desktop project management apps, calendar based, email-based, smartphone apps and everything else I could think of, it looks like I'll be sticking with my plain text todo file with a couple of handy VIM scripts. Here's how it works. |
Nested Anonymous ui:insert Ignored in ui:define (Facelets)5 August 2012, 5:57 PM Euch. What a mess. I've hit this bug a few times and have never found the exact cause. So I'm dumping my notes and test case here for next time. Here are 4 nested templates that should output the following when viewing the deepest template: View 1 View 2 View 3 View 4 view_1.xhtml
|