Wednesday, 24 November 2010

eclipse, junit & static imports

It was annoying me that eclipse was not finding the static imports needed by junit 4 unit tests.

A quick google tuned up this gem, which I have grabbed below:

Open the Preferences via Window -> Preferences and select Java > Editor > Content Assist > Favorites. Add then via "New Member" the methods you need. For example this makes the assertTrue, assertFalse and assertEquals method available.

You can now use Content Assist (Ctrl+Space) to add the method and the import.

He suggests to add at least the following new members.

  • org.junit.Assert.assertTrue

  • org.junit.Assert.assertFalse

  • org.junit.Assert.assertEquals

  • org.junit.Assert.fail

I suggest also adding

  • org.junit.Assert.assertNotNull

Friday, 19 November 2010

pidgin - Unable to validate certificate error

If you are having the 'Unable to validate certificate' error from pidgin then do the following:

  1. go to here, download the certificate omega.contacts.msn.com.pem
  2. in pidgin go to tools/certificates
  3. delete the cert omega.contacts.msn.com.pem
  4. add the new downloaded cert
  5. and away you go
UPDATE - or as I have said in the comment, now you can download the new version with a fix - see or better still update to the latest version that now has the fix - http://www.pidgin.im/

Thursday, 21 October 2010

SQLdeveloper & showing the full date

I keep getting this every time I install SQLDeveloper.

The date shown is just dd/mm/yyyy with no hours:minutes:seconds

The solution can be found here on Zenx's blog, but to save me looking here it is also.

1. From SQL Developer, open menu Tools >> Preferences.
2. From the Preferences dialog, select Database >> NLS Parameters from the left panel.
3. From the list of NLS parameters, enter DD-MON-RR HH24:MI:SS into the Date Format field.
4. Save and close the dialog, done!

Thanks Zenx.

Also, if you want milli-seconds add ':SSSSS' at the end.

Wednesday, 20 October 2010

git & github from windows

While learning Grails and working though 'Grails in Action' I wanted to save my work to a repository. SVN can be a pain to setup on windows and many people use github & so I thought I would give it a go.

Sadly I am on a windows PC but I have just been so pleasantly surprised as to how easy it was.

This is what I had to do:
  1. I work from a cygwin command shell. In this I had to have ssh & git executables installed.
  2. help to set up the ssh key is here .
  3. I did not realise that git acts as a local repository as well as a public repository so you are under no obligation to upload your work. The local set up is a breeze and is described in this excellent tutorial, running the commands from my cygwin shell.
  4. There is even a GUI with the command 'gitk'
  5. create the repository on the remote server such as the public github repository
  6. Once you want to upload the code to a public github repository it is a simple case of running the following commands:
  7. cd existing_git_repo
    git remote add origin git@github.com:bill-comer/hubbub.git
    git push origin master
  8. And you can download code from github using the following:
  9. git clone   git@github.com:bill-comer/hubbub.git
  10. As I am on a windows PC I had to tweak the SSH2 key location. In eclipse go to Preferences/Network Conections/SSH2. Here I set the SSH2 home to where my cygwin .ssh directory is. In my case C:\cygwin\home\comerb\.ssh.


Now go ahead and enjoy a free and easy to use code repository.

Thursday, 30 September 2010

Grails & 'Grails in Action' - some notes & comments

I have just started playing with grails.
I am using 'Grails in Action' as my reference.
My current version of grails is 1.3.4
I am using the STS eclipse IDE with their built in grails plugin

Here are some initial notes on GOTCHAs I have found with the book and grails itself.
NB I will continue to update this one page with other gotchas, instaed of creating many pages.

Comments on 'Grails in Action'

1) p28, list 1.22
'render' should be 'response.outputStream <<'

2) logo.png & snazzy.css are needed for chapt 1 & can be got from github



Comments on Grails 1.3.4

1) can not create integration tests - getting error
Error executing script CreateIntegrationTest: No such property: type for class: CreateIntegrationTest
No such property: type for class: CreateIntegrationTest

edit the file scripts/CreateIntegrationTest.groovy in your grails installation
and add the line
def type = "Tests"
after the line
depends(checkVersion, parseArguments)

NB this is fixed in 1.3.5

2) when running the test via 'grails test-app' the url for the report is incorrect
and is missing the trailing 's' from the URL

edit the file scripts/_GrailsTest.groovy line 402 and add a space after the the closing brace of testReportsDir and before the double quote
msg += " - view reports in ${testReportsDir} "



3) 1.3.5 bug - add a contraint that specifies the size of the field then it does not check for null.
IE This will allow a nulll value in name:
static constraints = {
name (size:3..8)
}

The work around is to do this:


static constraints = {
name (size:3..8, blank:false)
}

bug GRAILS-6821 has been raised on version 1.3.5

Tuesday, 21 September 2010

keepass and dropbox combined.

A while ago I blogged about using keepass as a secure password & data storage tool.
The blog entry is here.

The issue I have always had is keeping the keepass db in sync between my different PCs at work & at home and on the move. I used to use a memory stick but decided that was prone to getting lost or damaged.

I have recently started using dropbox. This tool provides online storage allowing sync between any number of devices and supports linux, i-phones, android, iPad as well as Microsoft platforms. It is free for the first 2GB and you get to earn additional storage by either nominating others or getting nominated by an existing member.

From the reviews I have read it appears secure so I have started using it for my keepass database as well as any every day stuff I want to share.

As for reviewing keepass I am still very pleased and impressed with it.
My family now all have their own keepass databases to keep their personal data.

So if you want to try dropbox, follow this referral link and try it out.


Thursday, 16 September 2010

tomcat IE and parse locale Exceptions

I have just done an upgrade for a customer that involved new java, tomcat as well as a new version of our application software.


The webapp was failing with the following Exception:


Caused by: javax.servlet.jsp.JspException: In &lt;parseNumber&gt;, a parse locale can not be established
at org.apache.taglibs.standard.tag.common.fmt.ParseNumberSupport.doEndTag(ParseNumberSupport.java:134)
at org.apache.jsp.tag.web.shared.paging_tag._jspx_meth_fmt_005fparseNumber_005f0(paging_tag.java:598)
at org.apache.jsp.tag.web.shared.paging_tag.doTag(paging_tag.java:241)
at org.apache.jsp.pages.jsp.type3Footer_jsp._jspx_meth_tag_005fpaging_005f0(type3Footer_jsp.java:220)
at org.apache.jsp.pages.jsp.type3Footer_jsp._jspService(type3Footer_jsp.java:114)
... 73 more


Some googling pointed me to adding locale java options:
This just shifted the problem to Oracle Exceptions complaining about NLS_LANG and suggesting
After all the application worked fine before.

So what was my final solution.

Very simple. In IE go to Tools->Internet Options->General/Languages.
  • found out there were no languages set
  • Add the appropriate one
  • English (United Kingdom) [en-gb] in my case.