| 1 |
/* |
| 2 |
* Copyright (c) 2021 Goldman Sachs and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* and Eclipse Distribution License v. 1.0 which accompany this distribution. |
| 6 |
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* and the Eclipse Distribution License is available at |
| 8 |
* http://www.eclipse.org/org/documents/edl-v10.php. |
| 9 |
*/ |
| 10 |
|
| 11 |
package org.eclipse.collections.impl |
| 12 |
|
| 13 |
import java.lang.StringBuilder |
| 14 |
import java.util.concurrent.TimeUnit |
| 15 |
|
| 16 |
import org.eclipse.collections.api.collection.MutableCollection |
| 17 |
import org.eclipse.collections.api.list.MutableList |
| 18 |
import org.eclipse.collections.api.multimap.MutableMultimap |
| 19 |
import org.eclipse.collections.api.tuple.Pair |
| 20 |
import org.eclipse.collections.impl.Prelude._ |
| 21 |
import org.eclipse.collections.impl.collection.mutable.AbstractMultiReaderMutableCollection |
| 22 |
import org.eclipse.collections.impl.list.mutable.FastList |
| 23 |
import org.eclipse.collections.impl.multimap.list.FastListMultimap |
| 24 |
import org.junit.{Assert, Test} |
| 25 |
|
| 26 |
trait MultiReaderThreadSafetyTestTrait |
| 27 |
{ |
| 28 |
val classUnderTest: AbstractMultiReaderMutableCollection[Int] |
| 29 |
|
| 30 |
def createReadLockHolderThread(gate: Gate): Thread |
| 31 |
|
| 32 |
def createWriteLockHolderThread(gate: Gate): Thread |
| 33 |
|
| 34 |
def sleep(gate: Gate): Unit = |
| 35 |
{ |
| 36 |
gate.open() |
| 37 |
|
| 38 |
try |
| 39 |
{ |
| 40 |
Thread.sleep(java.lang.Long.MAX_VALUE) |
| 41 |
} |
| 42 |
catch |
| 43 |
{ |
| 44 |
case ignore: InterruptedException => Thread.currentThread.interrupt() |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
def spawn(code: => Unit) = |
| 49 |
{ |
| 50 |
val result = new Thread |
| 51 |
{ |
| 52 |
override def run() = code |
| 53 |
} |
| 54 |
result.start() |
| 55 |
result |
| 56 |
} |
| 57 |
|
| 58 |
class Gate |
| 59 |
{ |
| 60 |
val latch = new java.util.concurrent.CountDownLatch(1) |
| 61 |
|
| 62 |
def open(): Unit = this.latch.countDown() |
| 63 |
|
| 64 |
def await(): Unit = this.latch.await() |
| 65 |
} |
| 66 |
|
| 67 |
def time(code: => Unit) = |
| 68 |
{ |
| 69 |
val before = System.currentTimeMillis |
| 70 |
code |
| 71 |
val after = System.currentTimeMillis |
| 72 |
after - before |
| 73 |
} |
| 74 |
|
| 75 |
def assert(readersBlocked: Boolean, writersBlocked: Boolean)(code: => Any): Unit = |
| 76 |
{ |
| 77 |
if (readersBlocked) |
| 78 |
{ |
| 79 |
assertReadersBlocked(code) |
| 80 |
} |
| 81 |
else |
| 82 |
{ |
| 83 |
assertReadersNotBlocked(code) |
| 84 |
} |
| 85 |
|
| 86 |
if (writersBlocked) |
| 87 |
{ |
| 88 |
assertWritersBlocked(code) |
| 89 |
} |
| 90 |
else |
| 91 |
{ |
| 92 |
assertWritersNotBlocked(code) |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
def assertReadersBlocked(code: => Unit): Unit = |
| 97 |
{ |
| 98 |
this.assertReadSafety(threadSafe = true, 10L, TimeUnit.MILLISECONDS, code) |
| 99 |
} |
| 100 |
|
| 101 |
def assertReadersNotBlocked(code: => Unit): Unit = |
| 102 |
{ |
| 103 |
this.assertReadSafety(threadSafe = false, 60L, TimeUnit.SECONDS, code) |
| 104 |
} |
| 105 |
|
| 106 |
def assertWritersBlocked(code: => Unit): Unit = |
| 107 |
{ |
| 108 |
this.assertWriteSafety(threadSafe = true, 10L, TimeUnit.MILLISECONDS, code) |
| 109 |
} |
| 110 |
|
| 111 |
def assertWritersNotBlocked(code: => Unit): Unit = |
| 112 |
{ |
| 113 |
this.assertWriteSafety(threadSafe = false, 60L, TimeUnit.SECONDS, code) |
| 114 |
} |
| 115 |
|
| 116 |
def assertReadSafety(threadSafe: Boolean, timeout: Long, timeUnit: TimeUnit, code: => Unit): Unit = |
| 117 |
{ |
| 118 |
val gate = new Gate |
| 119 |
assertThreadSafety(timeout, timeUnit, gate, code, threadSafe, createReadLockHolderThread(gate)) |
| 120 |
} |
| 121 |
|
| 122 |
def assertWriteSafety(threadSafe: Boolean, timeout: Long, timeUnit: TimeUnit, code: => Unit): Unit = |
| 123 |
{ |
| 124 |
val gate = new Gate |
| 125 |
assertThreadSafety(timeout, timeUnit, gate, code, threadSafe, createWriteLockHolderThread(gate)) |
| 126 |
} |
| 127 |
|
| 128 |
def assertThreadSafety(timeout: Long, timeUnit: TimeUnit, gate: MultiReaderThreadSafetyTestTrait.this.type#Gate, code: => Unit, threadSafe: Boolean, lockHolderThread: Thread): Unit = |
| 129 |
{ |
| 130 |
val millisTimeout = TimeUnit.MILLISECONDS.convert(timeout, timeUnit) |
| 131 |
val measuredTime = time |
| 132 |
{ |
| 133 |
// Don't start until the other thread is synchronized on classUnderTest |
| 134 |
gate.await() |
| 135 |
spawn(code).join(millisTimeout, 0) |
| 136 |
} |
| 137 |
|
| 138 |
Assert.assertEquals( |
| 139 |
"Measured " + measuredTime + " ms but timeout was " + millisTimeout + " ms.", |
| 140 |
threadSafe, |
| 141 |
measuredTime >= millisTimeout) |
| 142 |
|
| 143 |
lockHolderThread.interrupt() |
| 144 |
lockHolderThread.join() |
| 145 |
} |
| 146 |
|
| 147 |
@Test |
| 148 |
def newEmpty_safe(): Unit = |
| 149 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 150 |
{ |
| 151 |
this.classUnderTest.newEmpty |
| 152 |
} |
| 153 |
|
| 154 |
@Test |
| 155 |
def iterator_safe(): Unit = |
| 156 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 157 |
{ |
| 158 |
try |
| 159 |
{ |
| 160 |
this.classUnderTest.iterator |
| 161 |
} |
| 162 |
catch |
| 163 |
{ |
| 164 |
case e: Exception => () |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
@Test |
| 169 |
def add_safe(): Unit = |
| 170 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 171 |
{ |
| 172 |
this.classUnderTest.add(4) |
| 173 |
} |
| 174 |
|
| 175 |
@Test |
| 176 |
def addAll_safe(): Unit = |
| 177 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 178 |
{ |
| 179 |
this.classUnderTest.addAll(new FastList[Int]) |
| 180 |
} |
| 181 |
|
| 182 |
@Test |
| 183 |
def addAllIterable_safe(): Unit = |
| 184 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 185 |
{ |
| 186 |
this.classUnderTest.addAllIterable(new FastList[Int]) |
| 187 |
} |
| 188 |
|
| 189 |
@Test |
| 190 |
def remove_safe(): Unit = |
| 191 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 192 |
{ |
| 193 |
this.classUnderTest.remove(1) |
| 194 |
} |
| 195 |
|
| 196 |
@Test |
| 197 |
def removeAll_safe(): Unit = |
| 198 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 199 |
{ |
| 200 |
this.classUnderTest.removeAll(new FastList[Int]) |
| 201 |
} |
| 202 |
|
| 203 |
@Test |
| 204 |
def removeAllIterable_safe(): Unit = |
| 205 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 206 |
{ |
| 207 |
this.classUnderTest.removeAllIterable(new FastList[Int]) |
| 208 |
} |
| 209 |
|
| 210 |
@Test |
| 211 |
def retainAll_safe(): Unit = |
| 212 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 213 |
{ |
| 214 |
this.classUnderTest.retainAll(new FastList[Int]) |
| 215 |
} |
| 216 |
|
| 217 |
@Test |
| 218 |
def retainAllIterable_safe(): Unit = |
| 219 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 220 |
{ |
| 221 |
this.classUnderTest.retainAllIterable(new FastList[Int]) |
| 222 |
} |
| 223 |
|
| 224 |
@Test |
| 225 |
def removeIf_safe(): Unit = |
| 226 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 227 |
{ |
| 228 |
this.classUnderTest.removeIf((_: Int) => true) |
| 229 |
} |
| 230 |
|
| 231 |
@Test |
| 232 |
def removeIfWith_safe(): Unit = |
| 233 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 234 |
{ |
| 235 |
this.classUnderTest.removeIfWith((_: Int, _: Int) => true, 0) |
| 236 |
} |
| 237 |
|
| 238 |
@Test |
| 239 |
def with_safe(): Unit = |
| 240 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 241 |
{ |
| 242 |
this.classUnderTest.`with`(4) |
| 243 |
} |
| 244 |
|
| 245 |
@Test |
| 246 |
def without_safe(): Unit = |
| 247 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 248 |
{ |
| 249 |
this.classUnderTest.without(1) |
| 250 |
} |
| 251 |
|
| 252 |
@Test |
| 253 |
def withAll_safe(): Unit = |
| 254 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 255 |
{ |
| 256 |
this.classUnderTest.withAll(new FastList[Int]) |
| 257 |
} |
| 258 |
|
| 259 |
@Test |
| 260 |
def withoutAll_safe(): Unit = |
| 261 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 262 |
{ |
| 263 |
this.classUnderTest.withoutAll(new FastList[Int]) |
| 264 |
} |
| 265 |
|
| 266 |
@Test |
| 267 |
def clear_safe(): Unit = |
| 268 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 269 |
{ |
| 270 |
this.classUnderTest.clear() |
| 271 |
} |
| 272 |
|
| 273 |
@Test |
| 274 |
def size_safe(): Unit = |
| 275 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 276 |
{ |
| 277 |
this.classUnderTest.size |
| 278 |
} |
| 279 |
|
| 280 |
@Test |
| 281 |
def getFirst_safe(): Unit = |
| 282 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 283 |
{ |
| 284 |
this.classUnderTest.getFirst |
| 285 |
} |
| 286 |
|
| 287 |
@Test |
| 288 |
def getLast_safe(): Unit = |
| 289 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 290 |
{ |
| 291 |
this.classUnderTest.getLast |
| 292 |
} |
| 293 |
|
| 294 |
@Test |
| 295 |
def isEmpty_safe(): Unit = |
| 296 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 297 |
{ |
| 298 |
this.classUnderTest.isEmpty |
| 299 |
} |
| 300 |
|
| 301 |
@Test |
| 302 |
def notEmpty_safe(): Unit = |
| 303 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 304 |
{ |
| 305 |
this.classUnderTest.notEmpty |
| 306 |
} |
| 307 |
|
| 308 |
@Test |
| 309 |
def contains_safe(): Unit = |
| 310 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 311 |
{ |
| 312 |
this.classUnderTest.contains(1) |
| 313 |
} |
| 314 |
|
| 315 |
@Test |
| 316 |
def containsAll_safe(): Unit = |
| 317 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 318 |
{ |
| 319 |
this.classUnderTest.containsAll(new FastList[Int]) |
| 320 |
} |
| 321 |
|
| 322 |
@Test |
| 323 |
def containsAllIterable_safe(): Unit = |
| 324 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 325 |
{ |
| 326 |
this.classUnderTest.containsAll(new FastList[Int]) |
| 327 |
} |
| 328 |
|
| 329 |
@Test |
| 330 |
def containsAllArguments_safe(): Unit = |
| 331 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 332 |
{ |
| 333 |
this.classUnderTest.containsAllArguments("1", "2") |
| 334 |
} |
| 335 |
|
| 336 |
@Test |
| 337 |
def equals_safe(): Unit = |
| 338 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 339 |
{ |
| 340 |
this.classUnderTest.equals(null) |
| 341 |
} |
| 342 |
|
| 343 |
@Test |
| 344 |
def hashCode_safe(): Unit = |
| 345 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 346 |
{ |
| 347 |
this.classUnderTest.hashCode |
| 348 |
} |
| 349 |
|
| 350 |
@Test |
| 351 |
def forEach_safe(): Unit = |
| 352 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 353 |
{ |
| 354 |
this.classUnderTest.forEach((_: Int) => ()) |
| 355 |
} |
| 356 |
|
| 357 |
@Test |
| 358 |
def forEachWith_safe(): Unit = |
| 359 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 360 |
{ |
| 361 |
this.classUnderTest.forEachWith((_: Int, _: Int) => (), 0) |
| 362 |
} |
| 363 |
|
| 364 |
@Test |
| 365 |
def collect_safe(): Unit = |
| 366 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 367 |
{ |
| 368 |
this.classUnderTest.collect[String]((_: Int) => "") |
| 369 |
} |
| 370 |
|
| 371 |
@Test |
| 372 |
def collect_withTarget_safe(): Unit = |
| 373 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 374 |
{ |
| 375 |
this.classUnderTest.collect[String, MutableCollection[String]]((_: Int) => "", new FastList[String]) |
| 376 |
} |
| 377 |
|
| 378 |
@Test |
| 379 |
def collectWith_safe(): Unit = |
| 380 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 381 |
{ |
| 382 |
this.classUnderTest.collectWith[String, String]((_: Int, _: String) => "", "") |
| 383 |
} |
| 384 |
|
| 385 |
@Test |
| 386 |
def collectWith_withTarget_safe(): Unit = |
| 387 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 388 |
{ |
| 389 |
this.classUnderTest.collectWith[String, String, MutableList[String]]((_: Int, _: String) => "", "", new FastList[String]) |
| 390 |
} |
| 391 |
|
| 392 |
@Test |
| 393 |
def flatCollect_safe(): Unit = |
| 394 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 395 |
{ |
| 396 |
this.classUnderTest.flatCollect[String]((_: Int) => new FastList[String]) |
| 397 |
} |
| 398 |
|
| 399 |
@Test |
| 400 |
def flatCollect_withTarget_safe(): Unit = |
| 401 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 402 |
{ |
| 403 |
this.classUnderTest.flatCollect[Int, MutableList[Int]]((_: Int) => new FastList[Int], new FastList[Int]) |
| 404 |
} |
| 405 |
|
| 406 |
@Test |
| 407 |
def collectIf_safe(): Unit = |
| 408 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 409 |
{ |
| 410 |
this.classUnderTest.collectIf[String]((_: Int) => true, (_: Int) => "") |
| 411 |
} |
| 412 |
|
| 413 |
@Test |
| 414 |
def collectIf_withTarget_safe(): Unit = |
| 415 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 416 |
{ |
| 417 |
this.classUnderTest.collectIf[String, MutableCollection[String]]((_: Int) => true, (num: Int) => "", new FastList[String]) |
| 418 |
} |
| 419 |
|
| 420 |
@Test |
| 421 |
def select_safe(): Unit = |
| 422 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 423 |
{ |
| 424 |
this.classUnderTest.select((_: Int) => true) |
| 425 |
} |
| 426 |
|
| 427 |
@Test |
| 428 |
def select_withTarget_safe(): Unit = |
| 429 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 430 |
{ |
| 431 |
this.classUnderTest.select((_: Int) => true, new FastList[Int]) |
| 432 |
} |
| 433 |
|
| 434 |
@Test |
| 435 |
def selectWith_safe(): Unit = |
| 436 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 437 |
{ |
| 438 |
this.classUnderTest.selectWith((_: Int, _: Int) => true, 1) |
| 439 |
} |
| 440 |
|
| 441 |
@Test |
| 442 |
def selectWith_withTarget_safe(): Unit = |
| 443 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 444 |
{ |
| 445 |
this.classUnderTest.selectWith((_: Int, _: Int) => true, 1, new FastList[Int]) |
| 446 |
} |
| 447 |
|
| 448 |
@Test |
| 449 |
def reject_safe(): Unit = |
| 450 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 451 |
{ |
| 452 |
this.classUnderTest.reject((_: Int) => true) |
| 453 |
} |
| 454 |
|
| 455 |
@Test |
| 456 |
def reject_withTarget_safe(): Unit = |
| 457 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 458 |
{ |
| 459 |
this.classUnderTest.reject((_: Int) => true, new FastList[Int]) |
| 460 |
} |
| 461 |
|
| 462 |
@Test |
| 463 |
def rejectWith_safe(): Unit = |
| 464 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 465 |
{ |
| 466 |
this.classUnderTest.rejectWith((_: Int, _: Int) => true, 1) |
| 467 |
} |
| 468 |
|
| 469 |
@Test |
| 470 |
def rejectWith_withTarget_safe(): Unit = |
| 471 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 472 |
{ |
| 473 |
this.classUnderTest.rejectWith((_: Int, _: Int) => true, 1, new FastList[Int]) |
| 474 |
} |
| 475 |
|
| 476 |
@Test |
| 477 |
def selectInstancesOf_safe(): Unit = |
| 478 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 479 |
{ |
| 480 |
this.classUnderTest.selectInstancesOf(Int.getClass) |
| 481 |
} |
| 482 |
|
| 483 |
@Test |
| 484 |
def partition_safe(): Unit = |
| 485 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 486 |
{ |
| 487 |
this.classUnderTest.partition((_: Int) => true) |
| 488 |
} |
| 489 |
|
| 490 |
@Test |
| 491 |
def partitionWith_safe(): Unit = |
| 492 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 493 |
{ |
| 494 |
this.classUnderTest.partitionWith((_: Int, _: Int) => true, 1) |
| 495 |
} |
| 496 |
|
| 497 |
@Test |
| 498 |
def selectAndRejectWith_safe(): Unit = |
| 499 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 500 |
{ |
| 501 |
this.classUnderTest.selectAndRejectWith((_: Int, _: Int) => true, 1) |
| 502 |
} |
| 503 |
|
| 504 |
@Test |
| 505 |
def count_safe(): Unit = |
| 506 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 507 |
{ |
| 508 |
this.classUnderTest.count((_: Int) => true) |
| 509 |
} |
| 510 |
|
| 511 |
@Test |
| 512 |
def countWith_safe(): Unit = |
| 513 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 514 |
{ |
| 515 |
this.classUnderTest.countWith((_: Int, _: Int) => true, 1) |
| 516 |
} |
| 517 |
|
| 518 |
@Test |
| 519 |
def min_safe(): Unit = |
| 520 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 521 |
{ |
| 522 |
this.classUnderTest.min |
| 523 |
} |
| 524 |
|
| 525 |
@Test |
| 526 |
def max_safe(): Unit = |
| 527 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 528 |
{ |
| 529 |
this.classUnderTest.max |
| 530 |
} |
| 531 |
|
| 532 |
@Test |
| 533 |
def min_withComparator_safe(): Unit = |
| 534 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 535 |
{ |
| 536 |
this.classUnderTest.min((_: Int, _: Int) => 0) |
| 537 |
} |
| 538 |
|
| 539 |
@Test |
| 540 |
def max_withComparator_safe(): Unit = |
| 541 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 542 |
{ |
| 543 |
this.classUnderTest.max((_: Int, _: Int) => 0) |
| 544 |
} |
| 545 |
|
| 546 |
@Test |
| 547 |
def minBy_safe(): Unit = |
| 548 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 549 |
{ |
| 550 |
this.classUnderTest.minBy[String]((_: Int) => "") |
| 551 |
} |
| 552 |
|
| 553 |
@Test |
| 554 |
def maxBy_safe(): Unit = |
| 555 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 556 |
{ |
| 557 |
this.classUnderTest.maxBy[String]((_: Int) => "") |
| 558 |
} |
| 559 |
|
| 560 |
@Test |
| 561 |
def injectInto_safe(): Unit = |
| 562 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 563 |
{ |
| 564 |
this.classUnderTest.injectInto[Int](0, (_: Int, _: Int) => 0) |
| 565 |
} |
| 566 |
|
| 567 |
@Test |
| 568 |
def injectIntoWith_safe(): Unit = |
| 569 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 570 |
{ |
| 571 |
this.classUnderTest.injectIntoWith[Int, Int](0, (_: Int, _: Int, _: Int) => 0, 0) |
| 572 |
} |
| 573 |
|
| 574 |
@Test |
| 575 |
def sumOfInt_safe(): Unit = |
| 576 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 577 |
{ |
| 578 |
this.classUnderTest.sumOfInt((_: Int) => 0) |
| 579 |
} |
| 580 |
|
| 581 |
@Test |
| 582 |
def sumOfLong_safe(): Unit = |
| 583 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 584 |
{ |
| 585 |
this.classUnderTest.sumOfLong((_: Int) => 0L) |
| 586 |
} |
| 587 |
|
| 588 |
@Test |
| 589 |
def sumOfDouble_safe(): Unit = |
| 590 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 591 |
{ |
| 592 |
this.classUnderTest.sumOfDouble((_: Int) => 0.0) |
| 593 |
} |
| 594 |
|
| 595 |
@Test |
| 596 |
def sumOfFloat_safe(): Unit = |
| 597 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 598 |
{ |
| 599 |
this.classUnderTest.sumOfFloat((_: Int) => 0.0f) |
| 600 |
} |
| 601 |
|
| 602 |
@Test |
| 603 |
def toString_safe(): Unit = |
| 604 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 605 |
{ |
| 606 |
this.classUnderTest.toString |
| 607 |
} |
| 608 |
|
| 609 |
@Test |
| 610 |
def makeString_safe(): Unit = |
| 611 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 612 |
{ |
| 613 |
this.classUnderTest.makeString |
| 614 |
} |
| 615 |
|
| 616 |
@Test |
| 617 |
def makeString_withSeparator_safe(): Unit = |
| 618 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 619 |
{ |
| 620 |
this.classUnderTest.makeString(", ") |
| 621 |
} |
| 622 |
|
| 623 |
@Test |
| 624 |
def makeString_withStartEndSeparator_safe(): Unit = |
| 625 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 626 |
{ |
| 627 |
this.classUnderTest.makeString("[", ", ", "]") |
| 628 |
} |
| 629 |
|
| 630 |
@Test |
| 631 |
def appendString_safe(): Unit = |
| 632 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 633 |
{ |
| 634 |
this.classUnderTest.appendString(new StringBuilder) |
| 635 |
} |
| 636 |
|
| 637 |
@Test |
| 638 |
def appendString_withSeparator_safe(): Unit = |
| 639 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 640 |
{ |
| 641 |
this.classUnderTest.appendString(new StringBuilder, ", ") |
| 642 |
} |
| 643 |
|
| 644 |
@Test |
| 645 |
def appendString_withStartEndSeparator_safe(): Unit = |
| 646 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 647 |
{ |
| 648 |
this.classUnderTest.appendString(new StringBuilder, "[", ", ", "]") |
| 649 |
} |
| 650 |
|
| 651 |
@Test |
| 652 |
def groupBy_safe(): Unit = |
| 653 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 654 |
{ |
| 655 |
this.classUnderTest.groupBy[String]((_: Int) => "") |
| 656 |
} |
| 657 |
|
| 658 |
@Test |
| 659 |
def groupBy_withTarget_safe(): Unit = |
| 660 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 661 |
{ |
| 662 |
this.classUnderTest.groupBy[String, MutableMultimap[String, Int]]((_: Int) => "", new FastListMultimap[String, Int]) |
| 663 |
} |
| 664 |
|
| 665 |
@Test |
| 666 |
def groupByEach_safe(): Unit = |
| 667 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 668 |
{ |
| 669 |
this.classUnderTest.groupByEach((_: Int) => new FastList[String]) |
| 670 |
} |
| 671 |
|
| 672 |
@Test |
| 673 |
def groupByEach_withTarget_safe(): Unit = |
| 674 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 675 |
{ |
| 676 |
this.classUnderTest.groupByEach[Int, MutableMultimap[Int, Int]]((_: Int) => new FastList[Int], new FastListMultimap[Int, Int]) |
| 677 |
} |
| 678 |
|
| 679 |
@Test |
| 680 |
def aggregateBy_safe(): Unit = |
| 681 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 682 |
{ |
| 683 |
this.classUnderTest.aggregateBy[String, Int]((_: Int) => "", () => 0, (_: Int, _: Int) => 0) |
| 684 |
} |
| 685 |
|
| 686 |
@Test |
| 687 |
def aggregateInPlaceBy_safe(): Unit = |
| 688 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 689 |
{ |
| 690 |
this.classUnderTest.aggregateInPlaceBy[String, Int]((_: Int) => "", () => 0, (_: Int, _: Int) => ()) |
| 691 |
} |
| 692 |
|
| 693 |
@Test |
| 694 |
def zip_safe(): Unit = |
| 695 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 696 |
{ |
| 697 |
this.classUnderTest.zip(FastList.newListWith("1", "1", "2")) |
| 698 |
} |
| 699 |
|
| 700 |
@Test |
| 701 |
def zip_withTarget_safe(): Unit = |
| 702 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 703 |
{ |
| 704 |
this.classUnderTest.zip(FastList.newListWith[String]("1", "1", "2"), new FastList[Pair[Int, String]]) |
| 705 |
} |
| 706 |
|
| 707 |
@Test |
| 708 |
def zipByIndex_safe(): Unit = |
| 709 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 710 |
{ |
| 711 |
this.classUnderTest.zipWithIndex() |
| 712 |
} |
| 713 |
|
| 714 |
@Test |
| 715 |
def zipByIndex_withTarget_safe(): Unit = |
| 716 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 717 |
{ |
| 718 |
this.classUnderTest.zipWithIndex(new FastList[Pair[Int, java.lang.Integer]]) |
| 719 |
} |
| 720 |
|
| 721 |
@Test |
| 722 |
def chunk_safe(): Unit = |
| 723 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 724 |
{ |
| 725 |
this.classUnderTest.chunk(2) |
| 726 |
} |
| 727 |
|
| 728 |
@Test |
| 729 |
def anySatisfy_safe(): Unit = |
| 730 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 731 |
{ |
| 732 |
this.classUnderTest.anySatisfy((_: Int) => true) |
| 733 |
} |
| 734 |
|
| 735 |
@Test |
| 736 |
def anySatisfyWith_safe(): Unit = |
| 737 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 738 |
{ |
| 739 |
this.classUnderTest.anySatisfyWith((_: Int, _: Int) => true, 1) |
| 740 |
} |
| 741 |
|
| 742 |
@Test |
| 743 |
def allSatisfy_safe(): Unit = |
| 744 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 745 |
{ |
| 746 |
this.classUnderTest.allSatisfy((_: Int) => true) |
| 747 |
} |
| 748 |
|
| 749 |
@Test |
| 750 |
def allSatisfyWith_safe(): Unit = |
| 751 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 752 |
{ |
| 753 |
this.classUnderTest.allSatisfyWith((_: Int, _: Int) => true, 1) |
| 754 |
} |
| 755 |
|
| 756 |
@Test |
| 757 |
def noneSatisfy_safe(): Unit = |
| 758 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 759 |
{ |
| 760 |
this.classUnderTest.noneSatisfy((_: Int) => true) |
| 761 |
} |
| 762 |
|
| 763 |
@Test |
| 764 |
def noneSatisfyWith_safe(): Unit = |
| 765 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 766 |
{ |
| 767 |
this.classUnderTest.noneSatisfyWith((_: Int, _: Int) => true, 1) |
| 768 |
} |
| 769 |
|
| 770 |
@Test |
| 771 |
def detect_safe(): Unit = |
| 772 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 773 |
{ |
| 774 |
this.classUnderTest.detect((_: Int) => true) |
| 775 |
} |
| 776 |
|
| 777 |
@Test |
| 778 |
def detectIfNone_safe(): Unit = |
| 779 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 780 |
{ |
| 781 |
this.classUnderTest.detectIfNone((_: Int) => true, () => 1) |
| 782 |
} |
| 783 |
|
| 784 |
@Test |
| 785 |
def detectWith_safe(): Unit = |
| 786 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 787 |
{ |
| 788 |
this.classUnderTest.detectWith((_: Int, _: Int) => true, 1) |
| 789 |
} |
| 790 |
|
| 791 |
@Test |
| 792 |
def detectWithIfNone_safe(): Unit = |
| 793 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 794 |
{ |
| 795 |
this.classUnderTest.detectWithIfNone((_: Int, _: Int) => true, 1, () => 1) |
| 796 |
} |
| 797 |
|
| 798 |
@Test |
| 799 |
def asLazy_safe(): Unit = |
| 800 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 801 |
{ |
| 802 |
this.classUnderTest.asLazy |
| 803 |
} |
| 804 |
|
| 805 |
@Test |
| 806 |
def asUnmodifiable_safe(): Unit = |
| 807 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 808 |
{ |
| 809 |
this.classUnderTest.asUnmodifiable |
| 810 |
} |
| 811 |
|
| 812 |
@Test |
| 813 |
def asSynchronized_safe(): Unit = |
| 814 |
{ |
| 815 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 816 |
{ |
| 817 |
this.classUnderTest.asSynchronized |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
@Test |
| 822 |
def toImmutable_safe(): Unit = |
| 823 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 824 |
{ |
| 825 |
this.classUnderTest.toImmutable |
| 826 |
} |
| 827 |
|
| 828 |
@Test |
| 829 |
def toList_safe(): Unit = |
| 830 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 831 |
{ |
| 832 |
this.classUnderTest.toList |
| 833 |
} |
| 834 |
|
| 835 |
@Test |
| 836 |
def toSortedList_safe(): Unit = |
| 837 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 838 |
{ |
| 839 |
this.classUnderTest.toSortedList |
| 840 |
} |
| 841 |
|
| 842 |
@Test |
| 843 |
def toSortedList_withComparator_safe(): Unit = |
| 844 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 845 |
{ |
| 846 |
this.classUnderTest.toSortedList((_: Int, _: Int) => 0) |
| 847 |
} |
| 848 |
|
| 849 |
@Test |
| 850 |
def toSortedListBy_safe(): Unit = |
| 851 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 852 |
{ |
| 853 |
this.classUnderTest.toSortedListBy[String]((_: Int) => "") |
| 854 |
} |
| 855 |
|
| 856 |
@Test |
| 857 |
def toSet_safe(): Unit = |
| 858 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 859 |
{ |
| 860 |
this.classUnderTest.toSet |
| 861 |
} |
| 862 |
|
| 863 |
@Test |
| 864 |
def toSortedSet_safe(): Unit = |
| 865 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 866 |
{ |
| 867 |
this.classUnderTest.toSortedSet |
| 868 |
} |
| 869 |
|
| 870 |
@Test |
| 871 |
def toSortedSet_withComparator_safe(): Unit = |
| 872 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 873 |
{ |
| 874 |
this.classUnderTest.toSortedSet((_: Int, _: Int) => 0) |
| 875 |
} |
| 876 |
|
| 877 |
@Test |
| 878 |
def toSortedSetBy_safe(): Unit = |
| 879 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 880 |
{ |
| 881 |
this.classUnderTest.toSortedSetBy[String]((_: Int) => "") |
| 882 |
} |
| 883 |
|
| 884 |
@Test |
| 885 |
def toBag_safe(): Unit = |
| 886 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 887 |
{ |
| 888 |
this.classUnderTest.toBag |
| 889 |
} |
| 890 |
|
| 891 |
@Test |
| 892 |
def toSortedBag_safe(): Unit = |
| 893 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 894 |
{ |
| 895 |
this.classUnderTest.toSortedBag |
| 896 |
} |
| 897 |
|
| 898 |
@Test |
| 899 |
def toSortedBag_withComparator_safe(): Unit = |
| 900 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 901 |
{ |
| 902 |
this.classUnderTest.toSortedBag((_: Int, _: Int) => 0) |
| 903 |
} |
| 904 |
|
| 905 |
@Test |
| 906 |
def toSortedBagBy_safe(): Unit = |
| 907 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 908 |
{ |
| 909 |
this.classUnderTest.toSortedBagBy[String]((_: Int) => "") |
| 910 |
} |
| 911 |
|
| 912 |
@Test |
| 913 |
def toMap_safe(): Unit = |
| 914 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 915 |
{ |
| 916 |
this.classUnderTest.toMap((_: Int) => 0, (_: Int) => 0) |
| 917 |
} |
| 918 |
|
| 919 |
@Test |
| 920 |
def toSortedMap_safe(): Unit = |
| 921 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 922 |
{ |
| 923 |
this.classUnderTest.toSortedMap((_: Int) => 0, (_: Int) => 0) |
| 924 |
} |
| 925 |
|
| 926 |
@Test |
| 927 |
def toSortedMap_withComparator_safe(): Unit = |
| 928 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 929 |
{ |
| 930 |
this.classUnderTest.toSortedMap[Int, Int]((_: Int, _: Int) => 0, (_: Int) => 0, (_: Int) => 0) |
| 931 |
} |
| 932 |
|
| 933 |
@Test |
| 934 |
def toSortedMap_withFunction_safe(): Unit = |
| 935 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 936 |
{ |
| 937 |
this.classUnderTest.toSortedMapBy[Integer, Int, Int]((_: Int) => Integer.valueOf(0), (_: Int) => 0, (_: Int) => 0) |
| 938 |
} |
| 939 |
|
| 940 |
@Test |
| 941 |
def toArray_safe(): Unit = |
| 942 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 943 |
{ |
| 944 |
this.classUnderTest.toArray |
| 945 |
} |
| 946 |
|
| 947 |
@Test |
| 948 |
def toArrayWithTarget_safe(): Unit = |
| 949 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 950 |
{ |
| 951 |
this.classUnderTest.toArray(new Array[java.lang.Integer](10)) |
| 952 |
} |
| 953 |
} |