The Golden Ratio

Also known as the “Divine Quotient”, the Golden Ratio was given an almost magical meaning during the renaissance, but it’s actually much older than that. Leonardo DaVinci used it. Euclid used it. It was supposedly discovered by Pythagoras. So, what is it? It’s very simple. Take a length and divide it into two parts: a [...]

Tags: , , , ,

The Power of Unit Testing

The purpose of Unit Testing is to verify for the developer that a software unit does what it is supposed to and is fit for use. The confidence that the developer gets, gives the developer courage to do other useful practices like Refactoring.
Unit testing is often used to test complex units with one or [...]

Tags: ,

Upgrading Groovy to 1.6.2 Fails on Mac

When I tried to upgrade Groovy from 1.6.1 to 1.6.2 using MacPorts, it failed with an OutOfMemoryError. I managed to get it to build using some manual fixing in the build file. I’ll explain what I did in this blog.
This was the result that I got:

$ sudo port upgrade groovy
—> Building groovy

Command output: [...]

Tags: , , , , ,

Always Use Parenthesis in Groovy Builders

I recently ran into an interesting Groovy feature when demonstrating the strengths of the MarkupBuilder. As you probably know, parenthesis in a Groovy method call are optional, unless it’s a no-args call. In that case the parenthesis are needed in order to distinguish the call from a property. However, leaving out parenthesis in a Builder is asking for trouble. I’ll show you why.

Tags: , , , , ,

Getting Coverage For Integration Tests

Unit testing in my world is basically defined by being able to run the tests wherever and whenever; on the train, on the plane, at work, or at home. If you also have integration tests, chances are that they require some external data source or something that simply makes it impossible to run them everywhere. [...]

Tags:

Encrypting Properties With Jasypt

Properties are used in many Java applications as a simple way of separating parts that are likely to change, from the parts that are not that likely to change. Consider for example this typical bean definition in a Spring configuration file:
 
<bean id="traditionalPersonDao"
class="org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl">
<property name="url" value="ldap://localhost:3901" />
<property name="base" value="dc=jayway,dc=se" />
<property name="userDn" [...]

Tags: , , ,

Squid, the caching proxy

I just checked out the old Squid again, the worlds most famous caching proxy. If you direct all your web access through the Squid proxy server, it will cache stuff after the first access. This would simplify for example for labs where fifty people simultaneously begin retrieving stuff from a Maven repo somewhere or downloading [...]

Tags: , , , , ,

Using Amazon S3 for backup

Amazon Simple Storage Service (S3) is cheap on-line storage with a Web Service interface. You just log in with your Amazon id, sign up for S3, designate a credit card, and that’s it. You now have access to pretty much unlimited storage space, managed by Amazon. The price is $0.15 per GB-Month of storage used [...]

Tags: , , , , , , ,

Mocking Classes

Mocking a class rather than an interface might present some interesting obstacles. Perhaps you have ran into the dreaded:
Unexpected method call toString():
toString(): expected: 0, actual: 1
You think nothing of it and happily add an expectation for toString. Then you get:
Unexpected method call toString():
toString(): expected: 1, actual: 2
The reason is that EasyMock [...]

Tags: ,

Sweden Spring UG Birth of a new UG

Once in a while we see a new user group being born. One of those is close to many Java programmers’ hearts – the Sweden Spring User Group.
We turned to Ulrik Sandberg, one of the founders of the group.
Tell us how you got started with the Sweden Spring User Group.
The Sweden Spring User Group was [...]

Tags: ,

Sharing a Mac Internet Connection Through Airport

I just solved a networking problem on my Macs after hours of trying. For the benefit of others, I’ll describe here the problem and the solution.
Setup
Cable modem from ISP, network cable to a firewall, the private end of the firewall via network cable on to a switch. Pretty basic, I guess. No wireless base stations [...]

Tags: , , , ,

Solving 403 problems with Sourceforge Subversion

After having had severe problems when committing to the Sourceforge Subversion repos, I stumbled upon what appears to be the solution. The problem was that in the middle of a commit, one file or directory would fail with a 403 (permission denied). In desperation, I would chop up the change set and commit little pieces [...]

Tags: , , , , ,