Skip to content

Commit

Permalink
[routing] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Nov 10, 2023
1 parent 03f4ace commit 435c896
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions javalin/src/test/java/io/javalin/TestRouting.kt
Expand Up @@ -42,11 +42,10 @@ class TestRouting {
assertThat(http.getBody("/hello")).isEqualTo("Hello World")
}


@Test
fun `routing is available in config`() = TestUtil.test(Javalin.create { cfg ->
cfg.router.mount {
get("/hello") { it.result("Hello World") }
this.get("/hello") { it.result("Hello World") }
}
}) { _, http ->
assertThat(http.getBody("/hello")).isEqualTo("Hello World")
Expand Down
6 changes: 3 additions & 3 deletions javalin/src/test/java/io/javalin/TestWebSocket.kt
Expand Up @@ -89,7 +89,7 @@ class TestWebSocket {

TestUtil.test(contextPathJavalin { cfg ->
cfg.router.mount {
ws("/test-websocket-1") { ws ->
this.ws("/test-websocket-1") { ws ->
ws.onConnect { ctx -> logger.log.add(ctx.sessionId()) }
ws.onClose { ctx -> logger.log.add(ctx.sessionId()) }
}
Expand Down Expand Up @@ -119,7 +119,7 @@ class TestWebSocket {

TestUtil.test(contextPathJavalin { cfg ->
cfg.router.mount {
ws("/test-websocket-1") { ws ->
this.ws("/test-websocket-1") { ws ->
ws.onConnect { ctx ->
idMap[ctx] = atomicInteger.getAndIncrement()
logger.log.add("${idMap[ctx]} connected")
Expand Down Expand Up @@ -234,7 +234,7 @@ class TestWebSocket {
fun `headers and host are available in session`() = TestUtil.test { app, _ ->
app.ws("/websocket") { ws ->
ws.onConnect { ctx -> app.logger().log.add("Header: " + ctx.header("Test")!!) }
ws.onClose { ctx -> app.logger().log.add("Closed connection from: " + ctx.host()!!) }
ws.onClose { ctx -> app.logger().log.add("Closed connection from: " + ctx.host()) }
}
TestClient(app, "/websocket", mapOf("Test" to "HeaderParameter")).connectAndDisconnect()
assertThat(app.logger().log).containsExactlyInAnyOrder("Header: HeaderParameter", "Closed connection from: localhost")
Expand Down

0 comments on commit 435c896

Please sign in to comment.