use of org.springframework.core.io.ResourceLoader in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customResourceLoaderIsUsedInWebApplication.
@Test
void customResourceLoaderIsUsedInWebApplication() {
GenericWebApplicationContext context = new GenericWebApplicationContext(new MockServletContext());
ResourceLoader resourceLoader = mock(ResourceLoader.class);
context.setResourceLoader(resourceLoader);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
this.resolver.getResource("foo.txt");
then(resourceLoader).should().getResource("foo.txt");
}
use of org.springframework.core.io.ResourceLoader in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customResourceLoaderIsUsedInNonWebApplication.
@Test
void customResourceLoaderIsUsedInNonWebApplication() {
GenericApplicationContext context = new GenericApplicationContext();
ResourceLoader resourceLoader = mock(ResourceLoader.class);
context.setResourceLoader(resourceLoader);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
this.resolver.getResource("foo.txt");
then(resourceLoader).should().getResource("foo.txt");
}
use of org.springframework.core.io.ResourceLoader in project spring-boot by spring-projects.
the class SpringApplicationTests method customResourceLoaderFromConstructor.
@Test
void customResourceLoaderFromConstructor() {
ResourceLoader resourceLoader = new DefaultResourceLoader();
TestSpringApplication application = new TestSpringApplication(resourceLoader, ExampleWebConfig.class);
this.context = application.run();
then(application.getLoader()).should().setResourceLoader(resourceLoader);
}
use of org.springframework.core.io.ResourceLoader in project spring-boot by spring-projects.
the class Restarter method prepare.
private void prepare(GenericApplicationContext applicationContext) {
ResourceLoader resourceLoader = new ClassLoaderFilesResourcePatternResolver(applicationContext, this.classLoaderFiles);
applicationContext.setResourceLoader(resourceLoader);
}
use of org.springframework.core.io.ResourceLoader 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);
}
Aggregations