-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from scireum/feature/smo/migrateBackgorundLoo…
…pTest jUnit: Migrates BackgroundLoop Tests to Kotlin
- Loading branch information
Showing
2 changed files
with
42 additions
and
41 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Made with all the love in the world | ||
* by scireum in Remshalden, Germany | ||
* | ||
* Copyright by scireum GmbH | ||
* http://www.scireum.de - info@scireum.de | ||
*/ | ||
|
||
package sirius.kernel.async | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import sirius.kernel.NightlyTest | ||
import sirius.kernel.SiriusExtension | ||
import sirius.kernel.commons.Wait | ||
import kotlin.test.assertTrue | ||
|
||
@NightlyTest | ||
@ExtendWith(SiriusExtension::class) | ||
class BackgroundLoopSpec { | ||
@Test | ||
fun `BackgroundLoop limits to max frequency`() { | ||
val currentCounter = FastTestLoop.counter.toInt() | ||
Wait.seconds(10.0) | ||
val delta = FastTestLoop.counter.toInt() - currentCounter | ||
//the background loop executed enough calls (should be 10 but we're a bit tolerant here) | ||
assertTrue { delta >= 8 } | ||
//the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here) | ||
assertTrue { delta <= 12 } | ||
} | ||
|
||
@Test | ||
fun `BackgroundLoop executes as fast as possible if loop is slow`() { | ||
val currentCounter = SlowTestLoop.counter.toInt() | ||
Wait.seconds(10.0) | ||
val delta = SlowTestLoop.counter.toInt() - currentCounter | ||
//the background loop executed enough calls (should be 5 but we're a bit tolerant here) | ||
assertTrue { delta >= 3 } | ||
//the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here) | ||
assertTrue { delta <= 6 } | ||
} | ||
} |