The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘JavaZone’

(Unit) Testing Swiss Knife: All the Tools You Wanted to Know

Posted by Jakub Holý on September 9, 2012

I love testing. And I like productivity. There are many tools and libraries that make writing tests easier, more convenient, more fun. I would like to introduce here those that I found the most useful during the years, from selected advanced features of JUnit to assertion libraries, powerful behavior/fault injection, testing of database-related code, and finally to boosting your testing productivity hundredfold with Groovy.

This post accompanies my JavaZone 2012 lightning talk and goes more in depth and introduces additional tools and tips.

Read the rest of this entry »

Posted in Languages, Testing, Tools | Tagged: , , | 5 Comments »

Practical Introduction into Code Injection with AspectJ, Javassist, and Java Proxy

Posted by Jakub Holý on September 7, 2011

The ability to inject pieces of code into compiled classes and methods, either statically or at runtime, may be of immense help. This applies especially to troubleshooting problems in third-party libraries without source codes or in an environment where it isn’t possible to use a debugger or a profiler. Code injection is also useful for dealing with concerns that cut across the whole application, such as performance monitoring. Using code injection in this way became popular under the name Aspect-Oriented Programming (AOP). Code injection isn’t something used only rarely as you might think, quite the contrary; every programmer will come into a situation where this ability could prevent a lot of pain and frustration.

This post is aimed at giving you the knowledge that you may (or I should rather say “will”) need and at persuading you that learning basics of code injection is really worth the little of your time that it takes. I’ll present three different real-world cases where code injection came to my rescue, solving each one with a different tool, fitting best the constraints at hand.

Read the rest of this entry »

Posted in Languages, Tools | Tagged: , , , , | 9 Comments »