Search in sources :

Example 66 with DefaultResourceLoader

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

the class HazelcastClientConfigAvailableConditionTests method getMatchOutcome.

private ConditionOutcome getMatchOutcome(Environment environment) {
    ConditionContext conditionContext = mock(ConditionContext.class);
    given(conditionContext.getEnvironment()).willReturn(environment);
    given(conditionContext.getResourceLoader()).willReturn(new DefaultResourceLoader());
    return this.condition.getMatchOutcome(conditionContext, mock(AnnotatedTypeMetadata.class));
}
Also used : ConditionContext(org.springframework.context.annotation.ConditionContext) AnnotatedTypeMetadata(org.springframework.core.type.AnnotatedTypeMetadata) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader)

Example 67 with DefaultResourceLoader

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

the class SpringApplication method printBanner.

private Banner printBanner(ConfigurableEnvironment environment) {
    if (this.bannerMode == Banner.Mode.OFF) {
        return null;
    }
    ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader : new DefaultResourceLoader(null);
    SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);
    if (this.bannerMode == Mode.LOG) {
        return bannerPrinter.print(environment, this.mainApplicationClass, logger);
    }
    return bannerPrinter.print(environment, this.mainApplicationClass, System.out);
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader)

Example 68 with DefaultResourceLoader

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

the class ConfigurationPropertiesScanTests method scanImportBeanRegistrarShouldBeResourceLoaderAwareWithRequiredResource.

@Test
void scanImportBeanRegistrarShouldBeResourceLoaderAwareWithRequiredResource() {
    DefaultResourceLoader resourceLoader = mock(DefaultResourceLoader.class);
    this.context.setResourceLoader(resourceLoader);
    willCallRealMethod().given(resourceLoader).getClassLoader();
    given(resourceLoader.getResource("test")).willReturn(new ByteArrayResource("test".getBytes()));
    load(TestConfiguration.class);
    assertThat(this.context.containsBean("resource-org.springframework.boot.context.properties.scan.valid.a.AScanConfiguration$MyResourceProperties")).isTrue();
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.jupiter.api.Test)

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