@Test
public void getConnectionWhenDatasourceFails() throws Exception {

    expect(mockContext.lookup(eq("java:comp/env/jdbc/hook")))
        .andReturn(mockDataSource);
    expect(mockDataSource.getConnection()).andThrow(
            new SQLException("TEST"));
    EasyMockUnitils.replay();
    try {
        factory.getConnection("jdbc/hook");
        fail("DatabaseException expected");
    } catch (DatabaseException e) {
        // ok, expected
    }
}