Skip to content

Commit 8678652

Browse files
committed
SPR-6528 - PathVariables of type double
1 parent 976f920 commit 8678652

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

+35
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ public void binding() throws Exception {
8888
assertEquals(500, response.getStatus());
8989
}
9090

91+
@Test
92+
public void doubles() throws Exception {
93+
servlet = new DispatcherServlet() {
94+
@Override
95+
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
96+
throws BeansException {
97+
GenericWebApplicationContext wac = new GenericWebApplicationContext();
98+
wac.registerBeanDefinition("controller", new RootBeanDefinition(DoubleController.class));
99+
RootBeanDefinition mappingDef = new RootBeanDefinition(DefaultAnnotationHandlerMapping.class);
100+
mappingDef.getPropertyValues().add("useDefaultSuffixPattern", false);
101+
wac.registerBeanDefinition("handlerMapping", mappingDef);
102+
wac.refresh();
103+
return wac;
104+
}
105+
};
106+
servlet.init(new MockServletConfig());
107+
108+
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/lat/1.2/long/3.4");
109+
MockHttpServletResponse response = new MockHttpServletResponse();
110+
servlet.service(request, response);
111+
112+
assertEquals("latitude-1.2-longitude-3.4", response.getContentAsString());
113+
}
114+
91115
@Test
92116
public void ambiguous() throws Exception {
93117
initServlet(AmbiguousUriTemplateController.class);
@@ -415,6 +439,17 @@ public void handle(@PathVariable("root") int root, Writer writer) throws IOExcep
415439

416440
}
417441

442+
@Controller
443+
public static class DoubleController {
444+
445+
@RequestMapping("/lat/{latitude}/long/{longitude}")
446+
public void testLatLong(@PathVariable Double latitude, @PathVariable Double longitude, Writer writer)
447+
throws IOException {
448+
writer.write("latitude-" + latitude + "-longitude-" + longitude);
449+
}
450+
451+
}
452+
418453

419454
@Controller
420455
@RequestMapping("hotels")

0 commit comments

Comments
 (0)