Skip to content

Commit 6926e0f

Browse files
committed
Suppressing warnings, polishing JavaDoc, etc.
1 parent e7c2713 commit 6926e0f

File tree

41 files changed

+404
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+404
-364
lines changed

org.springframework.test/src/main/java/org/springframework/mock/web/MockExpressionEvaluator.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,55 +27,59 @@
2727
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
2828

2929
/**
30-
* Mock implementation of the JSP 2.0 {@link javax.servlet.jsp.el.ExpressionEvaluator}
31-
* interface, delegating to the Jakarta JSTL ExpressionEvaluatorManager.
32-
*
33-
* <p>Used for testing the web framework; only necessary for testing
34-
* applications when testing custom JSP tags.
35-
*
36-
* <p>Note that the Jakarta JSTL implementation (jstl.jar, standard.jar)
37-
* has to be available on the class path to use this expression evaluator.
38-
*
30+
* Mock implementation of the JSP 2.0
31+
* {@link javax.servlet.jsp.el.ExpressionEvaluator} interface, delegating to the
32+
* Jakarta JSTL ExpressionEvaluatorManager.
33+
* <p>
34+
* Used for testing the web framework; only necessary for testing applications
35+
* when testing custom JSP tags.
36+
* <p>
37+
* Note that the Jakarta JSTL implementation (jstl.jar, standard.jar) has to be
38+
* available on the class path to use this expression evaluator.
39+
*
3940
* @author Juergen Hoeller
4041
* @since 1.1.5
4142
* @see org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager
4243
*/
44+
@SuppressWarnings("deprecation")
4345
public class MockExpressionEvaluator extends ExpressionEvaluator {
4446

4547
private final PageContext pageContext;
4648

4749

4850
/**
4951
* Create a new MockExpressionEvaluator for the given PageContext.
52+
*
5053
* @param pageContext the JSP PageContext to run in
5154
*/
5255
public MockExpressionEvaluator(PageContext pageContext) {
5356
this.pageContext = pageContext;
5457
}
5558

56-
public Expression parseExpression(
57-
final String expression, final Class expectedType, final FunctionMapper functionMapper)
58-
throws ELException {
59+
@SuppressWarnings("rawtypes")
60+
public Expression parseExpression(final String expression, final Class expectedType,
61+
final FunctionMapper functionMapper) throws ELException {
5962

6063
return new Expression() {
64+
6165
public Object evaluate(VariableResolver variableResolver) throws ELException {
6266
return doEvaluate(expression, expectedType, functionMapper);
6367
}
6468
};
6569
}
6670

67-
public Object evaluate(
68-
String expression, Class expectedType, VariableResolver variableResolver, FunctionMapper functionMapper)
69-
throws ELException {
71+
@SuppressWarnings("rawtypes")
72+
public Object evaluate(String expression, Class expectedType, VariableResolver variableResolver,
73+
FunctionMapper functionMapper) throws ELException {
7074

7175
if (variableResolver != null) {
7276
throw new IllegalArgumentException("Custom VariableResolver not supported");
7377
}
7478
return doEvaluate(expression, expectedType, functionMapper);
7579
}
7680

77-
protected Object doEvaluate(
78-
String expression, Class expectedType, FunctionMapper functionMapper)
81+
@SuppressWarnings("rawtypes")
82+
protected Object doEvaluate(String expression, Class expectedType, FunctionMapper functionMapper)
7983
throws ELException {
8084

8185
if (functionMapper != null) {

org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.Map;
3636
import java.util.Set;
3737
import java.util.Vector;
38+
3839
import javax.servlet.RequestDispatcher;
3940
import javax.servlet.ServletContext;
4041
import javax.servlet.ServletInputStream;
@@ -48,10 +49,10 @@
4849
/**
4950
* Mock implementation of the {@link javax.servlet.http.HttpServletRequest}
5051
* interface. Supports the Servlet 2.5 API level.
51-
*
52-
* <p>Used for testing the web framework; also useful for testing
53-
* application controllers.
54-
*
52+
* <p>
53+
* Used for testing the web framework; also useful for testing application
54+
* controllers.
55+
*
5556
* @author Juergen Hoeller
5657
* @author Rod Johnson
5758
* @author Rick Evans
@@ -90,13 +91,11 @@ public class MockHttpServletRequest implements HttpServletRequest {
9091
*/
9192
public static final String DEFAULT_REMOTE_HOST = "localhost";
9293

93-
9494
private boolean active = true;
9595

96-
97-
//---------------------------------------------------------------------
96+
// ---------------------------------------------------------------------
9897
// ServletRequest properties
99-
//---------------------------------------------------------------------
98+
// ---------------------------------------------------------------------
10099

101100
private final Map<String, Object> attributes = new LinkedHashMap<String, Object>();
102101

@@ -135,10 +134,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
135134

136135
private int localPort = DEFAULT_SERVER_PORT;
137136

138-
139-
//---------------------------------------------------------------------
137+
// ---------------------------------------------------------------------
140138
// HttpServletRequest properties
141-
//---------------------------------------------------------------------
139+
// ---------------------------------------------------------------------
142140

143141
private String authType;
144142

@@ -175,13 +173,14 @@ public class MockHttpServletRequest implements HttpServletRequest {
175173
private boolean requestedSessionIdFromURL = false;
176174

177175

178-
//---------------------------------------------------------------------
176+
// ---------------------------------------------------------------------
179177
// Constructors
180-
//---------------------------------------------------------------------
178+
// ---------------------------------------------------------------------
181179

182180
/**
183181
* Create a new MockHttpServletRequest with a default
184182
* {@link MockServletContext}.
183+
*
185184
* @see MockServletContext
186185
*/
187186
public MockHttpServletRequest() {
@@ -191,6 +190,7 @@ public MockHttpServletRequest() {
191190
/**
192191
* Create a new MockHttpServletRequest with a default
193192
* {@link MockServletContext}.
193+
*
194194
* @param method the request method (may be <code>null</code>)
195195
* @param requestURI the request URI (may be <code>null</code>)
196196
* @see #setMethod
@@ -203,8 +203,9 @@ public MockHttpServletRequest(String method, String requestURI) {
203203

204204
/**
205205
* Create a new MockHttpServletRequest.
206-
* @param servletContext the ServletContext that the request runs in
207-
* (may be <code>null</code> to use a default MockServletContext)
206+
*
207+
* @param servletContext the ServletContext that the request runs in (may be
208+
* <code>null</code> to use a default MockServletContext)
208209
* @see MockServletContext
209210
*/
210211
public MockHttpServletRequest(ServletContext servletContext) {
@@ -213,8 +214,9 @@ public MockHttpServletRequest(ServletContext servletContext) {
213214

214215
/**
215216
* Create a new MockHttpServletRequest.
216-
* @param servletContext the ServletContext that the request runs in
217-
* (may be <code>null</code> to use a default MockServletContext)
217+
*
218+
* @param servletContext the ServletContext that the request runs in (may be
219+
* <code>null</code> to use a default MockServletContext)
218220
* @param method the request method (may be <code>null</code>)
219221
* @param requestURI the request URI (may be <code>null</code>)
220222
* @see #setMethod
@@ -228,14 +230,13 @@ public MockHttpServletRequest(ServletContext servletContext, String method, Stri
228230
this.locales.add(Locale.ENGLISH);
229231
}
230232

231-
232-
//---------------------------------------------------------------------
233+
// ---------------------------------------------------------------------
233234
// Lifecycle methods
234-
//---------------------------------------------------------------------
235+
// ---------------------------------------------------------------------
235236

236237
/**
237-
* Return the ServletContext that this request is associated with.
238-
* (Not available in the standard HttpServletRequest interface for some reason.)
238+
* Return the ServletContext that this request is associated with. (Not
239+
* available in the standard HttpServletRequest interface for some reason.)
239240
*/
240241
public ServletContext getServletContext() {
241242
return this.servletContext;
@@ -273,10 +274,9 @@ protected void checkActive() throws IllegalStateException {
273274
}
274275
}
275276

276-
277-
//---------------------------------------------------------------------
277+
// ---------------------------------------------------------------------
278278
// ServletRequest interface
279-
//---------------------------------------------------------------------
279+
// ---------------------------------------------------------------------
280280

281281
public Object getAttribute(String name) {
282282
checkActive();
@@ -323,16 +323,18 @@ public ServletInputStream getInputStream() {
323323

324324
/**
325325
* Set a single value for the specified HTTP parameter.
326-
* <p>If there are already one or more values registered for the given
326+
* <p>
327+
* If there are already one or more values registered for the given
327328
* parameter name, they will be replaced.
328329
*/
329330
public void setParameter(String name, String value) {
330-
setParameter(name, new String[] {value});
331+
setParameter(name, new String[] { value });
331332
}
332333

333334
/**
334335
* Set an array of values for the specified HTTP parameter.
335-
* <p>If there are already one or more values registered for the given
336+
* <p>
337+
* If there are already one or more values registered for the given
336338
* parameter name, they will be replaced.
337339
*/
338340
public void setParameter(String name, String[] values) {
@@ -341,15 +343,15 @@ public void setParameter(String name, String[] values) {
341343
}
342344

343345
/**
344-
* Sets all provided parameters <emphasis>replacing</emphasis> any
345-
* existing values for the provided parameter names. To add without
346-
* replacing existing values, use {@link #addParameters(java.util.Map)}.
346+
* Sets all provided parameters <emphasis>replacing</emphasis> any existing
347+
* values for the provided parameter names. To add without replacing
348+
* existing values, use {@link #addParameters(java.util.Map)}.
347349
*/
350+
@SuppressWarnings("rawtypes")
348351
public void setParameters(Map params) {
349352
Assert.notNull(params, "Parameter map must not be null");
350353
for (Object key : params.keySet()) {
351-
Assert.isInstanceOf(String.class, key,
352-
"Parameter map key must be of type [" + String.class.getName() + "]");
354+
Assert.isInstanceOf(String.class, key, "Parameter map key must be of type [" + String.class.getName() + "]");
353355
Object value = params.get(key);
354356
if (value instanceof String) {
355357
this.setParameter((String) key, (String) value);
@@ -358,25 +360,26 @@ else if (value instanceof String[]) {
358360
this.setParameter((String) key, (String[]) value);
359361
}
360362
else {
361-
throw new IllegalArgumentException(
362-
"Parameter map value must be single value " + " or array of type [" + String.class.getName() +
363-
"]");
363+
throw new IllegalArgumentException("Parameter map value must be single value " + " or array of type ["
364+
+ String.class.getName() + "]");
364365
}
365366
}
366367
}
367368

368369
/**
369370
* Add a single value for the specified HTTP parameter.
370-
* <p>If there are already one or more values registered for the given
371+
* <p>
372+
* If there are already one or more values registered for the given
371373
* parameter name, the given value will be added to the end of the list.
372374
*/
373375
public void addParameter(String name, String value) {
374-
addParameter(name, new String[] {value});
376+
addParameter(name, new String[] { value });
375377
}
376378

377379
/**
378380
* Add an array of values for the specified HTTP parameter.
379-
* <p>If there are already one or more values registered for the given
381+
* <p>
382+
* If there are already one or more values registered for the given
380383
* parameter name, the given values will be added to the end of the list.
381384
*/
382385
public void addParameter(String name, String[] values) {
@@ -394,15 +397,15 @@ public void addParameter(String name, String[] values) {
394397
}
395398

396399
/**
397-
* Adds all provided parameters <emphasis>without</emphasis> replacing
398-
* any existing values. To replace existing values, use
400+
* Adds all provided parameters <emphasis>without</emphasis> replacing any
401+
* existing values. To replace existing values, use
399402
* {@link #setParameters(java.util.Map)}.
400403
*/
404+
@SuppressWarnings("rawtypes")
401405
public void addParameters(Map params) {
402406
Assert.notNull(params, "Parameter map must not be null");
403407
for (Object key : params.keySet()) {
404-
Assert.isInstanceOf(String.class, key,
405-
"Parameter map key must be of type [" + String.class.getName() + "]");
408+
Assert.isInstanceOf(String.class, key, "Parameter map key must be of type [" + String.class.getName() + "]");
406409
Object value = params.get(key);
407410
if (value instanceof String) {
408411
this.addParameter((String) key, (String) value);
@@ -411,14 +414,15 @@ else if (value instanceof String[]) {
411414
this.addParameter((String) key, (String[]) value);
412415
}
413416
else {
414-
throw new IllegalArgumentException("Parameter map value must be single value " +
415-
" or array of type [" + String.class.getName() + "]");
417+
throw new IllegalArgumentException("Parameter map value must be single value " + " or array of type ["
418+
+ String.class.getName() + "]");
416419
}
417420
}
418421
}
419422

420423
/**
421-
* Remove already registered values for the specified HTTP parameter, if any.
424+
* Remove already registered values for the specified HTTP parameter, if
425+
* any.
422426
*/
423427
public void removeParameter(String name) {
424428
Assert.notNull(name, "Parameter name must not be null");
@@ -486,8 +490,8 @@ public int getServerPort() {
486490
public BufferedReader getReader() throws UnsupportedEncodingException {
487491
if (this.content != null) {
488492
InputStream sourceStream = new ByteArrayInputStream(this.content);
489-
Reader sourceReader = (this.characterEncoding != null) ?
490-
new InputStreamReader(sourceStream, this.characterEncoding) : new InputStreamReader(sourceStream);
493+
Reader sourceReader = (this.characterEncoding != null) ? new InputStreamReader(sourceStream,
494+
this.characterEncoding) : new InputStreamReader(sourceStream);
491495
return new BufferedReader(sourceReader);
492496
}
493497
else {
@@ -599,10 +603,9 @@ public int getLocalPort() {
599603
return this.localPort;
600604
}
601605

602-
603-
//---------------------------------------------------------------------
606+
// ---------------------------------------------------------------------
604607
// HttpServletRequest interface
605-
//---------------------------------------------------------------------
608+
// ---------------------------------------------------------------------
606609

607610
public void setAuthType(String authType) {
608611
this.authType = authType;
@@ -622,21 +625,25 @@ public Cookie[] getCookies() {
622625

623626
/**
624627
* Add a header entry for the given name.
625-
* <p>If there was no entry for that header name before,
626-
* the value will be used as-is. In case of an existing entry,
627-
* a String array will be created, adding the given value (more
628-
* specifically, its toString representation) as further element.
629-
* <p>Multiple values can only be stored as list of Strings,
630-
* following the Servlet spec (see <code>getHeaders</code> accessor).
631-
* As alternative to repeated <code>addHeader</code> calls for
632-
* individual elements, you can use a single call with an entire
633-
* array or Collection of values as parameter.
628+
* <p>
629+
* If there was no entry for that header name before, the value will be used
630+
* as-is. In case of an existing entry, a String array will be created,
631+
* adding the given value (more specifically, its toString representation)
632+
* as further element.
633+
* <p>
634+
* Multiple values can only be stored as list of Strings, following the
635+
* Servlet spec (see <code>getHeaders</code> accessor). As alternative to
636+
* repeated <code>addHeader</code> calls for individual elements, you can
637+
* use a single call with an entire array or Collection of values as
638+
* parameter.
639+
*
634640
* @see #getHeaderNames
635641
* @see #getHeader
636642
* @see #getHeaders
637643
* @see #getDateHeader
638644
* @see #getIntHeader
639645
*/
646+
@SuppressWarnings("rawtypes")
640647
public void addHeader(String name, Object value) {
641648
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
642649
Assert.notNull(value, "Header value must not be null");
@@ -665,8 +672,8 @@ else if (value instanceof Number) {
665672
return ((Number) value).longValue();
666673
}
667674
else if (value != null) {
668-
throw new IllegalArgumentException(
669-
"Value for header '" + name + "' is neither a Date nor a Number: " + value);
675+
throw new IllegalArgumentException("Value for header '" + name + "' is neither a Date nor a Number: "
676+
+ value);
670677
}
671678
else {
672679
return -1L;

0 commit comments

Comments
 (0)