|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2020 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
23 | 23 |
|
24 | 24 | import javax.servlet.http.HttpServletRequest;
|
25 | 25 |
|
| 26 | +import org.junit.jupiter.api.Test; |
26 | 27 | import org.junit.jupiter.params.provider.Arguments;
|
27 | 28 |
|
28 | 29 | import org.springframework.web.context.support.StaticWebApplicationContext;
|
@@ -66,16 +67,30 @@ void orderedInterceptors(
|
66 | 67 | mapping.setApplicationContext(new StaticWebApplicationContext());
|
67 | 68 |
|
68 | 69 | HandlerExecutionChain chain = mapping.getHandler(requestFactory.apply("/"));
|
| 70 | + |
69 | 71 | assertThat(chain).isNotNull();
|
70 | 72 | assertThat(chain.getInterceptorList()).contains(i1.getInterceptor(), i2, i3.getInterceptor(), i4);
|
71 | 73 | }
|
72 | 74 |
|
| 75 | + @Test // gh-26546 |
| 76 | + void abstractHandlerMappingEnsuresCachedLookupPath() throws Exception { |
| 77 | + MappedInterceptor interceptor = new MappedInterceptor(new String[] {"/**"}, mock(HandlerInterceptor.class)); |
| 78 | + TestHandlerMapping mapping = new TestHandlerMapping(); |
| 79 | + mapping.setInterceptors(interceptor); |
| 80 | + mapping.setApplicationContext(new StaticWebApplicationContext()); |
| 81 | + |
| 82 | + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); |
| 83 | + HandlerExecutionChain chain = mapping.getHandler(request); |
| 84 | + |
| 85 | + assertThat(chain).isNotNull(); |
| 86 | + assertThat(chain.getInterceptorList()).contains(interceptor.getInterceptor()); |
| 87 | + } |
| 88 | + |
73 | 89 |
|
74 | 90 | private static class TestHandlerMapping extends AbstractHandlerMapping {
|
75 | 91 |
|
76 | 92 | @Override
|
77 | 93 | protected Object getHandlerInternal(HttpServletRequest request) {
|
78 |
| - initLookupPath(request); |
79 | 94 | return new Object();
|
80 | 95 | }
|
81 | 96 | }
|
|
0 commit comments