ClassPath implements Iterable<String>, Tabular, Option { @Override public String toString() { return toString(PlatformSeparators.autoDetect()); } ClassPath();  ClassPath(ClassPath... classPaths);  ClassPath(Iterable<ClassPath> classPaths);  ClassPath(String... classPaths); int size(); boolean isEmpty(); URL[] getURLs(); boolean contains(String path); boolean contains(ClassPath classPath); @Override Iterator<String> iterator(); @Override String toString(); String toString(OptionsByType optionsByType); String toString(Option... options); @Override Table getTable(); ClassPath excluding(String... exclude); ClassPath excluding(ClassPath exclude); @Override boolean equals(Object other); @Override int hashCode(); static boolean isResourceAnArchive(String resourceName); static String getResourceArchiveType(String resourceName); static ClassPath ofResource(String      resourceName,
                                       ClassLoader classLoader); static ClassPath ofResource(String resourceName); static ClassPath ofClass(Class<?> clazz); static ClassPath ofClass(String      className,
                                    ClassLoader classLoader); static ClassPath ofFile(File file); @OptionsByType.Default static ClassPath ofSystem(); static ClassPath of(Iterable<String> paths); static ClassPath of(ClassPath... classPaths); static ClassPath of(String... classPaths); static final String[] JAVA_ARCHIVE_TYPES; }
@Test public void shouldUseSpecifiedSeparator() throws Exception { PlatformSeparators separators = mock(PlatformSeparators.class); ClassPath path = new ClassPath("foo.jar", "bar.jar"); when(separators.getPathSeparator()).thenReturn("$"); assertThat(path.toString(separators), is("foo.jar" + separators.getPathSeparator() + "bar.jar")); }
@Test public void shouldUseDefaultSeparators() throws Exception { PlatformSeparators separators = PlatformSeparators.autoDetect(); ClassPath path = new ClassPath("foo.jar", "bar.jar"); assertThat(path.toString(separators), is("foo.jar" + separators.getPathSeparator() + "bar.jar")); }
@Test public void shouldApplyModifier() throws Exception { ClassPathModifier modifier = mock(ClassPathModifier.class, "Mod"); PlatformSeparators separators = mock(PlatformSeparators.class, "Sep"); ClassPath path = new ClassPath("foo.jar", "bar.jar"); when(separators.getPathSeparator()).thenReturn("$"); when(modifier.modify(anyString())).thenReturn("modified-path"); String pathString = path.toString(separators, modifier); assertThat(pathString, is("modified-path")); verify(modifier).modify("foo.jar$bar.jar"); }