|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -16,9 +16,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.web.servlet.mvc.method; |
|
|
|
package org.springframework.web.servlet.mvc.method; |
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.*; |
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
@ -26,7 +23,6 @@ import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Before; |
|
|
|
@ -63,6 +59,8 @@ import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition; |
|
|
|
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; |
|
|
|
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; |
|
|
|
import org.springframework.web.util.UrlPathHelper; |
|
|
|
import org.springframework.web.util.UrlPathHelper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.*; |
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Test fixture with {@link RequestMappingInfoHandlerMapping}. |
|
|
|
* Test fixture with {@link RequestMappingInfoHandlerMapping}. |
|
|
|
@ -157,9 +155,7 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-9603
|
|
|
|
@Test(expected = HttpMediaTypeNotAcceptableException.class) // SPR-9603
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = HttpMediaTypeNotAcceptableException.class) |
|
|
|
|
|
|
|
public void getHandlerRequestMethodMatchFalsePositive() throws Exception { |
|
|
|
public void getHandlerRequestMethodMatchFalsePositive() throws Exception { |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/users"); |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/users"); |
|
|
|
request.addHeader("Accept", "application/xml"); |
|
|
|
request.addHeader("Accept", "application/xml"); |
|
|
|
@ -167,9 +163,7 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
this.handlerMapping.getHandler(request); |
|
|
|
this.handlerMapping.getHandler(request); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-8462
|
|
|
|
@Test // SPR-8462
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void getHandlerMediaTypeNotSupported() throws Exception { |
|
|
|
public void getHandlerMediaTypeNotSupported() throws Exception { |
|
|
|
testHttpMediaTypeNotSupportedException("/person/1"); |
|
|
|
testHttpMediaTypeNotSupportedException("/person/1"); |
|
|
|
testHttpMediaTypeNotSupportedException("/person/1/"); |
|
|
|
testHttpMediaTypeNotSupportedException("/person/1/"); |
|
|
|
@ -197,18 +191,14 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-8462
|
|
|
|
@Test // SPR-8462
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void getHandlerMediaTypeNotAccepted() throws Exception { |
|
|
|
public void getHandlerMediaTypeNotAccepted() throws Exception { |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons"); |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons"); |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons/"); |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons/"); |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons.json"); |
|
|
|
testHttpMediaTypeNotAcceptableException("/persons.json"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-12854
|
|
|
|
@Test // SPR-12854
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void getHandlerUnsatisfiedServletRequestParameterException() throws Exception { |
|
|
|
public void getHandlerUnsatisfiedServletRequestParameterException() throws Exception { |
|
|
|
try { |
|
|
|
try { |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/params"); |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/params"); |
|
|
|
@ -275,10 +265,8 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
assertEquals("2", uriVariables.get("path2")); |
|
|
|
assertEquals("2", uriVariables.get("path2")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SPR-9098
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@Test |
|
|
|
@Test // SPR-9098
|
|
|
|
public void handleMatchUriTemplateVariablesDecode() { |
|
|
|
public void handleMatchUriTemplateVariablesDecode() { |
|
|
|
RequestMappingInfo key = RequestMappingInfo.paths("/{group}/{identifier}").build(); |
|
|
|
RequestMappingInfo key = RequestMappingInfo.paths("/{group}/{identifier}").build(); |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/group/a%2Fb"); |
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/group/a%2Fb"); |
|
|
|
@ -502,6 +490,7 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
@SuppressWarnings("unused") |
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
private static class UserController { |
|
|
|
private static class UserController { |
|
|
|
@ -515,6 +504,7 @@ public class RequestMappingInfoHandlerMappingTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class TestRequestMappingInfoHandlerMapping extends RequestMappingInfoHandlerMapping { |
|
|
|
private static class TestRequestMappingInfoHandlerMapping extends RequestMappingInfoHandlerMapping { |
|
|
|
|
|
|
|
|
|
|
|
public void registerHandler(Object handler) { |
|
|
|
public void registerHandler(Object handler) { |
|
|
|
|