Woozle Wuzzle
Simplify Testing using Fault Injection

Presentation Slides

Example Source

Below are instructions on using the examples in Eclipse and AspectJ. (Please note that the examples are specific to AspectJ but neither AspectJ nor the examples are specific to Eclipse.)

  • Download, install and run Eclipse 3.2.1
  • Download and install AJDT (which includes AspectJ) through the download manager (Help -> Software Updates -> Find and Install -> Search for new updates to install. Add a "New Remote Site" with the URL http://download.eclipse.org/tools/ajdt/32/dev/update). Please note that the examples require the lastest development build due to a bug in AJDT.
  • Download and unzip the examples into a convenient location (you can use the workspace directory for example).
  • Within Eclipse, import (right click on the Package Explorer and select Import -> General -> Existing Projects into Workspace) the three example projects ("Example", "fault.injection" and "javassist"). (If you select the directory where you unzipped the files then the three projects should appear in the dialog.) (It may take a moment or two to set up and build everything. There should be no errors (though there will be warnings).)
  • You can run the example with out any faults (right click on "Main.java" in the "Example" project in the Project Explorer and select "Run as" -> "Java Application").
  • To run the examples with different faults requires a bit of setup:
    • Select "Run..." from the toolbar (it's a drop down from the green play-like button).
    • In the dialog click on "AspectJ / Java Application" in the left navigation and right click "New".
    • Under "Project" set it to fault.injection and under "Main class" set it to com.example.Main
    • Switch to the "Arguments" tab (still in the Run dialog) and add to the "VM arguments": "-javaagent:lib/aspectjweaver.jar" (without the quotes). (This is the JVMTI agent that will load-time weave the aspects.)
    • Click "Run". At this point the console should show the same information that you saw when you ran "Main.java" directly. This is because the META-INF/aop.xml doesn't have any aspects configured.
    • Open the META-INF/aop.xml which is located in the "fault.injection" project under "classes". (Because Eclipse tries to mask some complexity from you it's difficult to get at the "classes" directory in the IDE unless you set up some filters correctly. For simplicity, just open the file in some text editor via the filesystem.)
    • Uncomment the example fault that you are interested in (i.e. remove one set of "!--" and "--" from the aspects section of the file) and save the file. When you re-run the application in Eclipse the load-time weaver will weave in the aspect that you uncommented. (If something doesn't work as expected then check the top of the console output. The weaver may have some information for you.) Please note that in one case there are two aspects ("Read2" and "Read2Helper") as part of one example.

As I mentioned in the presentation, to apply techniques similar to this in your own environment, I would recommend using Ant to generate an appropriate META-INF/aop.xml and then run JUnit in a loop to run through different faults.

I tried to structure the projects to decouple them as much as possible. For example, the "fault.injection" project doesn't directly depend on the "Example" project. (It only depends on the output classes.) I could have gone a step further and generated a JAR out of the "Example" project and used that in the "fault.injection" one. The goal to all of this was to ensure / prove that load-time weaving was being done.

Please don't hesitate to contact me if you have questions or problems.

It finally happened...
"Let's coalesce those ideas into something actionable"
Robert L. Grzywinski, 2006

The worst has finally happened ... I uttered that phrase without thought. It felt as though it eminated from my very being. We're through the looking glass and we're on the other side. Things are very strange here. May the lord have mercy on my soul.

Scorsese's "The Departed"

I had the opportunity last night to see a preview screening of The Departed at the Gene Siskel Film Center. To quote the woman in front of me: "That was damn good." It was a ripping good yarn that kept you on the edge of your seat the whole time wondering who knows what and will they continue to get away with it. The dialog was incredibly witty providing a Quentin Tarantino feel and the movie had a Chan-wook Park flare. A damn good time was had by all.

Thank you Mr. Scorsese for making the preview screening possible.

Creative Commons License Unless otherwise expressly stated, all original material of whatever nature created by Rob Grzywinski and included in this weblog and any related pages, including the weblog's archives, is licensed under a Creative Commons License.