use of org.springframework.core.io.ProtocolResolver in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method mockProtocolResolver.
private ProtocolResolver mockProtocolResolver(String path, Resource resource) {
ProtocolResolver resolver = mock(ProtocolResolver.class);
given(resolver.resolve(eq(path), any(ResourceLoader.class))).willReturn(resource);
return resolver;
}
use of org.springframework.core.io.ProtocolResolver in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customProtocolResolverIsUsedInWebApplication.
@Test
void customProtocolResolverIsUsedInWebApplication() {
GenericWebApplicationContext context = new GenericWebApplicationContext(new MockServletContext());
Resource resource = mock(Resource.class);
ProtocolResolver resolver = mockProtocolResolver("foo:some-file.txt", resource);
context.addProtocolResolver(resolver);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
Resource actual = this.resolver.getResource("foo:some-file.txt");
assertThat(actual).isSameAs(resource);
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
}
use of org.springframework.core.io.ProtocolResolver in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customProtocolResolverIsUsedInNonWebApplication.
@Test
void customProtocolResolverIsUsedInNonWebApplication() {
GenericApplicationContext context = new GenericApplicationContext();
Resource resource = mock(Resource.class);
ProtocolResolver resolver = mockProtocolResolver("foo:some-file.txt", resource);
context.addProtocolResolver(resolver);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
Resource actual = this.resolver.getResource("foo:some-file.txt");
assertThat(actual).isSameAs(resource);
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
}
use of org.springframework.core.io.ProtocolResolver in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customProtocolResolverRegisteredAfterCreationIsUsedInNonWebApplication.
@Test
void customProtocolResolverRegisteredAfterCreationIsUsedInNonWebApplication() {
GenericApplicationContext context = new GenericApplicationContext();
Resource resource = mock(Resource.class);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
ProtocolResolver resolver = mockProtocolResolver("foo:some-file.txt", resource);
context.addProtocolResolver(resolver);
Resource actual = this.resolver.getResource("foo:some-file.txt");
assertThat(actual).isSameAs(resource);
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
}
use of org.springframework.core.io.ProtocolResolver in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method customProtocolResolverRegisteredAfterCreationIsUsedInWebApplication.
@Test
void customProtocolResolverRegisteredAfterCreationIsUsedInWebApplication() {
GenericWebApplicationContext context = new GenericWebApplicationContext(new MockServletContext());
Resource resource = mock(Resource.class);
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
ProtocolResolver resolver = mockProtocolResolver("foo:some-file.txt", resource);
context.addProtocolResolver(resolver);
Resource actual = this.resolver.getResource("foo:some-file.txt");
assertThat(actual).isSameAs(resource);
then(resolver).should().resolve(eq("foo:some-file.txt"), any(ResourceLoader.class));
}
Aggregations