diff --git a/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy b/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy deleted file mode 100644 index 82d92413..00000000 --- a/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.Tag -import sirius.kernel.BaseSpecification -import sirius.kernel.commons.Wait - -@Tag("nightly") -class BackgroundLoopSpec extends BaseSpecification { - - def "BackgroundLoop limits to max frequency"() { - given: - int currentCounter = FastTestLoop.counter - when: - Wait.seconds(10) - int delta = FastTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 10 but we're a bit tolerant here)" - delta >= 8 - and: "the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here)" - delta <= 12 - } - - def "BackgroundLoop executes as fast as possible if loop is slow"() { - given: - int currentCounter = SlowTestLoop.counter - when: - Wait.seconds(10) - int delta = SlowTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 5 but we're a bit tolerant here)" - delta >= 3 - and: "the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here)" - delta <= 6 - } -} diff --git a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt new file mode 100644 index 00000000..6fd75259 --- /dev/null +++ b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt @@ -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 } + } +}