Home » Author Archives: Shaun Abram

Author Archives: Shaun Abram

Test Doubles: mocks, dummies and stubs

Most classes have collaborators. When unit testing, you usually want to avoid using real implementations of those collaborators to avoid test brittleness and binding/coupling, and instead use Test Doubles: Mocks, Stubs and Doubles. This article references two existing articles on the subject: Mocks Aren’t Stubs, by Martin Fowler and The Little Mocker, by “Uncle” Bob Martin. I recommend them both. Terminology I am going to ...

Read More »

An introduction to REST

REST, or Representational State Transfer is an architectural style, or more simply, a set of constraints. We will look at the constraints REST imposes for web apps, but some highlights are:               Uniform interfaces: all resources are identified by URIs (think: links) It relies on a stateless, client-server, cacheable communications protocol (think: HTTP). Interaction with resources is ...

Read More »

AssertJ > Fest > Hamcrest

I have previously blogged about Hamcrest, and using its assertThat methods in preference to JUnit’s Assert. However, I quickly after discovered FEST Assertions, and happily switched to it. It provides the same improved test readability and improves failure messages as Hamcrest, but has the extra benefit of enabling IDE auto completion, rather than having to search through package and class docs to find the right matcher. Unfortunately, Fest seems to ...

Read More »


A microservice is a small, focussed piece of software that can be developed, deployed and upgraded independently. Commonly, it exposes it functionality via a synchronous protocol such as HTTP/REST. That is my understanding of microservices, at least. There is no hard definition of what they are, but they currently seem to be the cool kid on the block, attracting increasing attention ...

Read More »

Keyboard shortcuts in IntelliJ

I attended a talk by Hadi Hariri at JavaOne last week. He introduced a whole bunch of IntelliJ keyboard shortcuts I was not aware of. Very useful talk. I have listed some of the most useful ones below. Cmd-1: Move focus to the Project window While there, type any class name (including using Camel Case e.g. HW to find HelloWorld), ...

Read More »

Live Templates in IntelliJ

As described here, IntelliJ’s live templates let you easily insert predefined code fragments into your source code. I have posted some of my most used templates below, a link to my complete list of template files on GitHub (as a reference for myself when I setup new IntelliJ environments) and the steps I took to add the IntelliJ settings file ...

Read More »

How to add an IntelliJ project to GitHub

Although the GitHub docs contains good info on how to add an existing GitHub project to your local machine, how to add an existing (unversioned) project from your local machine to GitHub was a little less clear to me. Here are the steps I use. From IntelliJ Select ‘VCS’ menu -> Import in Version Control -> Share project on GitHub. ...

Read More »

Testing for expected exceptions in JUnit

Unit tests are used to verify that a piece of code operates as the developer expects it to. Sometimes, that means checking that the code throws expected exceptions too. JUnit is the standard for unit testing in Java and provides several mechanisms for verifying exceptions were thrown. This article explores the options and their relative merits.   Take the following ...

Read More »

Java7 – A look back

I started writing a blog post on what’s new in the upcoming Java8 release, and thought I would start by doing a quick look back at what Java7 brought to us. Java7 was released back in July 2011, and was described as “more evolutionary than revolutionary”. “There are some significant improvements, but no really earth-shattering or ground-breaking kinds of features.” ...

Read More »


Java8 isn’t scheduled for for release until March 2014, but early release versions have been available for a while. Some of the most interesting new features are: Streams Functional interfaces Default methods Lambdas Java Time     Streams The new java.util.stream package contains “classes to support functional-style operations on streams of elements”. Streams aren’t a new type of collection and ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns