Skip to content

Commit 199aa77

Browse files
committed
Support for Servlet 4.0 (PushBuilder argument, MockServletContext)
Issue: SPR-12674
1 parent d44325e commit 199aa77

32 files changed

+237
-272
lines changed

spring-test/src/main/java/org/springframework/mock/web/MockBodyContent.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,9 +26,7 @@
2626

2727
/**
2828
* Mock implementation of the {@link javax.servlet.jsp.tagext.BodyContent} class.
29-
*
30-
* <p>Used for testing the web framework; only necessary for testing
31-
* applications when testing custom JSP tags.
29+
* Only necessary for testing applications when testing custom JSP tags.
3230
*
3331
* @author Juergen Hoeller
3432
* @since 2.5

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,14 +20,13 @@
2020
import javax.servlet.jsp.PageContext;
2121

2222
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
23+
2324
import org.springframework.util.Assert;
2425

2526
/**
2627
* Mock implementation of the JSP 2.0 {@link javax.servlet.jsp.el.ExpressionEvaluator}
2728
* interface, delegating to the Apache JSTL ExpressionEvaluatorManager.
28-
*
29-
* <p>Used for testing the web framework; only necessary for testing applications
30-
* when testing custom JSP tags.
29+
* Only necessary for testing applications when testing custom JSP tags.
3130
*
3231
* <p>Note that the Apache JSTL implementation (jstl.jar, standard.jar) has to be
3332
* available on the class path to use this expression evaluator.

spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,9 +33,7 @@
3333
import org.springframework.util.ObjectUtils;
3434

3535
/**
36-
* <p>Mock implementation of the {@link javax.servlet.FilterChain} interface. Used
37-
* for testing the web framework; also useful for testing custom
38-
* {@link javax.servlet.Filter} implementations.
36+
* Mock implementation of the {@link javax.servlet.FilterChain} interface.
3937
*
4038
* <p>A {@link MockFilterChain} can be configured with one or more filters and a
4139
* Servlet to invoke. The first time the chain is called, it invokes all filters

spring-test/src/main/java/org/springframework/mock/web/MockFilterConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
* is {@link Locale#ENGLISH}. This value can be changed via {@link #addPreferredLocale}
7171
* or {@link #setPreferredLocales}.
7272
*
73-
* <p>As of Spring Framework 5.0, this set of mocks is designed on a Servlet 3.1 baseline.
73+
* <p>As of Spring Framework 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
7474
*
7575
* @author Juergen Hoeller
7676
* @author Rod Johnson

spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
/**
4646
* Mock implementation of the {@link javax.servlet.http.HttpServletResponse} interface.
4747
*
48-
* <p>As of Spring Framework 5.0, this set of mocks is designed on a Servlet 3.1 baseline.
48+
* <p>As of Spring Framework 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
4949
*
5050
* @author Juergen Hoeller
5151
* @author Rod Johnson

spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,10 +34,7 @@
3434
/**
3535
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
3636
*
37-
* <p>As of Spring 4.0, this set of mocks is designed on a Servlet 3.0 baseline.
38-
*
39-
* <p>Used for testing the web framework; also useful for testing application
40-
* controllers.
37+
* <p>As of Spring 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
4138
*
4239
* @author Juergen Hoeller
4340
* @author Rod Johnson
@@ -72,7 +69,6 @@ public class MockHttpSession implements HttpSession {
7269

7370
/**
7471
* Create a new MockHttpSession with a default {@link MockServletContext}.
75-
*
7672
* @see MockServletContext
7773
*/
7874
public MockHttpSession() {
@@ -81,7 +77,6 @@ public MockHttpSession() {
8177

8278
/**
8379
* Create a new MockHttpSession.
84-
*
8580
* @param servletContext the ServletContext that the session runs in
8681
*/
8782
public MockHttpSession(ServletContext servletContext) {
@@ -90,7 +85,6 @@ public MockHttpSession(ServletContext servletContext) {
9085

9186
/**
9287
* Create a new MockHttpSession.
93-
*
9488
* @param servletContext the ServletContext that the session runs in
9589
* @param id a unique identifier for this session
9690
*/
@@ -99,6 +93,7 @@ public MockHttpSession(ServletContext servletContext, String id) {
9993
this.id = (id != null ? id : Integer.toString(nextId++));
10094
}
10195

96+
10297
@Override
10398
public long getCreationTime() {
10499
assertIsValid();
@@ -111,8 +106,8 @@ public String getId() {
111106
}
112107

113108
/**
114-
* As of Servlet 3.1 the id of a session can be changed.
115-
* @return the new session id.
109+
* As of Servlet 3.1, the id of a session can be changed.
110+
* @return the new session id
116111
* @since 4.0.3
117112
*/
118113
public String changeSessionId() {
@@ -227,7 +222,6 @@ public void clearAttributes() {
227222

228223
/**
229224
* Invalidates this session then unbinds any objects bound to it.
230-
*
231225
* @throws IllegalStateException if this method is called on an already invalidated session
232226
*/
233227
@Override
@@ -244,7 +238,6 @@ public boolean isInvalid() {
244238
/**
245239
* Convenience method for asserting that this session has not been
246240
* {@linkplain #invalidate() invalidated}.
247-
*
248241
* @throws IllegalStateException if this session has been invalidated
249242
*/
250243
private void assertIsValid() {
@@ -264,7 +257,6 @@ public boolean isNew() {
264257
/**
265258
* Serialize the attributes of this session into an object that can be
266259
* turned into a byte array with standard Java serialization.
267-
*
268260
* @return a representation of this session's serialized state
269261
*/
270262
public Serializable serializeState() {
@@ -291,7 +283,6 @@ public Serializable serializeState() {
291283
/**
292284
* Deserialize the attributes of this session from a state object created by
293285
* {@link #serializeState()}.
294-
*
295286
* @param state a representation of this session's serialized state
296287
*/
297288
@SuppressWarnings("unchecked")

spring-test/src/main/java/org/springframework/mock/web/MockJspWriter.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,9 +24,7 @@
2424

2525
/**
2626
* Mock implementation of the {@link javax.servlet.jsp.JspWriter} class.
27-
*
28-
* <p>Used for testing the web framework; only necessary for testing
29-
* applications when testing custom JSP tags.
27+
* Only necessary for testing applications when testing custom JSP tags.
3028
*
3129
* @author Juergen Hoeller
3230
* @since 2.5

spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,11 +35,10 @@
3535
* Mock implementation of the
3636
* {@link org.springframework.web.multipart.MultipartHttpServletRequest} interface.
3737
*
38-
* <p>As of Spring 4.0, this set of mocks is designed on a Servlet 3.0 baseline.
38+
* <p>As of Spring 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
3939
*
4040
* <p>Useful for testing application controllers that access multipart uploads.
41-
* The {@link MockMultipartFile} can be used to populate these mock requests
42-
* with files.
41+
* {@link MockMultipartFile} can be used to populate these mock requests with files.
4342
*
4443
* @author Juergen Hoeller
4544
* @author Eric Crampton
@@ -49,8 +48,7 @@
4948
*/
5049
public class MockMultipartHttpServletRequest extends MockHttpServletRequest implements MultipartHttpServletRequest {
5150

52-
private final MultiValueMap<String, MultipartFile> multipartFiles =
53-
new LinkedMultiValueMap<>();
51+
private final MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<>();
5452

5553

5654
/**

spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040

4141
/**
4242
* Mock implementation of the {@link javax.servlet.jsp.PageContext} interface.
43-
*
44-
* <p>Used for testing the web framework; only necessary for testing
45-
* applications when testing custom JSP tags.
43+
* Only necessary for testing applications when testing custom JSP tags.
4644
*
4745
* <p>Note: Expects initialization via the constructor rather than via the
4846
* {@code PageContext.initialize} method. Does not support writing to a

spring-test/src/main/java/org/springframework/mock/web/MockRequestDispatcher.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,9 +29,6 @@
2929
/**
3030
* Mock implementation of the {@link javax.servlet.RequestDispatcher} interface.
3131
*
32-
* <p>Used for testing the web framework; typically not necessary for
33-
* testing application controllers.
34-
*
3532
* @author Rod Johnson
3633
* @author Juergen Hoeller
3734
* @author Sam Brannen
@@ -50,7 +47,7 @@ public class MockRequestDispatcher implements RequestDispatcher {
5047
* particular path or given by a particular name
5148
*/
5249
public MockRequestDispatcher(String resource) {
53-
Assert.notNull(resource, "resource must not be null");
50+
Assert.notNull(resource, "Resource must not be null");
5451
this.resource = resource;
5552
}
5653

spring-test/src/main/java/org/springframework/mock/web/MockServletConfig.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,9 +28,6 @@
2828
/**
2929
* Mock implementation of the {@link javax.servlet.ServletConfig} interface.
3030
*
31-
* <p>Used for testing the web framework; typically not necessary for
32-
* testing application controllers.
33-
*
3431
* @author Rod Johnson
3532
* @author Juergen Hoeller
3633
* @since 1.0.2

0 commit comments

Comments
 (0)