summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/Dockerfile2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt5
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt4
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/ClientEventsAsserts.kt10
4 files changed, 10 insertions, 11 deletions
diff --git a/sw-server/Dockerfile b/sw-server/Dockerfile
index 6d93473e..84a062a5 100644
--- a/sw-server/Dockerfile
+++ b/sw-server/Dockerfile
@@ -1,4 +1,4 @@
-FROM openjdk:15
+FROM openjdk:17
EXPOSE 80
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 c94d49da..bfdef6e9 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,9 +14,8 @@ 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.Duration.Companion.minutes
import kotlin.time.measureTimedValue
-import kotlin.time.minutes
import kotlin.time.toJavaDuration
/**
@@ -33,7 +32,7 @@ class AutoGameController(
val client = SevenWondersClient()
val serverUrl = "ws://localhost:$serverPort"
- val lastTurn = withTimeout(Duration.minutes(5)) {
+ val lastTurn = withTimeout(5.minutes) {
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 788430c8..41b38d72 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,7 +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.Duration.Companion.milliseconds
/**
* Handles actions in the game's lobby. The lobby is the place where players gather before a game.
@@ -165,7 +165,7 @@ class LobbyController(
}
if (result == null) {
meterRegistry.counter("bot.timeout", lobby.playerCountsTags()).increment()
- val timeoutDuration = Duration.milliseconds(action.globalBotTimeoutMillis)
+ val timeoutDuration = action.globalBotTimeoutMillis.milliseconds
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 65711d6d..62245764 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
@@ -12,8 +12,8 @@ import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
import kotlin.time.Duration
-import kotlin.time.milliseconds
-import kotlin.time.seconds
+import kotlin.time.Duration.Companion.milliseconds
+import kotlin.time.Duration.Companion.seconds
class EventAsserter(
val gameListEvents: ReceiveChannel<GameListEvent>,
@@ -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 = Duration.milliseconds(50)) {
+suspend inline fun EventAsserter.expectNoGameEvent(message: String? = null, timeout: Duration = 50.milliseconds) {
val event = withTimeoutOrNull(timeout) { gameEvents.receive() }
val extraMessage = message?.let { " ($it)" } ?: ""
assertNull(event, "Expected no game event$extraMessage, but received $event")
}
-suspend inline fun <reified T : GameEvent> EventAsserter.expectGameEvent(timeout: Duration = Duration.seconds(1)): T {
+suspend inline fun <reified T : GameEvent> EventAsserter.expectGameEvent(timeout: Duration = 1.seconds): 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 <reified T : GameListEvent> EventAsserter.expectGameListEvent(timeout: Duration = Duration.seconds(1)): T {
+suspend inline fun <reified T : GameListEvent> EventAsserter.expectGameListEvent(timeout: Duration = 1.seconds): 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")
bgstack15