-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
backend/testing/src/main/kotlin/io/tolgee/BatchJobCleanerListener.kt
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,13 @@ | ||
package io.tolgee | ||
|
||
import io.tolgee.BatchJobTestUtil.pauseAndClearBatchJobs | ||
import io.tolgee.BatchJobTestUtil.resumeBatchJobs | ||
import org.springframework.test.context.TestContext | ||
import org.springframework.test.context.TestExecutionListener | ||
|
||
class BatchJobCleanerListener : TestExecutionListener { | ||
override fun beforeTestMethod(testContext: TestContext) { | ||
pauseAndClearBatchJobs(testContext) | ||
resumeBatchJobs(testContext) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/testing/src/main/kotlin/io/tolgee/BatchJobTestUtil.kt
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,24 @@ | ||
package io.tolgee | ||
|
||
import io.tolgee.batch.BatchJobChunkExecutionQueue | ||
import io.tolgee.batch.BatchJobConcurrentLauncher | ||
import org.springframework.test.context.TestContext | ||
|
||
object BatchJobTestUtil { | ||
fun resumeBatchJobs(testContext: TestContext) { | ||
getBatchJobConcurrentLauncher(testContext).pause = false | ||
} | ||
|
||
fun pauseAndClearBatchJobs(testContext: TestContext) { | ||
getBatchJobConcurrentLauncher(testContext).pause = true | ||
getBatchJobExecutionQueue(testContext).clear() | ||
} | ||
|
||
private fun getBatchJobExecutionQueue(testContext: TestContext): BatchJobChunkExecutionQueue { | ||
return testContext.applicationContext.getBean(BatchJobChunkExecutionQueue::class.java) | ||
} | ||
|
||
private fun getBatchJobConcurrentLauncher(testContext: TestContext): BatchJobConcurrentLauncher { | ||
return testContext.applicationContext.getBean(BatchJobConcurrentLauncher::class.java) | ||
} | ||
} |
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
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