Revert "GH-3366: Return null from HTTP handleNoMatch"

This reverts commit 9aa9707f37.

See https://github.com/spring-projects/spring-framework/issues/25636#issuecomment-691269516
This commit is contained in:
Gary Russell
2020-09-11 15:29:16 -04:00
parent 9aa9707f37
commit dbb2f9cecb
4 changed files with 16 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.integration.http.config;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willReturn;
@@ -55,6 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.Validator;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.servlet.HandlerMapping;
@@ -193,13 +195,18 @@ public class HttpInboundChannelAdapterParserTests extends AbstractHttpInboundTes
}
@Test
public void getRequestNotAllowed() throws Exception {
public void getRequestNotAllowed() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
request.setParameter("foo", "bar");
request.setRequestURI("/postOnly");
assertThat(this.integrationRequestMappingHandlerMapping.getHandler(request)).isNull();
assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class)
.isThrownBy(() -> this.integrationRequestMappingHandlerMapping.getHandler(request))
.satisfies((ex) -> {
assertThat(ex.getMethod()).isEqualTo("GET");
assertThat(ex.getSupportedMethods()).containsExactly("POST");
});
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 the original author or authors.
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,8 +78,6 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.context.WebApplicationContext;
@@ -87,7 +85,6 @@ import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author Artem Bilan
@@ -211,7 +208,6 @@ public class HttpDslTests {
}
@Autowired
@Qualifier("customValidator")
private Validator validator;
@Test
@@ -297,20 +293,9 @@ public class HttpDslTests {
flowRegistration.destroy();
}
@Test
public void testMixWithMvcRequestMapping() throws Exception {
this.mockMvc.perform(
get("/mvcRequest")
.with(httpBasic("user", "user")))
.andExpect(status().isOk())
.andExpect(content().string("MVC reply"));
}
@Configuration
@EnableWebSecurity
@EnableIntegration
@EnableWebMvc
@RestController
public static class ContextConfiguration extends WebSecurityConfigurerAdapter {
@Override
@@ -424,19 +409,6 @@ public class HttpDslTests {
return new TestModelValidator();
}
@GetMapping("/mvcRequest")
ResponseEntity<?> mvcGet() {
return ResponseEntity.ok("MVC reply");
}
@Bean
HttpRequestHandlerEndpointSpec mvcHandler() {
return Http.inboundChannelAdapter("/mvcRequest")
.requestMapping((mapping) -> mapping.methods(HttpMethod.POST));
}
}
public static class HttpProxyResponseErrorHandler extends DefaultResponseErrorHandler {