Using Data Storm

In order to use Data Storm, you need to add datastorm.jar and SWT.jar to your class path.

When you then have a test case that is failing, then all you need to do is insert the following code to open a data storm window to inspect your database.

import org.datastorm.DataStorm;

class FooTest extends TestCase {
    public void testSomething() {
        new DataStorm().show(conn);
    }
}
Where conn is either a import java.sql.Connection or a DataSource. This will open an empty window.

You probably become tired of firing the same SQL each time, and you may forget from test to test what SQL is nice to use. Hence, you can pre-populate the Data Storm window with SQL which is automatically executed upon opening the window. To do so, you use the overloaded method

new DataStorm().show(conn, "SELECT * FROM foo, bar WHERE foo.id = bar.foo_id");
Since you are inside your normal java test environment, you can easily embed id's and other contextual information from your test into your queries. e.g.
class ATest {
    public void test_something() {
        long id = aService.save( new Person() );
        new DataStorm().show(conn, "SELECT * FROM person p WHERE p.id = " + id );
        ...
    }
}

IDE fine-tuning

Remember your IDE can be set up to easily paste queries into your java code (when pasting inside a string.
  • In Eclipse: Window -> preferences... -> Java -> Editor -> Typing -> escape text when pasting into a string literal

Testing in Spring

If your tests subclass AbstractTransactionalDataSourceSpringContextTests, note that the following will probably give you a connection, but not a connection enabling you to see changes to your database made within the test
class PromblemApproachTest extends AbstractTransactionalDataSourceSpringContextTests {
    public void test_dont_get_the_data() {
        new DataStorm().show(super.getJdbcTemplate().getDataSource(), "SELECT ..");
        new DataStorm().show(super.jdbcTemplate.getDataSource(), "SELECT ..");
Instead, what you will have to do is create an extra dao interface and an implementation and wire it to your test. Your dao could look like
class ConnectionDao extends SqlMapClientDaoSupport implements IConnectionDao {
    public DataSource getDataSource() {
        return getSqlMapClientTemplate().getDataSource();
    }
} 
The above code shows such a dao when compining Spring and iBatis

As the feature set of Data Storm grows, so will this page...

For more details see the Javadoc at Javadoc