Home » Author Archives: Alex Collins

Author Archives: Alex Collins

Thread Jiggling

Overview Thread jiggler is a simple testing framework for exercising code to find threading problems. It works by modifying classes bytecode at runtime to insert Thread.yield() calls between instructions – “jiggling” the threads. This greatly increases the likelihood of discovering threading issues, and does it without you needing to change your production code. Background I was recently researching how to ...

Read More »

Tips for Writing Maven Plugins

I’ve spent a lot of time recently writing or working on plugins for Maven recently. They’re simple, rewarding and fun to write. I thought I’d share a couple of tips for making life easier when writing them.                 Tip 1: Separate the Task from the Mojo Initially you’ll put all the code for ...

Read More »

Opinion: Performance Testing

Performance tuning an application is time consuming, and expensive. Useful tests often need dedicated hardware to run on. It’s specialised and time consuming to prepare the ground work and write the various fixtures needed to run, and whose only perceived benefit is preventing a production issue that you don’t even know will happen yet. Stereotypical Scenarios and Outcomes Here’s some ...

Read More »

An unambiguous software version scheme

When people talk about software versioning schemes they often refer to the commonly used X.Y.Z numerical scheme for versioning. This is often referred to major.minor.build, but these abstract terms are not useful as they don’t explicitly impart any meaning to each numerical component. This can lead to the simplest usage, we just increment the last number for each release, so ...

Read More »

5 Tips for Unit Testing Threaded Code

Here’s a few tips on how take make testing your code for logical correctness (as opposed to multi-threaded correctness). I find that there are essentially two stereotypical patterns with threaded code: Task orientated – many, short running, homogeneous tasks, often run within the Java 5 executor framework, Process orientated – few, long running, heterogeneous tasks, often event based (waiting on ...

Read More »

Tips for testing with Java

Introduction I love automated testing. In a rare diversion into op-ed1 I thought a put few thoughts (read – opinions) together. Before I start on how best to compose your tests, I briefly ask – What are the reasons for testing? Broadly, I think they are: Reduce total number of bugs / increase product stability Ensure software works as per ...

Read More »

Tomcat Context JUnit @Rule

A first draft of a JUnit @Rule that create the test context. This can be used with the Spring context rule for this post to create a complete Spring context for integration tests. import org.apache.commons.dbcp.BasicDataSource; import org.apache.log4j.Logger; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; import javax.xml.parsers.DocumentBuilder; import ...

Read More »

Tutorial: Hibernate, JPA & Spring MVC – Part 2


This tutorial will show you how to take a basic Hibernate/JPA app, convert it into a Spring MVC web project to be able to view the database in a web browser, and finally use Spring’s @Transactional annotation to reduce boiler plate code. This tutorial assumes you’re familiar with Java and Maven, and that you’ve completed the first part of this ...

Read More »

Tutorial: Hibernate, JPA – Part 1

This is the first part of tutorial about using Hibernate and JPA. This part is an introduction to to JPA and Hibernate. The second part will look at putting together a Spring MVC application using Spring ORM to reduce the amount of code necessary to create a CRUD application.  To complete this you’ll want to be familiar with Maven, JUnit, ...

Read More »

Integration Testing with Selenium

Overview I’ve been using this for sometime and I’ve come across a few things that appear to make life easier. I thought I’d share this as a tutorial, so I’ll walk you through these parts: Setting up a web project using Maven, configuring Selenium to run as an integration test on a C.I. Look into good ways to model the ...

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