Most interesting links of February ’12

Recommended Readings List of open source projects at Twitter including e.g. their scala_school – Lessons in the Fundamentals of Scala and effectivescala – Twitter’s Effective Scala Guide M. Fowler & P. Sadalage: Introduction into NoSQL and Polyglot Persistence (pdf, 11 slides) – what RDBMS offer and why it sometimes isn’t enough, what the different NoSQLContinue reading “Most interesting links of February ’12”

Cool Tools: Fault Injection into Unit Tests with JBoss Byteman – Easier Testing of Error Handling

How do you test error handling in your application? Do you? Is it at all possible to simulate SocketTimeoutException, SQLException? Normally the answer would be that it isn’t possible or very difficult, requiring a complicated setup. Not anymore – with JBoss Byteman you can easily inject whatever code – e.g. throw new SocketTimeoutException() – inContinue reading “Cool Tools: Fault Injection into Unit Tests with JBoss Byteman – Easier Testing of Error Handling”

Hacking A Maven Dependency with Javassist to Fix It

Have you ever wondered what to do when needing “just a small change” to a third-part library your project depended on? This post describes how to use Maven and Javassist to take a dependency of your project, instrument it to modify its behavior, re-pack it, and release it as an artifact with a different nameContinue reading “Hacking A Maven Dependency with Javassist to Fix It”

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

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 forContinue reading “Practical Introduction into Code Injection with AspectJ, Javassist, and Java Proxy”

Introduction to ObjectTeams/Java, a Role-Based Approach to Modularity With AOP

I’ve recently stumbled upon an interesting Eclipse project called ObjectTeams/Java (OT/J), which promises improved reusability and maintenance and support for evolvable architectures by creating well-encapsulated bundles of behavior – modules – that can be applied to existing classes (via AOP), when they are in the appropriate context of interaction (and not simply always, as isContinue reading “Introduction to ObjectTeams/Java, a Role-Based Approach to Modularity With AOP”

Implementing build-time bytecode instrumentation with Javassist

If you need to modify the code in class files at the (post-)build time without adding any third-party dependencies, for example to inject cross-cutting concerns such as logging, and you don’t wan’t to deal with the low-level byte code details, Javassist is the right tool for you. I’ve already blogged about “Injecting better logging intoContinue reading “Implementing build-time bytecode instrumentation with Javassist”

Enforcing a common log format with AspectJ

Enforcing a common log format with AspectJ Andy Wilson has recently blogged about the need for uniformly formatted log messages containing all the necessary information to make log parsing easier and mentioned an extensive refactoring he did on a project to achieve this. One of the readers mentioned that he could save the effort ofContinue reading “Enforcing a common log format with AspectJ”

Compiling with AspectJ’s ajc compiler from Maven

I needed to compile AspectJ classes (.java with annotations) with ajc and I wanted to have that integrated into the Maven build process. I tried several means, finally finding the one that worked. Note: I had to use ajc even though I was using the pure java 5 syntax based on annotations instead of theContinue reading “Compiling with AspectJ’s ajc compiler from Maven”

PatternTesting: Automatically verifying the good application of architectural/design patterns in code

PatternTesting is a mature open-source project that enables you to automatically check at the compile- or run-time that architectural/design/implementation decisions are implemented and bad practices avoided in the code. The main differences from tools like FindBugs and PMD are that you can implement tests spanning multiple files (classes) and that aside of compile-time checks thereContinue reading “PatternTesting: Automatically verifying the good application of architectural/design patterns in code”

Injecting timing aspect into JUnit test in Eclipse using AspectJ, AJDT

Introduction This blog describes my experience with using AOP, namely AspectJ, to measure the individual execution times and their average of a particular low-level method invoked many times during a JUnit test run from within Eclipse. It concentrates on creating the aspect and integrating (weaving) it into the JUnit test execution in the Eclipse environment.Continue reading “Injecting timing aspect into JUnit test in Eclipse using AspectJ, AJDT”