Polishing
This commit is contained in:
parent
95ef9c25c2
commit
ddaf0029ae
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -31,11 +31,13 @@ import static org.springframework.core.testfixture.TestGroup.PERFORMANCE;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @since 06.08.2003
|
* @since 06.08.2003
|
||||||
*/
|
*/
|
||||||
public class ServletRequestUtilsTests {
|
class ServletRequestUtilsTests {
|
||||||
|
|
||||||
|
private final MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntParameter() throws ServletRequestBindingException {
|
void testIntParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "5");
|
request.addParameter("param1", "5");
|
||||||
request.addParameter("param2", "e");
|
request.addParameter("param2", "e");
|
||||||
request.addParameter("paramEmpty", "");
|
request.addParameter("paramEmpty", "");
|
||||||
|
@ -58,8 +60,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntParameters() throws ServletRequestBindingException {
|
void testIntParameters() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param", new String[] {"1", "2", "3"});
|
request.addParameter("param", new String[] {"1", "2", "3"});
|
||||||
|
|
||||||
request.addParameter("param2", "1");
|
request.addParameter("param2", "1");
|
||||||
|
@ -78,8 +79,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLongParameter() throws ServletRequestBindingException {
|
void testLongParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "5");
|
request.addParameter("param1", "5");
|
||||||
request.addParameter("param2", "e");
|
request.addParameter("param2", "e");
|
||||||
request.addParameter("paramEmpty", "");
|
request.addParameter("paramEmpty", "");
|
||||||
|
@ -102,8 +102,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLongParameters() throws ServletRequestBindingException {
|
void testLongParameters() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.setParameter("param", new String[] {"1", "2", "3"});
|
request.setParameter("param", new String[] {"1", "2", "3"});
|
||||||
|
|
||||||
request.setParameter("param2", "0");
|
request.setParameter("param2", "0");
|
||||||
|
@ -127,8 +126,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFloatParameter() throws ServletRequestBindingException {
|
void testFloatParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "5.5");
|
request.addParameter("param1", "5.5");
|
||||||
request.addParameter("param2", "e");
|
request.addParameter("param2", "e");
|
||||||
request.addParameter("paramEmpty", "");
|
request.addParameter("paramEmpty", "");
|
||||||
|
@ -151,8 +149,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFloatParameters() throws ServletRequestBindingException {
|
void testFloatParameters() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
|
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
|
||||||
|
|
||||||
request.addParameter("param2", "1.5");
|
request.addParameter("param2", "1.5");
|
||||||
|
@ -167,8 +164,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoubleParameter() throws ServletRequestBindingException {
|
void testDoubleParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "5.5");
|
request.addParameter("param1", "5.5");
|
||||||
request.addParameter("param2", "e");
|
request.addParameter("param2", "e");
|
||||||
request.addParameter("paramEmpty", "");
|
request.addParameter("paramEmpty", "");
|
||||||
|
@ -191,8 +187,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoubleParameters() throws ServletRequestBindingException {
|
void testDoubleParameters() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
|
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
|
||||||
|
|
||||||
request.addParameter("param2", "1.5");
|
request.addParameter("param2", "1.5");
|
||||||
|
@ -206,8 +201,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBooleanParameter() throws ServletRequestBindingException {
|
void testBooleanParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "true");
|
request.addParameter("param1", "true");
|
||||||
request.addParameter("param2", "e");
|
request.addParameter("param2", "e");
|
||||||
request.addParameter("param4", "yes");
|
request.addParameter("param4", "yes");
|
||||||
|
@ -235,8 +229,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBooleanParameters() throws ServletRequestBindingException {
|
void testBooleanParameters() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param", new String[] {"true", "yes", "off", "1", "bogus"});
|
request.addParameter("param", new String[] {"true", "yes", "off", "1", "bogus"});
|
||||||
|
|
||||||
request.addParameter("param2", "false");
|
request.addParameter("param2", "false");
|
||||||
|
@ -259,8 +252,7 @@ public class ServletRequestUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringParameter() throws ServletRequestBindingException {
|
void testStringParameter() throws ServletRequestBindingException {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
request.addParameter("param1", "str");
|
request.addParameter("param1", "str");
|
||||||
request.addParameter("paramEmpty", "");
|
request.addParameter("paramEmpty", "");
|
||||||
|
|
||||||
|
@ -280,8 +272,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetIntParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetIntParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
@ -294,8 +285,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
@ -308,8 +298,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
@ -322,8 +311,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
@ -336,8 +324,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
@ -350,8 +337,7 @@ public class ServletRequestUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledForTestGroups(PERFORMANCE)
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
|
void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
|
||||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
sw.start();
|
sw.start();
|
||||||
for (int i = 0; i < 1000000; i++) {
|
for (int i = 0; i < 1000000; i++) {
|
||||||
|
|
Loading…
Reference in New Issue