From 8678652f3e5e9f53cc63486544bcb54cb13bf672 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 7 Dec 2009 14:25:21 +0000 Subject: [PATCH] SPR-6528 - PathVariables of type double --- ...plateServletAnnotationControllerTests.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java index 0d900cf095..6c079491c8 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java @@ -88,6 +88,30 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals(500, response.getStatus()); } + @Test + public void doubles() throws Exception { + servlet = new DispatcherServlet() { + @Override + protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) + throws BeansException { + GenericWebApplicationContext wac = new GenericWebApplicationContext(); + wac.registerBeanDefinition("controller", new RootBeanDefinition(DoubleController.class)); + RootBeanDefinition mappingDef = new RootBeanDefinition(DefaultAnnotationHandlerMapping.class); + mappingDef.getPropertyValues().add("useDefaultSuffixPattern", false); + wac.registerBeanDefinition("handlerMapping", mappingDef); + wac.refresh(); + return wac; + } + }; + servlet.init(new MockServletConfig()); + + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/lat/1.2/long/3.4"); + MockHttpServletResponse response = new MockHttpServletResponse(); + servlet.service(request, response); + + assertEquals("latitude-1.2-longitude-3.4", response.getContentAsString()); + } + @Test public void ambiguous() throws Exception { initServlet(AmbiguousUriTemplateController.class); @@ -415,6 +439,17 @@ public class UriTemplateServletAnnotationControllerTests { } + @Controller + public static class DoubleController { + + @RequestMapping("/lat/{latitude}/long/{longitude}") + public void testLatLong(@PathVariable Double latitude, @PathVariable Double longitude, Writer writer) + throws IOException { + writer.write("latitude-" + latitude + "-longitude-" + longitude); + } + + } + @Controller @RequestMapping("hotels") -- GitLab