1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+
16
17
package org .springframework .test .web .servlet ;
17
18
18
19
import java .util .concurrent .atomic .AtomicReference ;
19
20
20
21
import org .springframework .mock .web .MockHttpServletRequest ;
21
22
import org .springframework .mock .web .MockHttpServletResponse ;
22
- import org .springframework .util .Assert ;
23
23
import org .springframework .web .servlet .FlashMap ;
24
24
import org .springframework .web .servlet .HandlerInterceptor ;
25
25
import org .springframework .web .servlet .ModelAndView ;
@@ -60,55 +60,56 @@ public DefaultMvcResult(MockHttpServletRequest request, MockHttpServletResponse
60
60
this .mockResponse = response ;
61
61
}
62
62
63
- @ Override
64
- public MockHttpServletResponse getResponse () {
65
- return mockResponse ;
66
- }
67
63
68
64
@ Override
69
65
public MockHttpServletRequest getRequest () {
70
- return mockRequest ;
66
+ return this . mockRequest ;
71
67
}
72
68
73
69
@ Override
74
- public Object getHandler () {
75
- return this .handler ;
70
+ public MockHttpServletResponse getResponse () {
71
+ return this .mockResponse ;
76
72
}
77
73
78
74
public void setHandler (Object handler ) {
79
75
this .handler = handler ;
80
76
}
81
77
82
78
@ Override
83
- public HandlerInterceptor [] getInterceptors () {
84
- return this .interceptors ;
79
+ public Object getHandler () {
80
+ return this .handler ;
85
81
}
86
82
87
- public void setInterceptors (HandlerInterceptor [] interceptors ) {
83
+ public void setInterceptors (HandlerInterceptor ... interceptors ) {
88
84
this .interceptors = interceptors ;
89
85
}
90
86
91
87
@ Override
92
- public Exception getResolvedException () {
93
- return this .resolvedException ;
88
+ public HandlerInterceptor [] getInterceptors () {
89
+ return this .interceptors ;
94
90
}
95
91
96
92
public void setResolvedException (Exception resolvedException ) {
97
93
this .resolvedException = resolvedException ;
98
94
}
99
95
100
96
@ Override
101
- public ModelAndView getModelAndView () {
102
- return this .modelAndView ;
97
+ public Exception getResolvedException () {
98
+ return this .resolvedException ;
103
99
}
104
100
105
101
public void setModelAndView (ModelAndView mav ) {
106
102
this .modelAndView = mav ;
107
103
}
108
104
105
+ @ Override
106
+ public ModelAndView getModelAndView () {
107
+ return this .modelAndView ;
108
+ }
109
+
109
110
@ Override
110
111
public FlashMap getFlashMap () {
111
- return RequestContextUtils .getOutputFlashMap (mockRequest );
112
+ return RequestContextUtils .getOutputFlashMap (this . mockRequest );
112
113
}
113
114
114
115
public void setAsyncResult (Object asyncResult ) {
@@ -122,7 +123,6 @@ public Object getAsyncResult() {
122
123
123
124
@ Override
124
125
public Object getAsyncResult (long timeToWait ) {
125
-
126
126
if (this .mockRequest .getAsyncContext () != null ) {
127
127
timeToWait = (timeToWait == -1 ? this .mockRequest .getAsyncContext ().getTimeout () : timeToWait );
128
128
}
@@ -131,7 +131,7 @@ public Object getAsyncResult(long timeToWait) {
131
131
long endTime = System .currentTimeMillis () + timeToWait ;
132
132
while (System .currentTimeMillis () < endTime && this .asyncResult .get () == RESULT_NONE ) {
133
133
try {
134
- Thread .sleep (200 );
134
+ Thread .sleep (100 );
135
135
}
136
136
catch (InterruptedException ex ) {
137
137
throw new IllegalStateException ("Interrupted while waiting for " +
@@ -140,11 +140,12 @@ public Object getAsyncResult(long timeToWait) {
140
140
}
141
141
}
142
142
143
- Assert .state (this .asyncResult .get () != RESULT_NONE ,
144
- "Async result for handler [" + this .handler + "] " +
145
- "was not set during the specified timeToWait=" + timeToWait );
146
-
147
- return this .asyncResult .get ();
143
+ Object result = this .asyncResult .get ();
144
+ if (result == RESULT_NONE ) {
145
+ throw new IllegalStateException ("Async result for handler [" + this .handler + "] " +
146
+ "was not set during the specified timeToWait=" + timeToWait );
147
+ }
148
+ return result ;
148
149
}
149
150
150
151
}
0 commit comments