use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method customAssignableTypeIncludeFilterWithScan.
@Test
public void customAssignableTypeIncludeFilterWithScan() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
testCustomAssignableTypeIncludeFilter(provider);
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method customSupportedIncludeAndExcludeFilterWithIndex.
@Test
public void customSupportedIncludeAndExcludeFilterWithIndex() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
testCustomSupportedIncludeAndExcludeFilter(provider);
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method customFiltersFollowedByResetUseIndex.
@Test
public void customFiltersFollowedByResetUseIndex() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
provider.resetFilters(true);
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
assertBeanDefinitionType(candidates);
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method antStylePackageWithIndex.
@Test
public void antStylePackageWithIndex() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
testAntStyle(provider);
}
use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.
the class InjectedConstructionResolverTests method resolveMixedArgsConstructorWithUserBeanReference.
@ParameterizedTest
@MethodSource("mixedArgsConstruction")
void resolveMixedArgsConstructorWithUserBeanReference(InjectedConstructionResolver resolver) {
ResourceLoader resourceLoader = new DefaultResourceLoader();
Environment environment = mock(Environment.class);
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerResolvableDependency(ResourceLoader.class, resourceLoader);
beanFactory.registerSingleton("environment", environment);
beanFactory.registerSingleton("one", "1");
beanFactory.registerSingleton("two", "2");
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(MixedArgsConstructor.class).setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR).getBeanDefinition();
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, new RuntimeBeanReference("two"));
beanFactory.registerBeanDefinition("test", beanDefinition);
InjectedElementAttributes attributes = resolver.resolve(beanFactory);
assertThat(attributes.isResolved()).isTrue();
assertThat((ResourceLoader) attributes.get(0)).isEqualTo(resourceLoader);
assertThat((String) attributes.get(1)).isEqualTo("2");
assertThat((Environment) attributes.get(2)).isEqualTo(environment);
}
Aggregations