@Test
public void shouldFailIfLookingUpDataSourceFails() throws Exception {

    final NamingException namingException = new NamingException("Ooops");
    final String jndiName = "jndiName";
    when(initialContext.lookup(jndiName)).thenThrow(namingException);
    try {
        defaultJdbcDataSourceProvider.getDataSource(jndiName);
        fail();
    } catch (final JdbcRepositoryException expected) {
        assertThat(expected.getCause(), is(namingException));
        assertThat(expected.getMessage(), is("Failed to lookup DataSource using jndi name 'jndiName'"));
    }
}