Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 1 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Automatically repeatable Spring+Hibernate+FIT/FitNesse data-driven tests

At 3:53 PM on Jan 22, 2008, Gojko Adzic wrote:

Declarative transactions in Spring and Hibernate make programming enterprise applications much easier, but they also make integrated database tests a bit tricky. Crossing the transaction boundary between fixtures and services will cause data changes to become permanent, which makes tests non-repeatable and harder to maintain. I’ve finally found good solution for this problem — it is a bit dirty, but very effective.

The trick is based on the fact that FitNesse does not execute FIT in-process, but as an external program in order to allow test runners for languages like C# and Python to be plugged in.

We can use this feature to supply a different Java test runner, which will be injected into the Spring context straight from the start. We can mark the entry point as @Transactional, so no matter how many fixtures are instantiated and how ever they use the service layer, the calls will never cross the transaction boundary and require the transaction to commit. On the end, the test runner just has to roll back the active transaction and everything that the test changed will simply disappear.

This solution is totally non-intrusive, and automatically works for all fixtures. There is no need to replicate transaction management code all over the test suites. No special fixture code is required in fixtures or services, and it does not matter whether the page is in flow mode or works with standalone fixtures. No special SetUp or TearDown pages are required.

Implementing it, however, turned out to be tricky. That is why I said that the solution is a bit dirty. The FIT server class was not written with such use in mind (which is no surprise, really). But the ugly part is encapsulated and hidden from the end users, so it works good enough. You can get the code from http://gojko.net/2008/01/22/spring-rollback/
1 . At 9:15 PM on Jan 25, 2008, groovy wrote:
  Click to reply to this thread Reply

Re: Automatically repeatable Spring+Hibernate+FIT/FitNesse data-driven tests

awesome tip, thanks for sharing.
Java Tip

thread.rss_message