Tuesday, February 5, 2013

Verifying void methods with Mockito

I had the following problem with Mockito


class MyClass{
 void logSupportingServiceWarn(File dummyFile, String aString){
 }
}

MyClass task = Mockito.spy(new MyClass())
Mockito.never(task.logSupportingServiceWarn(dummyFile, null));

> Java gives the following error :
'void' type not allowed here

Well, this is an issue with Java because it does not allow you to pass in void as a parameter.
Actually it's documented on the website, but I could still not find the exact syntax.

Instead do this :


Mockito.verify(task, Mockito.never()).logSupportingServiceWarn(dummyFile, null);



Monday, February 4, 2013

Java and your security

Over the past few months Java has had some really bad press about security. The good news is you need to have Java running on your machine for most of the security vulnerabilities to be exploited. Applications on servers should not be effected.

Windows, Linux and Mac with Java installed are effected.

It is very important for you and your customers that have Java installed on their machine to have the latest version of Java installed as it contains a lot of patches.

If your customer / you is still running Java 6 please updated to at least Java 6 update 39.
And Java 7 at least update 13.


You can check the version of Java installed here :
http://www.java.com/en/download/installed.jsp

Monday, January 14, 2013

Invient Charts, Problem with TimeZone - always in UTC

The Problem


It seemed that all my InvientChart 0.8.6 charts in Vaadin were two hours behind where they should have been. And because I live in GMT + 2 it seemed like a timezone issue.

The solution


Before adding your chart to the UI add this component


            try {
                CustomLayout cl = new CustomLayout(new ByteArrayInputStream("
".getBytes())); addComponent(cl); } catch (IOException ex) { //should never happen log.warn("Should never happen",ex); }

Tuesday, January 8, 2013

Manage my time more effectively - Email and chats are the devil

Being used to being unfocused

I am lucky enough to work in a private office where I can closed the door and not be disturbed. But work email, Google chats and private Google mail really becomes a distraction. 
To make it worse, when I am not being distracted by mail and chat I check to see if I have new mail or chats periodically.
This really disrupts my train of thought.

The desired end result

While developing software focus is key!
No disruptions during pomodoros!

What I am going to do
Close my work email and gmail during 25 min pomodoros

Monday, January 7, 2013

2013 New Years Resolutions as a Java developer

I am going to focus on the following this year and blog about it.

Test driven development for everything I do

 

Doing things in a panic and rush comes back and bites.
Completely offline and modular test are a must.

Deploy one application to the Android Market

 

Deploy one application to the IOS Market

 

Become a GWT master

GWT is really one of the best frameworks I have seen in a long time. I've been dabbling for a long time, but I really want to be a master. That includes MVP 

Never lie on my timesheets

At one of the Java User groups at a new venue, one of my friends joked. "Look at that guy coming, you can see he is a Java developer, his eyes are red."
Long hours and stress is part of being a Java developer and I log 8 hours on my timesheet per day even though I spend much more.
People need to see how long I work.

Manage my time more effectively

Refine how I work. The Pomodoro Technique is a great starting point to working smart and working towards a end goal. But there needs to be more.

Do my Oracle Certified Java 8 Programmer course

Java 8 should be released close to the end of the year. If this is so, I would like to do a beta of the exam. If this is possible in South Africa.

Get involved a little with Java EE 7

 

Adopt a JSR

http://java.net/projects/adoptajsr/pages/Home