Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1668 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
1 changed files with 69 additions and 0 deletions
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
package org.springframework.web.context.request; |
||||
|
||||
import java.util.Iterator; |
||||
|
||||
import junit.framework.TestCase; |
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest; |
||||
|
||||
/** |
||||
* Unit test for the {@link HttpServletRequestParameterMap} class. |
||||
* |
||||
* @author Ulrik Sandberg |
||||
*/ |
||||
public class NativeWebRequestParameterMapTests extends TestCase { |
||||
|
||||
private NativeWebRequestParameterMap tested; |
||||
|
||||
private MockHttpServletRequest request; |
||||
|
||||
protected void setUp() throws Exception { |
||||
super.setUp(); |
||||
request = new MockHttpServletRequest(); |
||||
tested = new NativeWebRequestParameterMap(new ServletWebRequest(request)); |
||||
} |
||||
|
||||
protected void tearDown() throws Exception { |
||||
super.tearDown(); |
||||
request = null; |
||||
tested = null; |
||||
} |
||||
|
||||
public void testGetAttribute() { |
||||
request.setParameter("Some param", "Some value"); |
||||
// perform test
|
||||
Object result = tested.getAttribute("Some param"); |
||||
assertEquals("Some value", result); |
||||
} |
||||
|
||||
public void testSetAttribute() { |
||||
// perform test
|
||||
try { |
||||
tested.setAttribute("Some key", "Some value"); |
||||
fail("UnsupportedOperationException expected"); |
||||
} catch (UnsupportedOperationException expected) { |
||||
// expected
|
||||
} |
||||
} |
||||
|
||||
public void testRemoveAttribute() { |
||||
request.setParameter("Some param", "Some value"); |
||||
// perform test
|
||||
try { |
||||
tested.removeAttribute("Some param"); |
||||
fail("UnsupportedOperationException expected"); |
||||
} catch (UnsupportedOperationException expected) { |
||||
// expected
|
||||
} |
||||
} |
||||
|
||||
public void testGetAttributeNames() { |
||||
request.setParameter("Some param", "Some value"); |
||||
// perform test
|
||||
Iterator names = tested.getAttributeNames(); |
||||
assertNotNull("Null result unexpected", names); |
||||
assertTrue("More elements", names.hasNext()); |
||||
String name = (String) names.next(); |
||||
assertEquals("Some param", name); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue