<![CDATA[Ninth Avenue]]> http://www.NinthAvenue.com.au/ Ninth Avenue http://www.NinthAvenue.com.au/ http://www.ninthavenue.com.au/ox/webcore/attachments/22658/ninthavenue.png?width=200&height=200 http://www.rssboard.org/rss-specification <![CDATA[How To Export Google Reader Feeds Into Opera]]> How To Export Google Reader Feeds Into Opera

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.

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-export-google-reader-feeds-into-opera http://www.NinthAvenue.com.au/how-to-export-google-reader-feeds-into-opera Tue, 19 Mar 2013 18:07:57 +1100
<![CDATA[Preserving JSF Request Parameters and REST URLs]]> Preserving JSF Request Parameters and REST URLs

Have you ever used a URL pattern something like this?

http://localhost/app/widgets/WidgetEditor.xhtml?id=300 

or perhaps this?

http://localhost/app/widgets/300/edit 

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.

Read more...

]]>
http://www.NinthAvenue.com.au/preserving-jsf-request-parameters-and-rest-urls http://www.NinthAvenue.com.au/preserving-jsf-request-parameters-and-rest-urls Wed, 13 Feb 2013 14:23:46 +1100
<![CDATA[How To Get The HTTP Status Code In Selenium WebDriver]]> How To Get The HTTP Status Code In Selenium WebDriver

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?

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-get-the-http-status-code-in-selenium-webdriver http://www.NinthAvenue.com.au/how-to-get-the-http-status-code-in-selenium-webdriver Fri, 16 Nov 2012 08:43:31 +1100
<![CDATA[JSF Error Pages That Actually Work]]> JSF Error Pages That Actually Work

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:

Read more...

]]>
http://www.NinthAvenue.com.au/jsf-error-pages-that-actually-work http://www.NinthAvenue.com.au/jsf-error-pages-that-actually-work Sat, 27 Oct 2012 13:14:40 +1100
<![CDATA[Why Is Maven So Slow? [Solved]]]> Why Is Maven So Slow? [Solved]

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"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

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.

Read more...

]]>
http://www.NinthAvenue.com.au/why-is-maven-so-slow http://www.NinthAvenue.com.au/why-is-maven-so-slow Wed, 24 Oct 2012 11:46:05 +1100
<![CDATA[How To Sort Your Unit Tests By Layer In TestNG]]> How To Sort Your Unit Tests By Layer In TestNG

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).

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-sort-your-unit-tests-by-layer-in-testng http://www.NinthAvenue.com.au/how-to-sort-your-unit-tests-by-layer-in-testng Thu, 11 Oct 2012 11:03:11 +1100
<![CDATA[How To Create Email From JSF Templates]]> How To Create Email From JSF Templates

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.

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-create-email-from-jsf-templates http://www.NinthAvenue.com.au/how-to-create-email-from-jsf-templates Sat, 11 Oct 2008 21:29:47 +1100
<![CDATA[How To Install Ruby On Rails On Ubuntu Hardy 8.04]]> How To Install Ruby On Rails On Ubuntu Hardy 8.04

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
# wget http://jruby.org.s3.amazonaws.com/downloads/1.6.8/jruby-bin-1.6.8.tar.gz
# tar -zxf jruby-bin-1.6.8.tar.gz
# export PATH=$PATH:/opt/jruby-1.6.8/bin

2. Install Rubygems 1.8.24

    # wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.zip
# unzip rubygems-1.8.24.zip
# cd /opt/rubygems-1.8.24
# jruby setup.rb

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-install-ruby-on-rails-on-ubuntu-hardy-8-04 http://www.NinthAvenue.com.au/how-to-install-ruby-on-rails-on-ubuntu-hardy-8-04 Thu, 20 Sep 2012 04:11:58 +1000
<![CDATA[How To Unit Test Private Methods]]> How To Unit Test Private Methods

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.

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-unit-test-private-methods http://www.NinthAvenue.com.au/how-to-unit-test-private-methods Wed, 19 Sep 2012 08:02:43 +1000
<![CDATA[How To Change Maven's Default Resource Folder]]> How To Change Maven's Default Resource Folder

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>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes><exclude>**/*.java</exclude></excludes>
</resource>
</resources>
</build>

Note this overrides the default location, so make sure src/main/resources is empty, or add to the pom.xml like this.

  <build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes><exclude>**/*.java</exclude></excludes>
</resource> <resource> <directory>src/main/resources</directory> </resource>
</resources>
</build>

Don't forget to exclude the java files unless you want to ship your source code!

Read more...

]]>
http://www.NinthAvenue.com.au/how-to-change-mavens-default-resource-folder http://www.NinthAvenue.com.au/how-to-change-mavens-default-resource-folder Fri, 31 Aug 2012 05:46:44 +1000
<![CDATA[The Ultimate VIM TODO List]]> The Ultimate VIM TODO List

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.

Read more...

]]>
http://www.NinthAvenue.com.au/the-ultimate-vim-todo-list http://www.NinthAvenue.com.au/the-ultimate-vim-todo-list Thu, 9 Aug 2012 14:18:53 +1000
<![CDATA[Nested Anonymous ui:insert Ignored in ui:define (Facelets)]]> Nested Anonymous ui:insert Ignored in ui:define (Facelets)

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

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">

<body>
<h1>View 1</h1>
<ui:insert name="v1"/>
</body>
</html>

Read more...

]]>
http://www.NinthAvenue.com.au/nested-anonymous-ui-insert-ignored-in-ui-define-facelets http://www.NinthAvenue.com.au/nested-anonymous-ui-insert-ignored-in-ui-define-facelets Sun, 5 Aug 2012 17:57:51 +1000