This commit is contained in:
Phillip Webb 2016-11-18 15:58:56 -08:00
parent 3a3228fc70
commit c2c5611f77
2 changed files with 5 additions and 4 deletions

View File

@ -112,9 +112,9 @@ class CloudFoundryEndpointHandlerMapping
/**
* {@link HandlerInterceptor} that processes the response for CORS.
*
*/
class CorsInterceptor extends HandlerInterceptorAdapter {
private final CorsConfiguration config;
CorsInterceptor(CorsConfiguration config) {

View File

@ -41,6 +41,8 @@ import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.HandlerInterceptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link CloudFoundryEndpointHandlerMapping}.
@ -56,7 +58,7 @@ public class CloudFoundryEndpointHandlerMappingTests
CorsConfiguration corsConfiguration = new CorsConfiguration();
CloudFoundryEndpointHandlerMapping handlerMapping = new CloudFoundryEndpointHandlerMapping(
Collections.singleton(endpoint), corsConfiguration, null);
CorsProcessor corsProcessor = Mockito.mock(CorsProcessor.class);
CorsProcessor corsProcessor = mock(CorsProcessor.class);
handlerMapping.setCorsProcessor(corsProcessor);
MockHttpServletRequest request = new MockHttpServletRequest();
HandlerExecutionChain handlerExecutionChain = handlerMapping
@ -65,8 +67,7 @@ public class CloudFoundryEndpointHandlerMappingTests
CloudFoundryEndpointHandlerMapping.CorsInterceptor corsInterceptor = (CloudFoundryEndpointHandlerMapping.CorsInterceptor) interceptors[0];
MockHttpServletResponse response = new MockHttpServletResponse();
corsInterceptor.preHandle(request, response, new Object());
Mockito.verify(corsProcessor).processRequest(corsConfiguration, request,
response);
verify(corsProcessor).processRequest(corsConfiguration, request, response);
}
@Test