|
23 | 23 | import org.junit.Test;
|
24 | 24 | import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
|
25 | 25 | import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter;
|
| 26 | +import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
| 27 | +import org.springframework.context.annotation.Bean; |
| 28 | +import org.springframework.context.annotation.Configuration; |
| 29 | +import org.springframework.context.annotation.Lazy; |
| 30 | +import org.springframework.context.annotation.Scope; |
| 31 | +import org.springframework.context.annotation.ScopedProxyMode; |
26 | 32 | import org.springframework.context.support.StaticApplicationContext;
|
27 | 33 | import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping;
|
28 | 34 | import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping;
|
@@ -69,6 +75,18 @@ public void beanUrlMappings() {
|
69 | 75 | assertEquals("mapping", map.get("bean"));
|
70 | 76 | }
|
71 | 77 |
|
| 78 | + @Test |
| 79 | + public void beanUrlMappingsProxy() { |
| 80 | + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( |
| 81 | + MappingConfiguration.class); |
| 82 | + this.endpoint.setApplicationContext(context); |
| 83 | + Map<String, Object> result = this.endpoint.invoke(); |
| 84 | + assertEquals(1, result.size()); |
| 85 | + @SuppressWarnings("unchecked") |
| 86 | + Map<String, Object> map = (Map<String, Object>) result.get("/foo"); |
| 87 | + assertEquals("scopedTarget.mapping", map.get("bean")); |
| 88 | + } |
| 89 | + |
72 | 90 | @Test
|
73 | 91 | public void beanMethodMappings() {
|
74 | 92 | StaticApplicationContext context = new StaticApplicationContext();
|
@@ -104,4 +122,15 @@ public void concreteMethodMappings() {
|
104 | 122 | assertTrue(handler.containsKey("method"));
|
105 | 123 | }
|
106 | 124 |
|
| 125 | + @Configuration |
| 126 | + protected static class MappingConfiguration { |
| 127 | + @Bean |
| 128 | + @Lazy |
| 129 | + @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS) |
| 130 | + public AbstractUrlHandlerMapping mapping() { |
| 131 | + SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); |
| 132 | + mapping.setUrlMap(Collections.singletonMap("/foo", new Object())); |
| 133 | + return mapping; |
| 134 | + } |
| 135 | + } |
107 | 136 | }
|
0 commit comments