@@ -23,10 +23,12 @@ import java.util.concurrent.TimeUnit
23
23
class PlayJavaWsClientTestBase extends PlayWsClientTestBaseBase<StandaloneWSRequest > {
24
24
@Shared
25
25
StandaloneWSClient wsClient
26
+ @Shared
27
+ StandaloneWSClient wsClientWithReadTimeout
26
28
27
29
@Override
28
30
StandaloneWSRequest buildRequest (String method , URI uri , Map<String , String > headers ) {
29
- def request = wsClient . url(uri. toURL(). toString()). setFollowRedirects(true )
31
+ def request = getClient(uri) . url(uri. toURL(). toString()). setFollowRedirects(true )
30
32
headers. entrySet(). each { entry -> request. addHeader(entry. getKey(), entry. getValue()) }
31
33
return request. setMethod(method)
32
34
}
@@ -43,22 +45,33 @@ class PlayJavaWsClientTestBase extends PlayWsClientTestBaseBase<StandaloneWSRequ
43
45
}
44
46
}
45
47
48
+ def getClient (URI uri ) {
49
+ if (uri. toString(). contains(" /read-timeout" )) {
50
+ return wsClientWithReadTimeout
51
+ }
52
+ return wsClient
53
+ }
54
+
46
55
def setupSpec () {
47
56
wsClient = new StandaloneAhcWSClient (asyncHttpClient, materializer)
57
+ wsClientWithReadTimeout = new StandaloneAhcWSClient (asyncHttpClientWithReadTimeout, materializer)
48
58
}
49
59
50
60
def cleanupSpec () {
51
61
wsClient?. close()
62
+ wsClientWithReadTimeout?. close()
52
63
}
53
64
}
54
65
55
66
class PlayJavaStreamedWsClientTestBase extends PlayWsClientTestBaseBase<StandaloneWSRequest > {
56
67
@Shared
57
68
StandaloneWSClient wsClient
69
+ @Shared
70
+ StandaloneWSClient wsClientWithReadTimeout
58
71
59
72
@Override
60
73
StandaloneWSRequest buildRequest (String method , URI uri , Map<String , String > headers ) {
61
- def request = wsClient . url(uri. toURL(). toString()). setFollowRedirects(true )
74
+ def request = getClient(uri) . url(uri. toURL(). toString()). setFollowRedirects(true )
62
75
headers. entrySet(). each { entry -> request. addHeader(entry. getKey(), entry. getValue()) }
63
76
request. setMethod(method)
64
77
return request
@@ -88,22 +101,33 @@ class PlayJavaStreamedWsClientTestBase extends PlayWsClientTestBaseBase<Standalo
88
101
}
89
102
}
90
103
104
+ def getClient (URI uri ) {
105
+ if (uri. toString(). contains(" /read-timeout" )) {
106
+ return wsClientWithReadTimeout
107
+ }
108
+ return wsClient
109
+ }
110
+
91
111
def setupSpec () {
92
112
wsClient = new StandaloneAhcWSClient (asyncHttpClient, materializer)
113
+ wsClientWithReadTimeout = new StandaloneAhcWSClient (asyncHttpClientWithReadTimeout, materializer)
93
114
}
94
115
95
116
def cleanupSpec () {
96
117
wsClient?. close()
118
+ wsClientWithReadTimeout?. close()
97
119
}
98
120
}
99
121
100
122
class PlayScalaWsClientTestBase extends PlayWsClientTestBaseBase<play.api.libs.ws. StandaloneWSRequest > {
101
123
@Shared
102
124
play.api.libs.ws.StandaloneWSClient wsClient
125
+ @Shared
126
+ play.api.libs.ws.StandaloneWSClient wsClientWithReadTimeout
103
127
104
128
@Override
105
129
play.api.libs.ws.StandaloneWSRequest buildRequest (String method , URI uri , Map<String , String > headers ) {
106
- return wsClient . url(uri. toURL(). toString())
130
+ return getClient(uri) . url(uri. toURL(). toString())
107
131
.withMethod(method)
108
132
.withFollowRedirects(true )
109
133
.withHttpHeaders(JavaConverters . mapAsScalaMap(headers). toSeq())
@@ -135,22 +159,33 @@ class PlayScalaWsClientTestBase extends PlayWsClientTestBaseBase<play.api.libs.w
135
159
}, ExecutionContext . global())
136
160
}
137
161
162
+ def getClient (URI uri ) {
163
+ if (uri. toString(). contains(" /read-timeout" )) {
164
+ return wsClientWithReadTimeout
165
+ }
166
+ return wsClient
167
+ }
168
+
138
169
def setupSpec () {
139
170
wsClient = new play.api.libs.ws.ahc.StandaloneAhcWSClient (asyncHttpClient, materializer)
171
+ wsClientWithReadTimeout = new play.api.libs.ws.ahc.StandaloneAhcWSClient (asyncHttpClientWithReadTimeout, materializer)
140
172
}
141
173
142
174
def cleanupSpec () {
143
175
wsClient?. close()
176
+ wsClientWithReadTimeout?. close()
144
177
}
145
178
}
146
179
147
180
class PlayScalaStreamedWsClientTestBase extends PlayWsClientTestBaseBase<play.api.libs.ws. StandaloneWSRequest > {
148
181
@Shared
149
182
play.api.libs.ws.StandaloneWSClient wsClient
183
+ @Shared
184
+ play.api.libs.ws.StandaloneWSClient wsClientWithReadTimeout
150
185
151
186
@Override
152
187
play.api.libs.ws.StandaloneWSRequest buildRequest (String method , URI uri , Map<String , String > headers ) {
153
- return wsClient . url(uri. toURL(). toString())
188
+ return getClient(uri) . url(uri. toURL(). toString())
154
189
.withMethod(method)
155
190
.withFollowRedirects(true )
156
191
.withHttpHeaders(JavaConverters . mapAsScalaMap(headers). toSeq())
@@ -193,11 +228,20 @@ class PlayScalaStreamedWsClientTestBase extends PlayWsClientTestBaseBase<play.ap
193
228
}, ExecutionContext . global())
194
229
}
195
230
231
+ def getClient (URI uri ) {
232
+ if (uri. toString(). contains(" /read-timeout" )) {
233
+ return wsClientWithReadTimeout
234
+ }
235
+ return wsClient
236
+ }
237
+
196
238
def setupSpec () {
197
239
wsClient = new play.api.libs.ws.ahc.StandaloneAhcWSClient (asyncHttpClient, materializer)
240
+ wsClientWithReadTimeout = new play.api.libs.ws.ahc.StandaloneAhcWSClient (asyncHttpClientWithReadTimeout, materializer)
198
241
}
199
242
200
243
def cleanupSpec () {
201
244
wsClient?. close()
245
+ wsClientWithReadTimeout?. close()
202
246
}
203
247
}
0 commit comments