@ -23,6 +23,12 @@ import java.util.Map;
import org.junit.Test ;
import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping ;
import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter ;
import org.springframework.context.annotation.AnnotationConfigApplicationContext ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.context.annotation.Scope ;
import org.springframework.context.annotation.ScopedProxyMode ;
import org.springframework.context.support.StaticApplicationContext ;
import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping ;
import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping ;
@ -69,6 +75,18 @@ public class RequestMappingEndpointTests {
assertEquals ( "mapping" , map . get ( "bean" ) ) ;
}
@Test
public void beanUrlMappingsProxy ( ) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (
MappingConfiguration . class ) ;
this . endpoint . setApplicationContext ( context ) ;
Map < String , Object > result = this . endpoint . invoke ( ) ;
assertEquals ( 1 , result . size ( ) ) ;
@SuppressWarnings ( "unchecked" )
Map < String , Object > map = ( Map < String , Object > ) result . get ( "/foo" ) ;
assertEquals ( "scopedTarget.mapping" , map . get ( "bean" ) ) ;
}
@Test
public void beanMethodMappings ( ) {
StaticApplicationContext context = new StaticApplicationContext ( ) ;
@ -104,4 +122,15 @@ public class RequestMappingEndpointTests {
assertTrue ( handler . containsKey ( "method" ) ) ;
}
@Configuration
protected static class MappingConfiguration {
@Bean
@Lazy
@Scope ( proxyMode = ScopedProxyMode . TARGET_CLASS )
public AbstractUrlHandlerMapping mapping ( ) {
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping ( ) ;
mapping . setUrlMap ( Collections . singletonMap ( "/foo" , new Object ( ) ) ) ;
return mapping ;
}
}
}