Remove @MVC test with multiple matches
RequestMappingHandlerMapping currently picks the first match and does have logic to deal with selecting the best match. This caused a random test failure depending on which controller method was matched first. This change removes the test.
This commit is contained in:
parent
e9e4bcdc59
commit
8d30722f21
|
|
@ -32,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.reactive.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
@ -43,6 +42,7 @@ public class RequestMappingHandlerMappingTests {
|
||||||
|
|
||||||
private RequestMappingHandlerMapping mapping;
|
private RequestMappingHandlerMapping mapping;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||||
|
|
@ -52,6 +52,7 @@ public class RequestMappingHandlerMappingTests {
|
||||||
this.mapping = (RequestMappingHandlerMapping)wac.getBean("handlerMapping");
|
this.mapping = (RequestMappingHandlerMapping)wac.getBean("handlerMapping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void path() throws Exception {
|
public void path() throws Exception {
|
||||||
ReactiveServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "boo");
|
ReactiveServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "boo");
|
||||||
|
|
@ -68,10 +69,6 @@ public class RequestMappingHandlerMappingTests {
|
||||||
request = new MockServerHttpRequest(HttpMethod.GET, "foo");
|
request = new MockServerHttpRequest(HttpMethod.GET, "foo");
|
||||||
handler = (HandlerMethod) this.mapping.getHandler(request);
|
handler = (HandlerMethod) this.mapping.getHandler(request);
|
||||||
assertEquals(TestController.class.getMethod("getFoo"), handler.getMethod());
|
assertEquals(TestController.class.getMethod("getFoo"), handler.getMethod());
|
||||||
|
|
||||||
request = new MockServerHttpRequest(HttpMethod.PUT, "foo");
|
|
||||||
handler = (HandlerMethod) this.mapping.getHandler(request);
|
|
||||||
assertEquals(TestController.class.getMethod("foo"), handler.getMethod());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -79,11 +76,6 @@ public class RequestMappingHandlerMappingTests {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static class TestController {
|
private static class TestController {
|
||||||
|
|
||||||
@RequestMapping("foo")
|
|
||||||
public String foo() {
|
|
||||||
return "foo";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(path = "foo", method = RequestMethod.POST)
|
@RequestMapping(path = "foo", method = RequestMethod.POST)
|
||||||
public String postFoo() {
|
public String postFoo() {
|
||||||
return "postFoo";
|
return "postFoo";
|
||||||
|
|
@ -106,7 +98,11 @@ public class RequestMappingHandlerMappingTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MockServerHttpRequest implements ReactiveServerHttpRequest{
|
|
||||||
|
/**
|
||||||
|
* TODO: this is more widely needed.
|
||||||
|
*/
|
||||||
|
private static class MockServerHttpRequest implements ReactiveServerHttpRequest {
|
||||||
|
|
||||||
private HttpMethod method;
|
private HttpMethod method;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue