@@ -4,7 +4,8 @@ import java.util.Random
4
4
import java .util .concurrent .atomic .{AtomicBoolean , AtomicInteger , AtomicLong }
5
5
6
6
import odelay .Timer
7
- import org .scalatest .{AsyncFunSpec , BeforeAndAfterAll }
7
+ import org .scalatest .BeforeAndAfterAll
8
+ import org .scalatest .funspec .AsyncFunSpec
8
9
9
10
import scala .collection .compat .immutable .LazyList
10
11
import scala .concurrent .Future
@@ -101,7 +102,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
101
102
Future (true )
102
103
}
103
104
val policy = Directly .forever
104
- policy(run).map { result =>
105
+ policy(run() ).map { result =>
105
106
assert(result === true )
106
107
assert(retried.get() == 10000 )
107
108
}
@@ -135,7 +136,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
135
136
Future (true )
136
137
}
137
138
val policy = Pause .forever(1 .millis)
138
- policy(run).map { result =>
139
+ policy(run() ).map { result =>
139
140
assert(result === true )
140
141
assert(retried.get() == 1000 )
141
142
}
@@ -168,7 +169,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
168
169
Future (true )
169
170
}
170
171
val policy = Backoff .forever(1 .millis)
171
- policy(run).map { result =>
172
+ policy(run() ).map { result =>
172
173
assert(result === true )
173
174
assert(retried.get() == 5 )
174
175
}
@@ -181,15 +182,15 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
181
182
182
183
it(" should retry a future for a specified number of times" ) {
183
184
implicit val success = Success [Int ](_ == 3 )
184
- implicit val algo = algoCreator(10 .millis)
185
+ implicit val algo : Jitter = algoCreator(10 .millis)
185
186
val tries = forwardCountingFutureStream().iterator
186
187
val policy = JitterBackoff (3 , 1 .milli)
187
188
policy(tries.next).map(result =>
188
189
assert(success.predicate(result) === true ))
189
190
}
190
191
191
192
it(" should fail when expected" ) {
192
- implicit val algo = algoCreator(10 .millis)
193
+ implicit val algo : Jitter = algoCreator(10 .millis)
193
194
val success = implicitly[Success [Option [Int ]]]
194
195
val tries = Future (None : Option [Int ])
195
196
val policy = JitterBackoff (3 , 1 .milli)
@@ -200,7 +201,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
200
201
201
202
it(" should deal with future failures" ) {
202
203
implicit val success = Success .always
203
- implicit val algo = algoCreator(10 .millis)
204
+ implicit val algo : Jitter = algoCreator(10 .millis)
204
205
val policy = JitterBackoff (3 , 5 .millis)
205
206
val counter = new AtomicInteger ()
206
207
val future = policy { () =>
@@ -213,7 +214,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
213
214
214
215
it(" should retry futures passed by-name instead of caching results" ) {
215
216
implicit val success = Success .always
216
- implicit val algo = algoCreator(10 .millis)
217
+ implicit val algo : Jitter = algoCreator(10 .millis)
217
218
val counter = new AtomicInteger ()
218
219
val policy = JitterBackoff (1 , 1 .milli)
219
220
val future = policy {
@@ -227,7 +228,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
227
228
228
229
it(" should pause with multiplier and jitter between retries" ) {
229
230
implicit val success = Success [Int ](_ == 2 )
230
- implicit val algo = algoCreator(1000 .millis)
231
+ implicit val algo : Jitter = algoCreator(1000 .millis)
231
232
val tries = forwardCountingFutureStream().iterator
232
233
val policy = JitterBackoff (5 , 50 .millis)
233
234
val marker_base = System .currentTimeMillis
@@ -242,7 +243,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
242
243
243
244
it(" should also work when invoked as forever" ) {
244
245
implicit val success = Success [Int ](_ == 5 )
245
- implicit val algo = algoCreator(1000 .millis)
246
+ implicit val algo : Jitter = algoCreator(1000 .millis)
246
247
val tries = forwardCountingFutureStream().iterator
247
248
val policy = JitterBackoff .forever(50 .millis)
248
249
val marker_base = System .currentTimeMillis
@@ -267,7 +268,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
267
268
Future (true )
268
269
}
269
270
val policy = JitterBackoff .forever(1 .millis)
270
- policy(run).map { result =>
271
+ policy(run() ).map { result =>
271
272
assert(result === true )
272
273
assert(retried.get() == 10 )
273
274
}
@@ -325,7 +326,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
325
326
// lift an exception into a new policy
326
327
case RetryAfter (duration) => Pause (delay = duration)
327
328
}
328
- policy(run).map(result => assert(result === true ))
329
+ policy(run() ).map(result => assert(result === true ))
329
330
}
330
331
331
332
it(" should repeat on failure until success" ) {
@@ -344,7 +345,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
344
345
// lift an exception into a new policy
345
346
case _ : MyException => Directly .forever
346
347
}
347
- policy(run).map { result =>
348
+ policy(run() ).map { result =>
348
349
assert(result === true )
349
350
assert(retried.get() == 10000 )
350
351
}
@@ -367,7 +368,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
367
368
case _ : MyException => Pause .forever(1 .millis)
368
369
369
370
}
370
- policy(run).map { result =>
371
+ policy(run() ).map { result =>
371
372
assert(result === true )
372
373
assert(retried.get() == 1000 )
373
374
}
@@ -389,7 +390,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
389
390
// lift an exception into a new policy
390
391
case _ : MyException => Backoff .forever(1 .millis)
391
392
}
392
- policy(run).map { result =>
393
+ policy(run() ).map { result =>
393
394
assert(result === true )
394
395
assert(retried.get() == 5 )
395
396
}
@@ -411,7 +412,7 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
411
412
// lift an exception into a new policy
412
413
case _ : MyException => JitterBackoff .forever(1 .millis)
413
414
}
414
- policy(run).map { result =>
415
+ policy(run() ).map { result =>
415
416
assert(result === true )
416
417
assert(retried.get() == 10 )
417
418
}
0 commit comments