@@ -24,7 +24,13 @@ import org.slf4j.{ Logger => Underlying }
24
24
import org .scalatest .{ Matchers , WordSpec }
25
25
import org .scalatest .mockito .MockitoSugar
26
26
27
- class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
27
+ trait Varargs {
28
+ // TODO: we used to wrap in List(...): _*, which I assume was to force the varags method to be chosen.
29
+ // I encapsulated that here in something that works across 2.12/2.13.
30
+ def forceVarargs [T ](xs : T * ): scala.Seq [T ] = scala.Seq (xs : _* )
31
+ }
32
+
33
+ class LoggerSpec extends WordSpec with Matchers with MockitoSugar with Varargs {
28
34
29
35
// Error
30
36
@@ -58,7 +64,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
58
64
val f = fixture(_.isErrorEnabled, isEnabled = true )
59
65
import f ._
60
66
logger.error(s " msg $arg1 $arg2" )
61
- verify(underlying).error(" msg {} {}" , List (arg1, arg2): _* )
67
+ verify(underlying).error(" msg {} {}" , forceVarargs (arg1, arg2): _* )
62
68
}
63
69
64
70
}
@@ -86,9 +92,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
86
92
val f = fixture(_.isErrorEnabled, isEnabled = true )
87
93
import f ._
88
94
logger.error(msg, arg1)
89
- verify(underlying).error(msg, List ( arg1) : _* )
95
+ verify(underlying).error(msg, arg1)
90
96
logger.error(msg, arg1, arg2)
91
- verify(underlying).error(msg, List (arg1, arg2): _* )
97
+ verify(underlying).error(msg, forceVarargs (arg1, arg2): _* )
92
98
logger.error(msg, arg1, arg2, arg3)
93
99
verify(underlying).error(msg, arg1, arg2, arg3)
94
100
}
@@ -97,9 +103,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
97
103
val f = fixture(_.isErrorEnabled, isEnabled = false )
98
104
import f ._
99
105
logger.error(msg, arg1)
100
- verify(underlying, never).error(msg, List ( arg1) : _* )
106
+ verify(underlying, never).error(msg, arg1)
101
107
logger.error(msg, arg1, arg2)
102
- verify(underlying, never).error(msg, List (arg1, arg2): _* )
108
+ verify(underlying, never).error(msg, forceVarargs (arg1, arg2): _* )
103
109
logger.error(msg, arg1, arg2, arg3)
104
110
verify(underlying, never).error(msg, arg1, arg2, arg3)
105
111
}
@@ -137,7 +143,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
137
143
val f = fixture(_.isWarnEnabled, isEnabled = true )
138
144
import f ._
139
145
logger.warn(s " msg $arg1 $arg2" )
140
- verify(underlying).warn(" msg {} {}" , List (arg1, arg2): _* )
146
+ verify(underlying).warn(" msg {} {}" , forceVarargs (arg1, arg2): _* )
141
147
}
142
148
}
143
149
@@ -164,9 +170,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
164
170
val f = fixture(_.isWarnEnabled, isEnabled = true )
165
171
import f ._
166
172
logger.warn(msg, arg1)
167
- verify(underlying).warn(msg, List ( arg1) : _* )
173
+ verify(underlying).warn(msg, arg1)
168
174
logger.warn(msg, arg1, arg2)
169
- verify(underlying).warn(msg, List (arg1, arg2): _* )
175
+ verify(underlying).warn(msg, forceVarargs (arg1, arg2): _* )
170
176
logger.warn(msg, arg1, arg2, arg3)
171
177
verify(underlying).warn(msg, arg1, arg2, arg3)
172
178
}
@@ -175,9 +181,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
175
181
val f = fixture(_.isWarnEnabled, isEnabled = false )
176
182
import f ._
177
183
logger.warn(msg, arg1)
178
- verify(underlying, never).warn(msg, List ( arg1) : _* )
184
+ verify(underlying, never).warn(msg, arg1)
179
185
logger.warn(msg, arg1, arg2)
180
- verify(underlying, never).warn(msg, List (arg1, arg2): _* )
186
+ verify(underlying, never).warn(msg, forceVarargs (arg1, arg2): _* )
181
187
logger.warn(msg, arg1, arg2, arg3)
182
188
verify(underlying, never).warn(msg, arg1, arg2, arg3)
183
189
}
@@ -215,7 +221,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
215
221
val f = fixture(_.isInfoEnabled, isEnabled = true )
216
222
import f ._
217
223
logger.info(s " msg $arg1 $arg2" )
218
- verify(underlying).info(" msg {} {}" , List (arg1, arg2): _* )
224
+ verify(underlying).info(" msg {} {}" , forceVarargs (arg1, arg2): _* )
219
225
}
220
226
}
221
227
@@ -242,9 +248,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
242
248
val f = fixture(_.isInfoEnabled, isEnabled = true )
243
249
import f ._
244
250
logger.info(msg, arg1)
245
- verify(underlying).info(msg, List ( arg1) : _* )
251
+ verify(underlying).info(msg, arg1)
246
252
logger.info(msg, arg1, arg2)
247
- verify(underlying).info(msg, List (arg1, arg2): _* )
253
+ verify(underlying).info(msg, forceVarargs (arg1, arg2): _* )
248
254
logger.info(msg, arg1, arg2, arg3)
249
255
verify(underlying).info(msg, arg1, arg2, arg3)
250
256
}
@@ -253,9 +259,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
253
259
val f = fixture(_.isInfoEnabled, isEnabled = false )
254
260
import f ._
255
261
logger.info(msg, arg1)
256
- verify(underlying, never).info(msg, List ( arg1) : _* )
262
+ verify(underlying, never).info(msg, arg1)
257
263
logger.info(msg, arg1, arg2)
258
- verify(underlying, never).info(msg, List (arg1, arg2): _* )
264
+ verify(underlying, never).info(msg, forceVarargs (arg1, arg2): _* )
259
265
logger.info(msg, arg1, arg2, arg3)
260
266
verify(underlying, never).info(msg, arg1, arg2, arg3)
261
267
}
@@ -292,7 +298,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
292
298
val f = fixture(_.isDebugEnabled, isEnabled = true )
293
299
import f ._
294
300
logger.debug(s " msg $arg1 $arg2" )
295
- verify(underlying).debug(" msg {} {}" , List (arg1, arg2): _* )
301
+ verify(underlying).debug(" msg {} {}" , forceVarargs (arg1, arg2): _* )
296
302
}
297
303
}
298
304
@@ -319,9 +325,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
319
325
val f = fixture(_.isDebugEnabled, isEnabled = true )
320
326
import f ._
321
327
logger.debug(msg, arg1)
322
- verify(underlying).debug(msg, List ( arg1) : _* )
328
+ verify(underlying).debug(msg, arg1)
323
329
logger.debug(msg, arg1, arg2)
324
- verify(underlying).debug(msg, List (arg1, arg2): _* )
330
+ verify(underlying).debug(msg, forceVarargs (arg1, arg2): _* )
325
331
logger.debug(msg, arg1, arg2, arg3)
326
332
verify(underlying).debug(msg, arg1, arg2, arg3)
327
333
}
@@ -330,9 +336,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
330
336
val f = fixture(_.isDebugEnabled, isEnabled = false )
331
337
import f ._
332
338
logger.debug(msg, arg1)
333
- verify(underlying, never).debug(msg, List ( arg1) : _* )
339
+ verify(underlying, never).debug(msg, arg1)
334
340
logger.debug(msg, arg1, arg2)
335
- verify(underlying, never).debug(msg, List (arg1, arg2): _* )
341
+ verify(underlying, never).debug(msg, forceVarargs (arg1, arg2): _* )
336
342
logger.debug(msg, arg1, arg2, arg3)
337
343
verify(underlying, never).debug(msg, arg1, arg2, arg3)
338
344
}
@@ -370,7 +376,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
370
376
val f = fixture(_.isTraceEnabled, isEnabled = true )
371
377
import f ._
372
378
logger.trace(s " msg $arg1 $arg2" )
373
- verify(underlying).trace(" msg {} {}" , List (arg1, arg2): _* )
379
+ verify(underlying).trace(" msg {} {}" , forceVarargs (arg1, arg2): _* )
374
380
}
375
381
}
376
382
@@ -397,9 +403,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
397
403
val f = fixture(_.isTraceEnabled, isEnabled = true )
398
404
import f ._
399
405
logger.trace(msg, arg1)
400
- verify(underlying).trace(msg, List ( arg1) : _* )
406
+ verify(underlying).trace(msg, arg1)
401
407
logger.trace(msg, arg1, arg2)
402
- verify(underlying).trace(msg, List (arg1, arg2): _* )
408
+ verify(underlying).trace(msg, forceVarargs (arg1, arg2): _* )
403
409
logger.trace(msg, arg1, arg2, arg3)
404
410
verify(underlying).trace(msg, arg1, arg2, arg3)
405
411
}
@@ -408,9 +414,9 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
408
414
val f = fixture(_.isTraceEnabled, isEnabled = false )
409
415
import f ._
410
416
logger.trace(msg, arg1)
411
- verify(underlying, never).trace(msg, List ( arg1) : _* )
417
+ verify(underlying, never).trace(msg, arg1)
412
418
logger.trace(msg, arg1, arg2)
413
- verify(underlying, never).trace(msg, List (arg1, arg2): _* )
419
+ verify(underlying, never).trace(msg, forceVarargs (arg1, arg2): _* )
414
420
logger.trace(msg, arg1, arg2, arg3)
415
421
verify(underlying, never).trace(msg, arg1, arg2, arg3)
416
422
}
@@ -468,7 +474,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
468
474
val f = fixture(_.isErrorEnabled, isEnabled = true )
469
475
import f ._
470
476
logger.error(" foo {}, bar {}" , arg4, arg5)
471
- verify(underlying).error(" foo {}, bar {}" , Array (arg4ref, arg5ref): _* )
477
+ verify(underlying).error(" foo {}, bar {}" , forceVarargs (arg4ref, arg5ref): _* )
472
478
}
473
479
474
480
" map args to AnyRef for non 2 args" in {
0 commit comments