Polish PathVariableMapMethodArgumentResolver

Return an empty map when there are no path variables, rather than
raising an exception. This is consistent with similar resolvers for
extracting headers and request parameters.

Issue: SPR-9289
This commit is contained in:
Rossen Stoyanchev
2012-06-26 10:23:01 -04:00
parent 4fd7645efd
commit 3f5fa44d32
2 changed files with 14 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -89,9 +90,12 @@ public class PathVariableMapMethodArgumentResolverTests {
assertEquals(uriTemplateVars, result);
}
@Test(expected=ServletRequestBindingException.class)
@Test
@SuppressWarnings("unchecked")
public void resolveArgumentNoUriVars() throws Exception {
resolver.resolveArgument(paramMap, mavContainer, webRequest, null);
Map<String, String> map = (Map<String, String>) resolver.resolveArgument(paramMap, mavContainer, webRequest, null);
assertEquals(Collections.emptyMap(), map);
}