@Test
public void getDataSource() {

    // Mock Spark context
    final SparkContext sparkContext = Mockito.mock(SparkContext.class);
    Mockito.when(sparkContext.hadoopConfiguration()).thenReturn(new Configuration(false));
    // Test with no jars
    final DataSourceResourceLoader loader = DataSourceResourceLoader.create(sparkContext);
    Optional<DataSourceRegister> dataSource = loader.getDataSource("mock");
    Assert.assertThat(dataSource, isAbsent());
    // Test with service jar
    loader.addJar(getClass().getResource("/").toString());
    dataSource = loader.getDataSource("mock");
    Assert.assertThat(dataSource, isPresentAndThat(dataSourceShortName(CoreMatchers.equalTo("mock"))));
    // Test case-insensitive match (as Spark does)
    dataSource = loader.getDataSource("MOCK");
    Assert.assertThat(dataSource, isPresentAndThat(dataSourceShortName(CoreMatchers.equalTo("mock"))));
}