### Question:
DataSourceResourceLoader extends HadoopClassLoader { @Nonnull public Optional<DataSourceRegister> getDataSource(@Nonnull final String shortName) { final List<DataSourceRegister> matches = new ArrayList<>(1); for (final DataSourceRegister dataSource : dataSourceLoader) { if (dataSource.shortName().equalsIgnoreCase(shortName)) { matches.add(dataSource); } } if (matches.size() == 1) { return Optional.of(matches.get(0)); } else if (matches.isEmpty()) { return Optional.absent(); } else { if (log.isDebugEnabled()) { final List<String> matchClasses = new ArrayList<>(matches.size()); for (final DataSourceRegister dataSource : matches) { matchClasses.add(dataSource.getClass().getName()); } log.debug("Multiple sources found for data source [{}]: {}", shortName, matchClasses); } throw new IllegalArgumentException("Multiple sources found for " + shortName + ", please specify the fully qualified class name."); } } DataSourceResourceLoader(@Nonnull final SparkContext sparkContext, @Nonnull final ClassLoader parent); void addFile(@Nullable final String path); @Nonnull Optional<DataSourceRegister> getDataSource(@Nonnull final String shortName); T runWithThreadContext(@Nonnull final Callable<T> callable); void runWithThreadContext(@Nonnull final Runnable runnable);  }### Answer:
@Test public void getDataSource() { final SparkContext sparkContext = Mockito.mock(SparkContext.class); Mockito.when(sparkContext.hadoopConfiguration()).thenReturn(new Configuration(false)); final DataSourceResourceLoader loader = DataSourceResourceLoader.create(sparkContext); Optional<DataSourceRegister> dataSource = loader.getDataSource("mock"); Assert.assertThat(dataSource, isAbsent()); loader.addJar(getClass().getResource("/").toString()); dataSource = loader.getDataSource("mock"); Assert.assertThat(dataSource, isPresentAndThat(dataSourceShortName(CoreMatchers.equalTo("mock")))); dataSource = loader.getDataSource("MOCK"); Assert.assertThat(dataSource, isPresentAndThat(dataSourceShortName(CoreMatchers.equalTo("mock")))); }