@Test
public void shouldThrowExceptionIfTheLookupOfTheDataSourceFails() throws Exception {

    final NamingException namingException = new NamingException();
    final String dataSourceName = "java:/DS.framework";
    when(viewStoreDataSourceNameProvider.getDataSourceName()).thenReturn(dataSourceName);
    when(initialContext.lookup(dataSourceName)).thenThrow(namingException);
    try {
        viewStoreJdbcDataSourceProvider.getDataSource();
        fail();
    } catch (final JdbcRepositoryException expected) {
        assertThat(expected.getCause(), is(namingException));
        assertThat(expected.getMessage(), is("Failed to lookup ViewStore DataSource using JNDI name 'java:/DS.framework'"));
    }
}