Search in sources :

Example 6 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method customAssignableTypeIncludeFilterWithIndex.

@Test
public void customAssignableTypeIncludeFilterWithIndex() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
    testCustomAssignableTypeIncludeFilter(provider, AnnotatedGenericBeanDefinition.class);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 7 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method bogusPackageWithIndex.

@Test
public void bogusPackageWithIndex() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
    Set<BeanDefinition> candidates = provider.findCandidateComponents("bogus");
    assertEquals(0, candidates.size());
}
Also used : BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 8 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method customSupportedIncludeAndExcludedFilterWithScan.

@Test
public void customSupportedIncludeAndExcludedFilterWithScan() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
    testCustomSupportedIncludeAndExcludeFilter(provider, ScannedGenericBeanDefinition.class);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 9 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method customSupportIncludeFilterWithNonIndexedTypeUseScan.

@Test
public void customSupportIncludeFilterWithNonIndexedTypeUseScan() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
    // This annotation type is not directly annotated with Indexed so we can use
    // the index to find candidates
    provider.addIncludeFilter(new AnnotationTypeFilter(CustomStereotype.class));
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
    assertTrue(containsBeanClass(candidates, DefaultNamedComponent.class));
    assertEquals(1, candidates.size());
    assertBeanDefinitionType(candidates, ScannedGenericBeanDefinition.class);
}
Also used : AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) DefaultNamedComponent(example.scannable.DefaultNamedComponent) CustomStereotype(example.scannable.CustomStereotype) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 10 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class ClassPathScanningCandidateComponentProviderTests method customAnnotationTypeIncludeFilterWithIndex.

@Test
public void customAnnotationTypeIncludeFilterWithIndex() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
    testCustomAnnotationTypeIncludeFilter(provider, AnnotatedGenericBeanDefinition.class);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Aggregations

DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)39 Test (org.junit.Test)24 ResourceLoader (org.springframework.core.io.ResourceLoader)8 Before (org.junit.Before)5 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 Resource (org.springframework.core.io.Resource)4 URLClassLoader (java.net.URLClassLoader)3 DefaultNamedComponent (example.scannable.DefaultNamedComponent)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 X509Certificate (java.security.cert.X509Certificate)2 SnmpAgentAddress (org.opennms.netmgt.snmp.SnmpAgentAddress)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 Context (ch.qos.logback.core.Context)1 DevComponent (example.profilescan.DevComponent)1 ProfileAnnotatedComponent (example.profilescan.ProfileAnnotatedComponent)1 ProfileMetaAnnotatedComponent (example.profilescan.ProfileMetaAnnotatedComponent)1 CustomStereotype (example.scannable.CustomStereotype)1 FooDao (example.scannable.FooDao)1