import org.junit.Test;
public final class CurrentClassLoaderResourceLocatorTest {
@Test
public void testFindResource() {
ResourceLocator locator = new CurrentClassLoaderResourceLocator();
try {
URL url = locator.findResource("file1.txt");
Assert.assertNotNull(url);
} catch (ResourceNotFoundException e) {
Assert.fail("Resource should be found but was not found.");
}
try {
URL url = locator.findResource("one/file2.txt");
Assert.assertNotNull(url);
} catch (ResourceNotFoundException e) {
Assert.fail("Resource should be found but was not found.");
}
try {
URL url = locator.findResource("one/two/file3.txt");
Assert.assertNotNull(url);
} catch (ResourceNotFoundException e) {
Assert.fail("Resource should be found but was not found.");
}
try {
locator.findResource("missing.txt");
Assert.fail("Resource should not be found but was found.");
} catch (ResourceNotFoundException e) {
// Expected.
}
}