Skip to content

Commit 06539d0

Browse files
committed
extract websocket tests in separate module
1 parent ecfeb07 commit 06539d0

File tree

7 files changed

+71
-38
lines changed

7 files changed

+71
-38
lines changed

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

-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,5 @@ kotlin {
3434
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-
}
4337
}
4438
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import rsocketbuild.*
18+
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)