factory.setRoots(Arrays.asList(getRoot(getClass())));
KernelDeployment deployment = install(factory);
try
{
final Set<String> classes = new HashSet<String>();
ResourceVisitor visitor = new ResourceVisitor()
{
public ResourceFilter getFilter()
{
return new ResourceFilter()
{
public boolean accepts(ResourceContext resource)
{
return resource.getResourceName().contains("support");
}
};
}
public void visit(ResourceContext resource)
{
classes.add(resource.getClassName());
}
};
final String pathA = ClassLoaderUtils.packageNameToPath(A.class.getName());
final int pathAlength = pathA.length();
ResourceFilter recurseFilter = new ResourceFilter()
{
public boolean accepts(ResourceContext resource)
{
String resourceName = resource.getResourceName();
int min = Math.min(resourceName.length(), pathAlength);
return pathA.substring(0, min).equals(resourceName.substring(0, min));
}
};
Module module = assertModule("test:0.0.0");
module.visit(visitor, visitor.getFilter(), recurseFilter);
assertEquals(1, classes.size());
assertEquals(classes.iterator().next(), A.class.getName());
}
finally