Skip to content

Commit 8fd223d

Browse files
authored
Ktor usage cleanup (#288)
* Cleanup ktor deps * drop old client tests * extract websocket tests in separate module
1 parent aeaf294 commit 8fd223d

File tree

9 files changed

+57
-90
lines changed

9 files changed

+57
-90
lines changed

gradle/libs.versions.toml

-7
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,14 @@ kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutine
3131

3232
kotlinx-benchmark = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
3333

34-
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
35-
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" }
3634
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
3735
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
3836
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
3937
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
4038
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
41-
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
42-
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
4339
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
44-
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
4540
ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.ref = "ktor" }
4641
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
47-
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
48-
ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" }
4942

5043
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
5144
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }

ktor-plugins/ktor-server-rsocket/build.gradle.kts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,11 +32,5 @@ kotlin {
3232
api(projects.rsocketCore)
3333
api(libs.ktor.server.websockets)
3434
}
35-
commonTest.dependencies {
36-
implementation(projects.ktorClientRsocket)
37-
implementation(projects.rsocketTest)
38-
implementation(libs.ktor.client.cio)
39-
implementation(libs.ktor.server.cio)
40-
}
4135
}
4236
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,11 +14,23 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.transport.ktor.websocket.server
17+
import rsocketbuild.*
1818

19-
import io.ktor.client.engine.cio.CIO as ClientCIO
20-
import io.ktor.server.cio.CIO as ServerCIO
19+
plugins {
20+
id("rsocketbuild.multiplatform-base")
21+
}
2122

22-
class CIOWebSocketTransportTest : WebSocketTransportTest(ClientCIO, ServerCIO)
23+
kotlin {
24+
jvmTarget()
25+
nixTargets()
2326

24-
class CIOKtorWebSocketTransportTest : KtorWebSocketTransportTest(ClientCIO, ServerCIO)
27+
sourceSets {
28+
commonTest.dependencies {
29+
implementation(projects.ktorClientRsocket)
30+
implementation(projects.ktorServerRsocket)
31+
implementation(projects.rsocketTest)
32+
implementation(libs.ktor.client.cio)
33+
implementation(libs.ktor.server.cio)
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.transport.ktor.websocket.server
17+
package io.rsocket.kotlin.ktor.tests
1818

1919
import io.ktor.client.*
2020
import io.ktor.server.application.*

rsocket-transports/ktor-websocket-server/build.gradle.kts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,18 +31,8 @@ kotlin {
3131
implementation(projects.rsocketTransportKtorWebsocketInternal)
3232
implementation(projects.rsocketInternalIo)
3333
api(projects.rsocketCore)
34-
api(libs.ktor.server.host.common)
34+
api(libs.ktor.server.core)
3535
api(libs.ktor.server.websockets)
3636
}
37-
commonTest.dependencies {
38-
implementation(projects.rsocketTransportTests)
39-
implementation(projects.rsocketTransportKtorWebsocketClient)
40-
implementation(libs.ktor.client.cio)
41-
implementation(libs.ktor.server.cio)
42-
}
43-
jvmTest.dependencies {
44-
implementation(libs.ktor.client.okhttp)
45-
implementation(libs.ktor.server.netty)
46-
}
4737
}
4838
}

rsocket-transports/ktor-websocket-server/src/jvmTest/kotlin/io/rsocket/kotlin/transport/ktor/websocket/server/WebSocketTransportTests.kt

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,12 +14,23 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.transport.ktor.websocket.client
17+
import rsocketbuild.*
1818

19-
//class ClientWebSocketTransportTest : TransportTest() {
20-
// override suspend fun before() {
21-
// client = connectClient(
22-
// WebSocketClientTransport(Js, port = 9000, context = testContext, pool = InUseTrackingPool)
23-
// )
24-
// }
25-
//}
19+
plugins {
20+
id("rsocketbuild.multiplatform-base")
21+
}
22+
23+
kotlin {
24+
jvmTarget()
25+
nixTargets()
26+
27+
sourceSets {
28+
commonTest.dependencies {
29+
implementation(projects.rsocketTransportTests)
30+
implementation(projects.rsocketTransportKtorWebsocketClient)
31+
implementation(projects.rsocketTransportKtorWebsocketServer)
32+
implementation(libs.ktor.client.cio)
33+
implementation(libs.ktor.server.cio)
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,43 +14,38 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.rsocket.kotlin.transport.ktor.websocket.server
17+
package io.rsocket.kotlin.transport.ktor.websocket.tests
1818

19-
import io.ktor.client.engine.*
20-
import io.ktor.server.engine.*
2119
import io.rsocket.kotlin.transport.ktor.websocket.client.*
20+
import io.rsocket.kotlin.transport.ktor.websocket.server.*
2221
import io.rsocket.kotlin.transport.tests.*
22+
import io.ktor.client.engine.cio.CIO as ClientCIO
23+
import io.ktor.server.cio.CIO as ServerCIO
2324

2425
@Suppress("DEPRECATION_ERROR")
25-
abstract class WebSocketTransportTest(
26-
private val clientEngine: HttpClientEngineFactory<*>,
27-
private val serverEngine: ApplicationEngineFactory<*, *>,
28-
) : TransportTest() {
26+
class WebSocketTransportTest : TransportTest() {
2927
override suspend fun before() {
3028
val embeddedServer = startServer(
31-
WebSocketServerTransport(serverEngine, port = 0)
29+
WebSocketServerTransport(ServerCIO, port = 0)
3230
)
3331
val connector = embeddedServer.engine.resolvedConnectors().single()
3432
client = connectClient(
35-
WebSocketClientTransport(clientEngine, port = connector.port, context = testContext)
33+
WebSocketClientTransport(ClientCIO, port = connector.port, context = testContext)
3634
)
3735
}
3836
}
3937

40-
abstract class KtorWebSocketTransportTest(
41-
private val clientEngine: HttpClientEngineFactory<*>,
42-
private val serverEngine: ApplicationEngineFactory<*, *>,
43-
) : TransportTest() {
38+
class KtorWebSocketTransportTest : TransportTest() {
4439
override suspend fun before() {
4540
val server = startServer(
4641
KtorWebSocketServerTransport(testContext) {
47-
httpEngine(serverEngine)
42+
httpEngine(ServerCIO)
4843
}.target(port = 0)
4944
)
5045
val port = server.connectors.single().port
5146
client = connectClient(
5247
KtorWebSocketClientTransport(testContext) {
53-
httpEngine(clientEngine)
48+
httpEngine(ClientCIO)
5449
}.target(port = port)
5550
)
5651
}

settings.gradle.kts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@ projects("rsocket-kotlin") {
4141
module("ktor-websocket-internal")
4242
module("ktor-websocket-client")
4343
module("ktor-websocket-server")
44+
module("ktor-websocket-tests")
4445

4546
module("netty-internal")
4647
module("netty-tcp")
@@ -52,6 +53,7 @@ projects("rsocket-kotlin") {
5253
folder("ktor-plugins", null) {
5354
module("ktor-client-rsocket")
5455
module("ktor-server-rsocket")
56+
module("ktor-tests")
5557
// for migration from old names
5658
module("rsocket-ktor-client")
5759
module("rsocket-ktor-server")

0 commit comments

Comments
 (0)