ScannerRegistry { public LocationScanner getScanner(String scheme) { notNullOrEmpty(scheme, "scheme"); return this.scanners.get(scheme.toLowerCase()); } ScannerRegistry(); LocationScanner getScanner(String scheme); boolean supports(String scheme); void register(String scheme, LocationScanner scanner); void unregister(String scheme); static final String JAR_SCHEME; static final String FILE_SCHEME; }
@Test public void shouldReturnFileSystemLocationScannerWhenNonJarSchemeGiven() { LocationScanner scanner = new ScannerRegistry().getScanner("file"); assertThat(scanner, is(not(nullValue()))); assertThat(FileSystemLocationScanner.class.isAssignableFrom(scanner.getClass()), is(true)); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenNoSchemeGiven() { new ScannerRegistry().getScanner(null); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenEmptySchemeGiven() { new ScannerRegistry().getScanner(""); }
@Test public void shouldReturnJarLocationScannerWhenJarSchemeGiven() { LocationScanner scanner = new ScannerRegistry().getScanner("jar"); assertThat(scanner, is(not(nullValue()))); assertThat(JarLocationScanner.class.isAssignableFrom(scanner.getClass()), is(true)); }
@Test public void shouldIgnoreCaseWhenJarSchemeGiven() { LocationScanner scanner = new ScannerRegistry().getScanner("jAr"); assertThat(scanner, is(not(nullValue()))); assertThat(JarLocationScanner.class.isAssignableFrom(scanner.getClass()), is(true)); }