Johan Haleby

Johan Haleby is a Swedish developer, speaker, and writer with a profound interest in software engineering and testability in particular. He has founded and contributed to numerous open source projects such as PowerMock, REST Assured and Awaitility and has spoken at several conferences and user groups such as Öredev and Devoxx.

Finding country name from geolocation

Java Unit Testing Niceness

With this blog I just want to share some tips on how to use two interesting test frameworks that are not very well known, Komarro and Catch Exception. Class Under Test The following class is a (modified) example of an anti-corruption layer used in a project I’m working on. It uses an instance of MappingRepository that is a part of another bounded context to obfuscate EntityId’s (which in the real project is called something else). Happy Flow Test So let’s…

Confess 2013 Conference Report

The four of us recently visited the Confess, CONference For Enterprise Software Solutions, in Vienna. It was located at the Messe Wien Exhibition & Congress Center which was a nice place for the conference. Here’s a summary of some of the sessions during the conference. Couchbase – Michael Nitschinger Michael gave an overview of Couchbase and in particular the new features of the 2.0 version. Couchbase combines the features of an in-memory data grid and a document database with secondary…

Solving asm conflicts after upgrading to Groovy 2.1

What’s new in REST Assured 1.8?

Serializing groovy.util.slurpersupport.Node to XML

Upgrading Jersey with Spring, JAXB and Jackson 1.x to Jackson 2.x

Scandinavian Developer Conference report

Beyond Mocking with PowerMock

What you may not know about HTTP redirects

Finding the pid listening on a specific port on Mac OS X

Configuring Jasmine to work with Maven and JQuery Fixtures

Configure Morphia to work without a default constructor

Komarro – A new interesting mock framework for Java

Mocking is a well-known and estabilished concept in our field of work as developers. There are a lot of frameworks for creating and setting up expectations on mock objects in all kinds of different languages. For me as a Java developer my introduction with mocking was through the EasyMock project. Due to the techincal limitations of this and other frameworks at the time me and a colleague founded PowerMock to make it possible to mock things such as new instance…

How to really fix the too many open files problem for Tomcat in Ubuntu

Simple Parsing of Complex JSON and XML Documents in Java

Multipart Form Data File Uploading Made Simple with REST Assured

Is your REST assured?

A couple of months ago I introduced a new open source Java framework for simple automated testing of REST/HTTP services called REST Assured. A lot of things have happended to the framework since then and it’s now better than ever. In this blog I’m going to summarize some of the most important new features that have been added since the last blog post. Easy parsing of the response body JSON Let’s assume that a REST service at localhost:8080/json returns: As…

PowerMock for Integration Testing

A while ago I blogged about how to use the PowerMock Rule to bootstrap PowerMock without using a JUnit runner. A problem that you’ll likely run into sooner or later when using this approach in an integration test is the need to ignore certain classes or packages from being loaded by the PowerMock classloader using the @PowerMockIgnore annotation. This is actually not limited to the Rule but happens when using the standard JUnit runner as well but it’s much more…

PowerMock with unsupported frameworks such as JMock

Currently PowerMock builds on top of EasyMock and Mockito to provide mocking of e.g. static methods and final classes using a familiar API. What most people don’t know is that it’s pretty easy to benefit from PowerMock even for frameworks it doesn’t support. JMock is another popular mocking framework that PowerMock currently doesn’t support but this article will demonstrate some examples of JMock and PowerMock. Mocking final classes Unlike EasyMock and Mockito, JMock doesn’t support mocking classes out of the…

Using PowerMock with Spring integration testing

REST Assured – Or how to easily test REST services in Java