From 0ab3594568c36f64df480cfaccd9e7f7692bfb10 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Tue, 7 Sep 2021 00:30:02 +0200 Subject: Upgrade Kotlin, Kotlin/React, and Krossbow versions --- sw-server/build.gradle.kts | 2 +- .../luxons/sevenwonders/server/controllers/AutoGameController.kt | 3 ++- .../org/luxons/sevenwonders/server/controllers/LobbyController.kt | 3 ++- .../org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'sw-server') diff --git a/sw-server/build.gradle.kts b/sw-server/build.gradle.kts index 832ce912..1bab48d2 100644 --- a/sw-server/build.gradle.kts +++ b/sw-server/build.gradle.kts @@ -2,7 +2,7 @@ plugins { kotlin("jvm") kotlin("plugin.spring") kotlin("plugin.serialization") - id("org.springframework.boot") version "2.4.0" + id("org.springframework.boot") version "2.5.4" } apply(plugin = "io.spring.dependency-management") diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt index b6d66e4b..c94d49da 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController import java.security.Principal +import kotlin.time.Duration import kotlin.time.measureTimedValue import kotlin.time.minutes import kotlin.time.toJavaDuration @@ -32,7 +33,7 @@ class AutoGameController( val client = SevenWondersClient() val serverUrl = "ws://localhost:$serverPort" - val lastTurn = withTimeout(5.minutes) { + val lastTurn = withTimeout(Duration.minutes(5)) { val (lastTurn, duration) = measureTimedValue { val otherBotNames = List(action.nbPlayers - 1) { "JoinerBot${it + 1}" } val owner = client.connectBot(serverUrl, "OwnerBot", action.config) diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt index 9fb1603a..10a94579 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt @@ -27,6 +27,7 @@ import org.springframework.messaging.simp.SimpMessageSendingOperations import org.springframework.stereotype.Controller import org.springframework.validation.annotation.Validated import java.security.Principal +import kotlin.time.Duration import kotlin.time.milliseconds /** @@ -165,7 +166,7 @@ class LobbyController( } if (result == null) { meterRegistry.counter("bot.timeout", lobby.playerCountsTags()).increment() - val timeoutDuration = action.globalBotTimeoutMillis.milliseconds + val timeoutDuration = Duration.milliseconds(action.globalBotTimeoutMillis) logger.error("Bot {} timed out after {}", action.botDisplayName, timeoutDuration) bot.disconnect() } diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt index d87c2122..65711d6d 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt @@ -27,20 +27,20 @@ suspend fun SevenWondersSession.eventAsserter(scope: CoroutineScope): EventAsser return EventAsserter(gameListEvents, gameEvents) } -suspend inline fun EventAsserter.expectNoGameEvent(message: String? = null, timeout: Duration = 50.milliseconds) { +suspend inline fun EventAsserter.expectNoGameEvent(message: String? = null, timeout: Duration = Duration.milliseconds(50)) { val event = withTimeoutOrNull(timeout) { gameEvents.receive() } val extraMessage = message?.let { " ($it)" } ?: "" assertNull(event, "Expected no game event$extraMessage, but received $event") } -suspend inline fun EventAsserter.expectGameEvent(timeout: Duration = 1.seconds): T { +suspend inline fun EventAsserter.expectGameEvent(timeout: Duration = Duration.seconds(1)): T { val event = withTimeoutOrNull(timeout) { gameEvents.receive() } assertNotNull(event, "Expected event of type ${T::class.simpleName}, received nothing in $timeout") assertTrue(event is T, "Expected event of type ${T::class.simpleName}, received $event") return event } -suspend inline fun EventAsserter.expectGameListEvent(timeout: Duration = 1.seconds): T { +suspend inline fun EventAsserter.expectGameListEvent(timeout: Duration = Duration.seconds(1)): T { val event = withTimeoutOrNull(timeout) { gameListEvents.receive() } assertNotNull(event, "Expected event of type ${T::class.simpleName}, received nothing in $timeout") assertTrue(event is T, "Expected event of type ${T::class.simpleName}, received $event") -- cgit