public void testFindByFilterPackageInJarUrlWithPlusChars() throws Exception { ClassLoader savedClassLoader = null; try { savedClassLoader = Thread.currentThread().getContextClassLoader(); URL url = getClass().getResource("/package+scan+test.jar"); URL urls[] = {new URL("jar:" + url.toString() + "!/")}; URLClassLoader classLoader = new URLClassLoader(urls, savedClassLoader); Thread.currentThread().setContextClassLoader(classLoader); // recreate resolver since we mess with context class loader resolver = new DefaultPackageScanClassResolver(); filter.addIncludePattern("a.*.c.*"); resolver.addFilter(filter); Set<Class<?>> scanned = resolver.findByFilter(filter, "a.b.c"); assertEquals(1, scanned.size()); assertEquals("class a.b.c.Test", scanned.iterator().next().toString()); } finally { if (savedClassLoader != null) { Thread.currentThread().setContextClassLoader(savedClassLoader); } } }
public void testFindByFilterWithIncludePackageFilter() { filter.addIncludePattern(scanPackage + ".**.ScanTarget*"); resolver.addFilter(filter); Set<Class<?>> scanned = resolver.findByFilter(filter, "org.apache.camel.spring.scan"); validateMatchingSetContains( scanned, ScanTargetOne.class, ScanTargetTwo.class, ScanTargetThree.class); }