Search in sources :

Example 6 with ProtocolResolver

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

the class ConfigurationPropertiesTests method customProtocolResolverIsInvoked.

@Test
void customProtocolResolverIsInvoked() {
    this.context = new AnnotationConfigApplicationContext();
    TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "test.resource=application.properties");
    ProtocolResolver protocolResolver = mock(ProtocolResolver.class);
    given(protocolResolver.resolve(anyString(), any(ResourceLoader.class))).willReturn(null);
    this.context.addProtocolResolver(protocolResolver);
    this.context.register(PropertiesWithResource.class);
    this.context.refresh();
    then(protocolResolver).should().resolve(eq("application.properties"), any(ResourceLoader.class));
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ProtocolResolver(org.springframework.core.io.ProtocolResolver) Test(org.junit.jupiter.api.Test)

Aggregations

ProtocolResolver (org.springframework.core.io.ProtocolResolver)6 ResourceLoader (org.springframework.core.io.ResourceLoader)6 Test (org.junit.jupiter.api.Test)5 DeletedClassLoaderFileResource (org.springframework.boot.devtools.restart.ClassLoaderFilesResourcePatternResolver.DeletedClassLoaderFileResource)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 Resource (org.springframework.core.io.Resource)4 ServletContextResource (org.springframework.web.context.support.ServletContextResource)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1