Search in sources :

Example 46 with DefaultResourceLoader

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);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.jupiter.api.Test)

Example 47 with DefaultResourceLoader

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);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.jupiter.api.Test)

Example 48 with DefaultResourceLoader

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);
}
Also used : AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) ProfileMetaAnnotatedComponent(example.profilescan.ProfileMetaAnnotatedComponent) NamedComponent(example.scannable.NamedComponent) AnnotatedComponent(example.gh24375.AnnotatedComponent) ProfileAnnotatedComponent(example.profilescan.ProfileAnnotatedComponent) BarComponent(example.scannable.sub.BarComponent) DevComponent(example.profilescan.DevComponent) Component(org.springframework.stereotype.Component) DefaultNamedComponent(example.scannable.DefaultNamedComponent) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.jupiter.api.Test)

Example 49 with DefaultResourceLoader

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);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.jupiter.api.Test)

Example 50 with DefaultResourceLoader

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);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Environment(org.springframework.core.env.Environment) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)68 Test (org.junit.jupiter.api.Test)28 ResourceLoader (org.springframework.core.io.ResourceLoader)20 Resource (org.springframework.core.io.Resource)10 Before (org.junit.Before)8 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)8 IOException (java.io.IOException)6 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)6 URLClassLoader (java.net.URLClassLoader)4 Test (org.junit.Test)4 Environment (org.springframework.core.env.Environment)4 InputStream (java.io.InputStream)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)3 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)3 LRUCacheManager (io.syndesis.common.util.cache.LRUCacheManager)2 DataManager (io.syndesis.server.dao.manager.DataManager)2 EncryptionComponent (io.syndesis.server.dao.manager.EncryptionComponent)2 File (java.io.File)2