From f4ba1a20685c7e4064665a1659a2cf7b7ced124e Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 17 Nov 2008 13:39:10 +0000 Subject: [PATCH] Added test for ServletAnnotationMappingUtils git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@290 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../ServletAnnotationMappingUtilsTests.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java new file mode 100644 index 00000000000..294006af299 --- /dev/null +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java @@ -0,0 +1,29 @@ +package org.springframework.web.servlet.mvc.annotation; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.web.bind.annotation.RequestMethod; + +/** @author Arjen Poutsma */ +public class ServletAnnotationMappingUtilsTests { + + @Test + public void checkRequestMethodMatch() { + RequestMethod[] methods = new RequestMethod[]{RequestMethod.GET, RequestMethod.POST}; + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); + boolean result = ServletAnnotationMappingUtils.checkRequestMethod(methods, request); + assertTrue("Invalid request method result", result); + } + + @Test + public void checkRequestMethodNoMatch() { + RequestMethod[] methods = new RequestMethod[]{RequestMethod.GET, RequestMethod.POST}; + MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/"); + boolean result = ServletAnnotationMappingUtils.checkRequestMethod(methods, request); + assertFalse("Invalid request method result", result); + } + +}