backported @PathVariable matching fix (SPR-8543)

This commit is contained in:
Juergen Hoeller
2011-07-27 22:31:17 +00:00
parent d48c3b5d4f
commit 7605707c18
2 changed files with 71 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.BeansException;
@@ -43,7 +42,12 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping;
/** @author Arjen Poutsma */
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
* @author Rossen Stoyanchev
*/
public class UriTemplateServletAnnotationControllerTests {
private DispatcherServlet servlet;
@@ -309,9 +313,7 @@ public class UriTemplateServletAnnotationControllerTests {
assertEquals("test-42", response.getContentAsString());
}
/*
* See SPR-6640
*/
// SPR-6640
@Test
public void menuTree() throws Exception {
initServlet(MenuTreeController.class);
@@ -322,9 +324,7 @@ public class UriTemplateServletAnnotationControllerTests {
assertEquals("M5", response.getContentAsString());
}
/*
* See SPR-6876
*/
// SPR-6876
@Test
public void variableNames() throws Exception {
initServlet(VariableNamesController.class);
@@ -340,9 +340,18 @@ public class UriTemplateServletAnnotationControllerTests {
assertEquals("bar-bar", response.getContentAsString());
}
/*
* See SPR-6906
*/
// SPR-8543
@Test
public void variableNamesWithUrlExtension() throws Exception {
initServlet(VariableNamesController.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test/foo.json");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("foo-foo", response.getContentAsString());
}
// SPR-6906
@Test
public void controllerClassName() throws Exception {
servlet = new DispatcherServlet() {
@@ -376,9 +385,7 @@ public class UriTemplateServletAnnotationControllerTests {
assertEquals("plain-bar", response.getContentAsString());
}
/*
* See SPR-6978
*/
// SPR-6978
@Test
public void doIt() throws Exception {
initServlet(Spr6978Controller.class);
@@ -406,10 +413,7 @@ public class UriTemplateServletAnnotationControllerTests {
}
/*
* Controllers
*/
// Controllers
@Controller
public static class SimpleUriTemplateController {
@@ -548,7 +552,6 @@ public class UriTemplateServletAnnotationControllerTests {
}
@Controller
@RequestMapping("hotels")
public static class CrudController {
@@ -676,5 +679,4 @@ public class UriTemplateServletAnnotationControllerTests {
}
}
}