ClasspathScanner { public Set<String> getClasses() throws IOException { Set<String> classes = new HashSet<String>(); Enumeration<URL> resources = getClassLoader().getResources(pkg + "/"); if (resources != null) { while (resources.hasMoreElements()) { String path = sanitizeURL(resources.nextElement().getFile()); if ((path != null) && (path.trim().length() > 0)) classes.addAll( isJARPath(path) ? getClassesFromJAR(path) : getClassesFromDirectory(path) ); } } return classes; } ClasspathScanner(String pkg, boolean subpackages);  ClasspathScanner(String pkg); Set<String> getClasses();  }
@Test(expected = IllegalArgumentException.class) public void getClasses() throws IOException { scanner = new ClasspathScanner("org.hibernate.annotations.common.*"); Set<String> classes = scanner.getClasses(); assertTrue(classes.size() == 2); assertTrue(classes.contains("org.hibernate.annotations.common.AssertionFailure")); assertTrue(classes.contains("org.hibernate.annotations.common.TestDirectoryScan")); scanner = new ClasspathScanner("org.hibernate.annotations.common.*", true); classes = scanner.getClasses(); assertTrue(classes.size() == 61); assertTrue(classes.contains("org.hibernate.annotations.common.other.another.AnotherTestDirectoryScan")); scanner = new ClasspathScanner("x.y.z", true); assertTrue(scanner.getClasses().size() == 0); scanner = new ClasspathScanner(""); }