SliceResourceScanner { public Collection<Class<?>> findSliceResources(Bundle bundle, String basePackage) { BundleClassesFinder classFinder = new BundleClassesFinder(basePackage); classFinder.addFilter(new SliceResourceFilter()); LOG.info("Searching for classes annotated with SliceResource, packages: {}, bundle: {}", basePackage, bundle.getSymbolicName()); Collection<Class<?>> classes = classFinder.getClasses(bundle); LOG.info("Found {} Slice Resource classes. Switch to debug logging level to see them all.", classes.size()); return classes; }  Collection<Class<?>> findSliceResources(Bundle bundle, String basePackage);  }
@Test public void testFindSliceResources() throws ClassNotFoundException { final List<String> classList = Lists.newArrayList("com/cognifide/slice/testhelper/TestBundleClass1", "com/cognifide/slice/testhelper/TestBundleClass2"); setUp(classList); SliceResourceScanner sliceResourceScanner = new SliceResourceScanner(); Collection<Class<?>> classes = sliceResourceScanner.findSliceResources(bundle, "test"); Assert.assertEquals(1, classes.size()); Assert.assertEquals("TestBundleClass2", new ArrayList<Class<?>>(classes).get(0).getSimpleName()); }
@Test public void testFindSliceInnerClassesResources() throws ClassNotFoundException { final List<String> classList = Lists.newArrayList( "com/cognifide/slice/testhelper/TestBundleInnerClass1", "com/cognifide/slice/testhelper/TestBundleInnerClass2"); setUp(classList); SliceResourceScanner sliceResourceScanner = new SliceResourceScanner(); Collection<Class<?>> classes = sliceResourceScanner.findSliceResources(bundle, "test"); Assert.assertEquals(1, classes.size()); Assert.assertEquals("TestBundleInnerClass1", new ArrayList<Class<?>>(classes).get(0).getSimpleName()); }