use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class AnnotationModuleLoaderTest method testLoadModels.
@Test
public void testLoadModels() throws Exception {
AnnotationModelLoader loader = new AnnotationModelLoader(new DefaultPackageScanClassResolver());
Set<Class<?>> classes = loader.loadModels("org.apache.camel.dataformat.bindy.model.complex.twoclassesandonelink");
assertNotNull("The findForFormattingOptions classes should not be null ", classes);
assertEquals("There should have 3 classes", 3, classes.size());
assertTrue(classes.contains(Client.class));
assertTrue(classes.contains(Order.class));
assertTrue(classes.contains(Security.class));
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class DefaultPackageResolverConfigureTest method testSetAcceptableSchema.
public void testSetAcceptableSchema() throws Exception {
DefaultPackageScanClassResolver resolver = (DefaultPackageScanClassResolver) context.getPackageScanClassResolver();
assertNotNull(resolver);
// just check the accept schema
assertTrue("We should accept the test:!", resolver.isAcceptableScheme("test://test"));
assertTrue("We should accept the test2:!", resolver.isAcceptableScheme("test2://test"));
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class DefaultPackageScanClassResolverTest method setUp.
public void setUp() throws Exception {
super.setUp();
resolver = new DefaultPackageScanClassResolver();
annotations.add(org.apache.camel.spring.scan.ScannableOne.class);
annotations.add(org.apache.camel.spring.scan.ScannableTwo.class);
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class DefaultPackageScanClassResolverTest method testFindByFilterPackageInJarUrl.
public void testFindByFilterPackageInJarUrl() 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);
}
}
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class DefaultPackageScanClassResolverTest method testFindByFilterPackageInJarUrlWithPlusChars.
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);
}
}
}
Aggregations