From 7412603262e4b941374ab8335916011c5486d720 Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Fri, 27 Dec 2024 15:52:29 +0100 Subject: [PATCH] KTOR-7995 Move test-server to a separate included build --- buildSrc/build.gradle.kts | 22 ------------ buildSrc/settings.gradle.kts | 9 ----- ...-resolution-management.settings.gradle.kts | 7 ++++ .../ktor-client-android/build.gradle.kts | 4 ++- .../ktor-client-apache/build.gradle.kts | 8 ++++- .../ktor-client-apache5/build.gradle.kts | 8 ++++- ktor-client/ktor-client-cio/build.gradle.kts | 4 ++- ktor-client/ktor-client-curl/build.gradle.kts | 5 ++- .../build.gradle.kts | 8 ++++- .../ktor-client-darwin/build.gradle.kts | 8 ++++- ktor-client/ktor-client-java/build.gradle.kts | 8 ++++- .../ktor-client-okhttp/build.gradle.kts | 8 ++++- .../ktor-client-auth/build.gradle.kts | 6 ++-- .../ktor-client-encoding/build.gradle.kts | 4 ++- .../ktor-client-json/build.gradle.kts | 3 +- .../ktor-client-tests/build.gradle.kts | 5 +-- .../ktor-client-winhttp/build.gradle.kts | 6 ++-- ktor-test-server/README.md | 3 ++ ktor-test-server/build.gradle.kts | 36 +++++++++++++++++++ ktor-test-server/settings.gradle.kts | 13 +++++++ .../src/main/kotlin/test-server.gradle.kts | 13 +++++++ .../kotlin/test/server/ClientTestServer.kt | 3 +- .../main/kotlin/test/server/ServerUtils.kt | 3 +- .../src/main/kotlin/test/server/TestServer.kt | 8 +++-- .../kotlin/test/server/TestServerService.kt | 27 ++++---------- .../main/kotlin/test/server/TestTcpServer.kt | 6 ++-- .../src/main/kotlin/test/server/tests/Auth.kt | 6 ++-- .../src/main/kotlin/test/server/tests/Bom.kt | 2 +- .../main/kotlin/test/server/tests/Builders.kt | 4 +-- .../main/kotlin/test/server/tests/Cache.kt | 6 ++-- .../test/server/tests/CloseableGroup.kt | 4 +-- .../main/kotlin/test/server/tests/Content.kt | 10 +++--- .../main/kotlin/test/server/tests/Cookies.kt | 4 +-- .../main/kotlin/test/server/tests/Download.kt | 6 ++-- .../main/kotlin/test/server/tests/Encoding.kt | 2 +- .../main/kotlin/test/server/tests/Events.kt | 0 .../main/kotlin/test/server/tests/Features.kt | 2 +- .../main/kotlin/test/server/tests/Forms.kt | 2 +- .../main/kotlin/test/server/tests/Headers.kt | 2 +- .../src/main/kotlin/test/server/tests/Json.kt | 4 +-- .../main/kotlin/test/server/tests/Logging.kt | 2 +- .../test/server/tests/MultiPartFormData.kt | 2 +- .../kotlin/test/server/tests/Multithreaded.kt | 4 +-- .../main/kotlin/test/server/tests/Redirect.kt | 4 +-- .../kotlin/test/server/tests/Serialization.kt | 2 +- .../test/server/tests/ServerSentEvents.kt | 8 +++-- .../src/main/kotlin/test/server/tests/Tcp.kt | 9 +++-- .../main/kotlin/test/server/tests/Timeout.kt | 4 +-- .../main/kotlin/test/server/tests/Upload.kt | 4 +-- .../kotlin/test/server/tests/WebSockets.kt | 4 +-- settings.gradle.kts | 2 ++ 51 files changed, 205 insertions(+), 129 deletions(-) create mode 100644 ktor-test-server/README.md create mode 100644 ktor-test-server/build.gradle.kts create mode 100644 ktor-test-server/settings.gradle.kts create mode 100644 ktor-test-server/src/main/kotlin/test-server.gradle.kts rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/ClientTestServer.kt (96%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/ServerUtils.kt (93%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/TestServer.kt (90%) rename buildSrc/src/main/kotlin/test/server/TestServerPlugin.kt => ktor-test-server/src/main/kotlin/test/server/TestServerService.kt (54%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/TestTcpServer.kt (91%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Auth.kt (98%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Bom.kt (95%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Builders.kt (75%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Cache.kt (96%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/CloseableGroup.kt (78%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Content.kt (94%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Cookies.kt (97%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Download.kt (87%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Encoding.kt (98%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Events.kt (100%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Features.kt (89%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Forms.kt (92%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Headers.kt (97%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Json.kt (82%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Logging.kt (94%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/MultiPartFormData.kt (94%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Multithreaded.kt (81%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Redirect.kt (95%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Serialization.kt (93%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/ServerSentEvents.kt (95%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Tcp.kt (94%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Timeout.kt (96%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/Upload.kt (78%) rename {buildSrc => ktor-test-server}/src/main/kotlin/test/server/tests/WebSockets.kt (97%) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 2b398113e7f..6c505a91a44 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -4,9 +4,6 @@ plugins { `kotlin-dsl` - // Serialization version should be aligned with the Kotlin version embedded in Gradle - // https://docs.gradle.org/current/userguide/compatibility.html#kotlin - kotlin("plugin.serialization") version embeddedKotlinVersion } dependencies { @@ -16,25 +13,6 @@ dependencies { implementation(libs.kotlinter) implementation(libs.develocity) implementation(libs.gradleDoctor) - - implementation(libs.ktor.server.default.headers) - implementation(libs.ktor.server.netty) - implementation(libs.ktor.server.cio) - implementation(libs.ktor.server.jetty) - implementation(libs.ktor.server.websockets) - implementation(libs.ktor.server.auth) - implementation(libs.ktor.server.caching.headers) - implementation(libs.ktor.server.conditional.headers) - implementation(libs.ktor.server.compression) - implementation(libs.ktor.server.content.negotiation) - implementation(libs.ktor.server.status.pages) - implementation(libs.ktor.serialization.kotlinx) - implementation(libs.ktor.network.tls.certificates) - implementation(libs.ktor.utils) - - implementation(libs.kotlinx.serialization.json) - implementation(libs.logback.classic) - implementation(libs.tomlj) implementation(libs.kotlinx.atomicfu.gradlePlugin) // A hack to make version catalogs accessible from buildSrc sources diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index ed0a0634d2b..6461f16acd9 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -7,22 +7,13 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") id("conventions-dependency-resolution-management") } dependencyResolutionManagement { - // Additional repositories for buildSrc dependencies @Suppress("UnstableApiUsage") repositories { gradlePluginPortal() - - exclusiveContent { - forRepository { - maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap") { name = "KtorEAP" } - } - filter { includeGroup("io.ktor") } - } } } diff --git a/gradle-settings-conventions/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts b/gradle-settings-conventions/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts index 27985787dfd..91603588435 100644 --- a/gradle-settings-conventions/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts +++ b/gradle-settings-conventions/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts @@ -43,6 +43,13 @@ pluginManagement { } mavenLocal() + + exclusiveContent { + forRepository { + maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap") { name = "KtorEAP" } + } + filter { includeVersionByRegex("io.ktor", ".+", ".+-eap-\\d+") } + } } } diff --git a/ktor-client/ktor-client-android/build.gradle.kts b/ktor-client/ktor-client-android/build.gradle.kts index 11d4ad51b38..74054f8e3f1 100644 --- a/ktor-client/ktor-client-android/build.gradle.kts +++ b/ktor-client/ktor-client-android/build.gradle.kts @@ -4,7 +4,9 @@ import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest -apply() +plugins { + id("test-server") +} kotlin.sourceSets { jvmMain { diff --git a/ktor-client/ktor-client-apache/build.gradle.kts b/ktor-client/ktor-client-apache/build.gradle.kts index b2713ee0296..431ec4addd5 100644 --- a/ktor-client/ktor-client-apache/build.gradle.kts +++ b/ktor-client/ktor-client-apache/build.gradle.kts @@ -1,6 +1,12 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + description = "Apache backend for ktor http client" -apply() +plugins { + id("test-server") +} kotlin.sourceSets { jvmMain { diff --git a/ktor-client/ktor-client-apache5/build.gradle.kts b/ktor-client/ktor-client-apache5/build.gradle.kts index d90574a3d5e..862e7d0a787 100644 --- a/ktor-client/ktor-client-apache5/build.gradle.kts +++ b/ktor-client/ktor-client-apache5/build.gradle.kts @@ -1,6 +1,12 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + description = "Apache backend for ktor http client" -apply() +plugins { + id("test-server") +} kotlin.sourceSets { jvmMain { diff --git a/ktor-client/ktor-client-cio/build.gradle.kts b/ktor-client/ktor-client-cio/build.gradle.kts index cc1412aa042..d3e60008ef0 100644 --- a/ktor-client/ktor-client-cio/build.gradle.kts +++ b/ktor-client/ktor-client-cio/build.gradle.kts @@ -4,7 +4,9 @@ description = "CIO backend for ktor http client" -apply() +plugins { + id("test-server") +} kotlin { sourceSets { diff --git a/ktor-client/ktor-client-curl/build.gradle.kts b/ktor-client/ktor-client-curl/build.gradle.kts index 1aa87437023..9816989729a 100644 --- a/ktor-client/ktor-client-curl/build.gradle.kts +++ b/ktor-client/ktor-client-curl/build.gradle.kts @@ -1,4 +1,6 @@ -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ val paths = listOf( "/opt/homebrew/opt/curl/include/", @@ -19,6 +21,7 @@ val paths = listOf( plugins { id("kotlinx-serialization") + id("test-server") } kotlin { diff --git a/ktor-client/ktor-client-darwin-legacy/build.gradle.kts b/ktor-client/ktor-client-darwin-legacy/build.gradle.kts index dc08308c634..d5f281ba164 100644 --- a/ktor-client/ktor-client-darwin-legacy/build.gradle.kts +++ b/ktor-client/ktor-client-darwin-legacy/build.gradle.kts @@ -1,4 +1,10 @@ -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("test-server") +} kotlin { sourceSets { diff --git a/ktor-client/ktor-client-darwin/build.gradle.kts b/ktor-client/ktor-client-darwin/build.gradle.kts index 4fc0fe781b7..eaba6ae09c6 100644 --- a/ktor-client/ktor-client-darwin/build.gradle.kts +++ b/ktor-client/ktor-client-darwin/build.gradle.kts @@ -1,4 +1,10 @@ -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("test-server") +} kotlin { diff --git a/ktor-client/ktor-client-java/build.gradle.kts b/ktor-client/ktor-client-java/build.gradle.kts index 836441a730a..2bddd751e54 100644 --- a/ktor-client/ktor-client-java/build.gradle.kts +++ b/ktor-client/ktor-client-java/build.gradle.kts @@ -1,4 +1,10 @@ -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("test-server") +} kotlin.sourceSets { jvmMain { diff --git a/ktor-client/ktor-client-okhttp/build.gradle.kts b/ktor-client/ktor-client-okhttp/build.gradle.kts index 82cd34856e5..c0d4697f287 100644 --- a/ktor-client/ktor-client-okhttp/build.gradle.kts +++ b/ktor-client/ktor-client-okhttp/build.gradle.kts @@ -1,4 +1,10 @@ -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("test-server") +} kotlin.sourceSets { jvmMain { diff --git a/ktor-client/ktor-client-plugins/ktor-client-auth/build.gradle.kts b/ktor-client/ktor-client-plugins/ktor-client-auth/build.gradle.kts index 722e3355ec1..feed6f124ad 100644 --- a/ktor-client/ktor-client-plugins/ktor-client-auth/build.gradle.kts +++ b/ktor-client/ktor-client-plugins/ktor-client-auth/build.gradle.kts @@ -2,8 +2,8 @@ * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ -import test.server.* - description = "Ktor client Auth support" -apply() +plugins { + id("test-server") +} diff --git a/ktor-client/ktor-client-plugins/ktor-client-encoding/build.gradle.kts b/ktor-client/ktor-client-plugins/ktor-client-encoding/build.gradle.kts index 540cc733c06..87c015d3e9d 100644 --- a/ktor-client/ktor-client-plugins/ktor-client-encoding/build.gradle.kts +++ b/ktor-client/ktor-client-plugins/ktor-client-encoding/build.gradle.kts @@ -2,7 +2,9 @@ * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ -apply() +plugins { + id("test-server") +} kotlin.sourceSets { jvmTest { diff --git a/ktor-client/ktor-client-plugins/ktor-client-json/build.gradle.kts b/ktor-client/ktor-client-plugins/ktor-client-json/build.gradle.kts index f30cd80004d..1dbe43172a5 100644 --- a/ktor-client/ktor-client-plugins/ktor-client-json/build.gradle.kts +++ b/ktor-client/ktor-client-plugins/ktor-client-json/build.gradle.kts @@ -6,10 +6,9 @@ description = "Ktor client JSON support" plugins { id("kotlinx-serialization") + id("test-server") } -apply() - kotlin { sourceSets { // This is a workaround for https://youtrack.jetbrains.com/issue/KT-39037 diff --git a/ktor-client/ktor-client-tests/build.gradle.kts b/ktor-client/ktor-client-tests/build.gradle.kts index c620c040210..b4359213383 100644 --- a/ktor-client/ktor-client-tests/build.gradle.kts +++ b/ktor-client/ktor-client-tests/build.gradle.kts @@ -2,16 +2,13 @@ * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ -import test.server.TestServerPlugin - description = "Common tests for client" plugins { id("kotlinx-serialization") + id("test-server") } -apply() - kotlin.sourceSets { commonMain { dependencies { diff --git a/ktor-client/ktor-client-winhttp/build.gradle.kts b/ktor-client/ktor-client-winhttp/build.gradle.kts index 904bd730913..55654510259 100644 --- a/ktor-client/ktor-client-winhttp/build.gradle.kts +++ b/ktor-client/ktor-client-winhttp/build.gradle.kts @@ -1,8 +1,10 @@ - -apply() +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ plugins { id("kotlinx-serialization") + id("test-server") } kotlin { diff --git a/ktor-test-server/README.md b/ktor-test-server/README.md new file mode 100644 index 00000000000..943b34fbc93 --- /dev/null +++ b/ktor-test-server/README.md @@ -0,0 +1,3 @@ +# ktor-test-server + +The server used for integration tests of Ktor itself. diff --git a/ktor-test-server/build.gradle.kts b/ktor-test-server/build.gradle.kts new file mode 100644 index 00000000000..8631c96eb49 --- /dev/null +++ b/ktor-test-server/build.gradle.kts @@ -0,0 +1,36 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + `kotlin-dsl` + // Serialization version should be aligned with the Kotlin version embedded in Gradle + // https://docs.gradle.org/current/userguide/compatibility.html#kotlin + kotlin("plugin.serialization") version embeddedKotlinVersion +} + +dependencies { + implementation(libs.ktor.server.default.headers) + implementation(libs.ktor.server.netty) + implementation(libs.ktor.server.cio) + implementation(libs.ktor.server.jetty) + implementation(libs.ktor.server.websockets) + implementation(libs.ktor.server.auth) + implementation(libs.ktor.server.caching.headers) + implementation(libs.ktor.server.conditional.headers) + implementation(libs.ktor.server.compression) + implementation(libs.ktor.server.content.negotiation) + implementation(libs.ktor.server.status.pages) + implementation(libs.ktor.serialization.kotlinx) + implementation(libs.ktor.network.tls.certificates) + implementation(libs.ktor.utils) + + implementation(libs.kotlinx.serialization.json) + implementation(libs.logback.classic) + implementation(libs.tomlj) +} + +// Should be synced with gradle/gradle-daemon-jvm.properties +kotlin { + jvmToolchain(21) +} diff --git a/ktor-test-server/settings.gradle.kts b/ktor-test-server/settings.gradle.kts new file mode 100644 index 00000000000..735c50882a1 --- /dev/null +++ b/ktor-test-server/settings.gradle.kts @@ -0,0 +1,13 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +pluginManagement { + includeBuild("../gradle-settings-conventions") +} + +plugins { + id("conventions-dependency-resolution-management") +} + +rootProject.name = "ktor-test-server" diff --git a/ktor-test-server/src/main/kotlin/test-server.gradle.kts b/ktor-test-server/src/main/kotlin/test-server.gradle.kts new file mode 100644 index 00000000000..6af2a6a3fa9 --- /dev/null +++ b/ktor-test-server/src/main/kotlin/test-server.gradle.kts @@ -0,0 +1,13 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +import test.server.TestServerService + +val testServerService = TestServerService.registerIfAbsent(project) + +tasks.withType().configureEach { + usesService(testServerService) + // Trigger server start if it is not started yet + doFirst("start test server") { testServerService.get() } +} diff --git a/buildSrc/src/main/kotlin/test/server/ClientTestServer.kt b/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt similarity index 96% rename from buildSrc/src/main/kotlin/test/server/ClientTestServer.kt rename to ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt index 74a1f52eac4..2b463a29f87 100644 --- a/buildSrc/src/main/kotlin/test/server/ClientTestServer.kt +++ b/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server @@ -7,7 +7,6 @@ package test.server import io.ktor.client.tests.utils.tests.* import io.ktor.http.* import io.ktor.server.application.* -import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.plugins.defaultheaders.* import io.ktor.server.plugins.statuspages.* import io.ktor.server.request.* diff --git a/buildSrc/src/main/kotlin/test/server/ServerUtils.kt b/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt similarity index 93% rename from buildSrc/src/main/kotlin/test/server/ServerUtils.kt rename to ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt index 4b101ba1c91..8d733c90cba 100644 --- a/buildSrc/src/main/kotlin/test/server/ServerUtils.kt +++ b/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server @@ -8,7 +8,6 @@ import io.ktor.http.* import io.ktor.http.content.* import io.ktor.util.* import io.ktor.utils.io.* -import io.ktor.utils.io.charsets.* import io.ktor.utils.io.core.* fun makeArray(size: Int): ByteArray = ByteArray(size) { it.toByte() } diff --git a/buildSrc/src/main/kotlin/test/server/TestServer.kt b/ktor-test-server/src/main/kotlin/test/server/TestServer.kt similarity index 90% rename from buildSrc/src/main/kotlin/test/server/TestServer.kt rename to ktor-test-server/src/main/kotlin/test/server/TestServer.kt index e5e46d9fc3c..7fea30bfe14 100644 --- a/buildSrc/src/main/kotlin/test/server/TestServer.kt +++ b/ktor-test-server/src/main/kotlin/test/server/TestServer.kt @@ -8,9 +8,11 @@ import io.ktor.network.tls.certificates.* import io.ktor.server.cio.* import io.ktor.server.engine.* import io.ktor.server.jetty.jakarta.* -import test.server.tests.* -import java.io.* -import java.util.concurrent.* +import test.server.tests.CloseableGroup +import test.server.tests.tcpServerHandler +import java.io.Closeable +import java.io.File +import java.util.concurrent.TimeUnit const val TEST_SERVER: String = "http://127.0.0.1:8080" diff --git a/buildSrc/src/main/kotlin/test/server/TestServerPlugin.kt b/ktor-test-server/src/main/kotlin/test/server/TestServerService.kt similarity index 54% rename from buildSrc/src/main/kotlin/test/server/TestServerPlugin.kt rename to ktor-test-server/src/main/kotlin/test/server/TestServerService.kt index 674ef63832e..566f1963218 100644 --- a/buildSrc/src/main/kotlin/test/server/TestServerPlugin.kt +++ b/ktor-test-server/src/main/kotlin/test/server/TestServerService.kt @@ -4,28 +4,15 @@ package test.server -import org.gradle.api.* -import org.gradle.api.logging.* +import org.gradle.api.Project +import org.gradle.api.logging.Logging import org.gradle.api.provider.Provider -import org.gradle.api.services.* -import org.gradle.api.tasks.testing.* -import org.gradle.kotlin.dsl.* -import java.io.* +import org.gradle.api.services.BuildService +import org.gradle.api.services.BuildServiceParameters +import org.gradle.kotlin.dsl.registerIfAbsent +import java.io.Closeable -class TestServerPlugin : Plugin { - - override fun apply(target: Project) { - val testServerService = TestServerService.registerIfAbsent(target) - - target.tasks.withType().configureEach { - usesService(testServerService) - // Trigger server start if it is not started yet - doFirst("start test server") { testServerService.get() } - } - } -} - -private abstract class TestServerService : BuildService, AutoCloseable { +abstract class TestServerService : BuildService, AutoCloseable { private val logger = Logging.getLogger("TestServerService") private val server: Closeable diff --git a/buildSrc/src/main/kotlin/test/server/TestTcpServer.kt b/ktor-test-server/src/main/kotlin/test/server/TestTcpServer.kt similarity index 91% rename from buildSrc/src/main/kotlin/test/server/TestTcpServer.kt rename to ktor-test-server/src/main/kotlin/test/server/TestTcpServer.kt index 1f293efdcdb..65f7e551f72 100644 --- a/buildSrc/src/main/kotlin/test/server/TestTcpServer.kt +++ b/ktor-test-server/src/main/kotlin/test/server/TestTcpServer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server @@ -7,8 +7,8 @@ package test.server import io.ktor.network.selector.* import io.ktor.network.sockets.* import kotlinx.coroutines.* -import java.io.* -import kotlin.coroutines.* +import java.io.Closeable +import kotlin.coroutines.CoroutineContext @OptIn(DelicateCoroutinesApi::class) internal class TestTcpServer(val port: Int, handler: suspend (Socket) -> Unit) : CoroutineScope, Closeable { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Auth.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Auth.kt similarity index 98% rename from buildSrc/src/main/kotlin/test/server/tests/Auth.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Auth.kt index 9f0f7d22e2c..bfdad2456f2 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Auth.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Auth.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests @@ -12,8 +12,8 @@ import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.websocket.* import io.ktor.websocket.* -import kotlinx.coroutines.* -import java.security.* +import kotlinx.coroutines.delay +import java.security.MessageDigest internal fun Application.authTestServer() { install(Authentication) { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Bom.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Bom.kt similarity index 95% rename from buildSrc/src/main/kotlin/test/server/tests/Bom.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Bom.kt index 659105c680b..6baae56ac9f 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Bom.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Bom.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2023 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Builders.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Builders.kt similarity index 75% rename from buildSrc/src/main/kotlin/test/server/tests/Builders.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Builders.kt index 7b077156af8..191c793d6cb 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Builders.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Builders.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Cache.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Cache.kt similarity index 96% rename from buildSrc/src/main/kotlin/test/server/tests/Cache.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Cache.kt index ae1e2a826bc..c0148e49f5b 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Cache.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Cache.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests @@ -13,7 +13,7 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.util.date.* -import java.util.concurrent.atomic.* +import java.util.concurrent.atomic.AtomicInteger internal val counter = AtomicInteger(0) diff --git a/buildSrc/src/main/kotlin/test/server/tests/CloseableGroup.kt b/ktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt similarity index 78% rename from buildSrc/src/main/kotlin/test/server/tests/CloseableGroup.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt index 2c7c625429c..d71462fcfe3 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/CloseableGroup.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt @@ -1,10 +1,10 @@ /* - * Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests -import java.io.* +import java.io.Closeable class CloseableGroup : Closeable { private val resources = mutableListOf() diff --git a/buildSrc/src/main/kotlin/test/server/tests/Content.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Content.kt similarity index 94% rename from buildSrc/src/main/kotlin/test/server/tests/Content.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Content.kt index c0af3a20485..00ebf4d2e98 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Content.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Content.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests @@ -7,15 +7,13 @@ package test.server.tests import io.ktor.http.* import io.ktor.http.content.* import io.ktor.server.application.* -import io.ktor.server.http.content.file import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.* import io.ktor.utils.io.* -import io.ktor.utils.io.core.* -import kotlinx.coroutines.* -import test.server.* +import kotlinx.coroutines.delay +import test.server.fail +import test.server.makeString internal fun Application.contentTestServer() { routing { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Cookies.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Cookies.kt similarity index 97% rename from buildSrc/src/main/kotlin/test/server/tests/Cookies.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Cookies.kt index 8c1e7dc1537..98835874274 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Cookies.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Cookies.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Download.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Download.kt similarity index 87% rename from buildSrc/src/main/kotlin/test/server/tests/Download.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Download.kt index 5d85e92bd10..4f7cb41fd45 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Download.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Download.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests @@ -9,7 +9,7 @@ import io.ktor.http.content.* import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* -import kotlinx.coroutines.* +import kotlinx.coroutines.delay private val content: String = buildString { repeat(1875) { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Encoding.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Encoding.kt similarity index 98% rename from buildSrc/src/main/kotlin/test/server/tests/Encoding.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Encoding.kt index b3bdc02695a..f72e7950bef 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Encoding.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Encoding.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Events.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Events.kt similarity index 100% rename from buildSrc/src/main/kotlin/test/server/tests/Events.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Events.kt diff --git a/buildSrc/src/main/kotlin/test/server/tests/Features.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Features.kt similarity index 89% rename from buildSrc/src/main/kotlin/test/server/tests/Features.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Features.kt index 9b68ebc3219..d860b857f1e 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Features.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Features.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Forms.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Forms.kt similarity index 92% rename from buildSrc/src/main/kotlin/test/server/tests/Forms.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Forms.kt index 382c73882ab..97ea4c24903 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Forms.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Forms.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Headers.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Headers.kt similarity index 97% rename from buildSrc/src/main/kotlin/test/server/tests/Headers.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Headers.kt index 6d962a7d4f2..cb9478e29a9 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Headers.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Headers.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Json.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Json.kt similarity index 82% rename from buildSrc/src/main/kotlin/test/server/tests/Json.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Json.kt index 95bbbbbdbd3..8810cbc7184 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Json.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Json.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Logging.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Logging.kt similarity index 94% rename from buildSrc/src/main/kotlin/test/server/tests/Logging.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Logging.kt index 2132d7e429b..3425ca467c0 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Logging.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Logging.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/MultiPartFormData.kt b/ktor-test-server/src/main/kotlin/test/server/tests/MultiPartFormData.kt similarity index 94% rename from buildSrc/src/main/kotlin/test/server/tests/MultiPartFormData.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/MultiPartFormData.kt index 9b53033cf8c..56efb5324f8 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/MultiPartFormData.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/MultiPartFormData.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Multithreaded.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt similarity index 81% rename from buildSrc/src/main/kotlin/test/server/tests/Multithreaded.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt index f052c557388..81b5fa818e8 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Multithreaded.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package io.ktor.client.tests.utils.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/Redirect.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Redirect.kt similarity index 95% rename from buildSrc/src/main/kotlin/test/server/tests/Redirect.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Redirect.kt index 9f6f78ee55e..5a20ed9f1f6 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Redirect.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Redirect.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests @@ -8,7 +8,7 @@ import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* -import test.server.* +import test.server.TEST_SERVER internal fun Application.redirectTest() { routing { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Serialization.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Serialization.kt similarity index 93% rename from buildSrc/src/main/kotlin/test/server/tests/Serialization.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Serialization.kt index 370d1284d1d..e6598503c28 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Serialization.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Serialization.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/ServerSentEvents.kt b/ktor-test-server/src/main/kotlin/test/server/tests/ServerSentEvents.kt similarity index 95% rename from buildSrc/src/main/kotlin/test/server/tests/ServerSentEvents.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/ServerSentEvents.kt index 33589b9d9e9..713ad737b67 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/ServerSentEvents.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/ServerSentEvents.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2023 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests @@ -10,8 +10,10 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.utils.io.* -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.map internal fun Application.serverSentEvents() { routing { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Tcp.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Tcp.kt similarity index 94% rename from buildSrc/src/main/kotlin/test/server/tests/Tcp.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Tcp.kt index c2a60ce2db2..5b7c6f1d31b 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Tcp.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Tcp.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests @@ -10,7 +10,10 @@ import io.ktor.network.selector.* import io.ktor.network.sockets.* import io.ktor.util.* import io.ktor.utils.io.* -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.withTimeout internal suspend fun tcpServerHandler(socket: Socket) { val input = socket.openReadChannel() diff --git a/buildSrc/src/main/kotlin/test/server/tests/Timeout.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Timeout.kt similarity index 96% rename from buildSrc/src/main/kotlin/test/server/tests/Timeout.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Timeout.kt index 97915d42ddb..b0cab9d281d 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Timeout.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Timeout.kt @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package test.server.tests @@ -10,7 +10,7 @@ import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.utils.io.* -import kotlinx.coroutines.* +import kotlinx.coroutines.delay internal fun Application.timeoutTest() { routing { diff --git a/buildSrc/src/main/kotlin/test/server/tests/Upload.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Upload.kt similarity index 78% rename from buildSrc/src/main/kotlin/test/server/tests/Upload.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/Upload.kt index f888709ae17..f1d10492f66 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/Upload.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Upload.kt @@ -1,6 +1,6 @@ /* -* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. -*/ + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ package test.server.tests diff --git a/buildSrc/src/main/kotlin/test/server/tests/WebSockets.kt b/ktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt similarity index 97% rename from buildSrc/src/main/kotlin/test/server/tests/WebSockets.kt rename to ktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt index f2e5f6432ba..0e173b6429d 100644 --- a/buildSrc/src/main/kotlin/test/server/tests/WebSockets.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt @@ -9,8 +9,8 @@ import io.ktor.server.routing.* import io.ktor.server.websocket.* import io.ktor.util.* import io.ktor.websocket.* -import kotlinx.serialization.* -import kotlinx.serialization.json.* +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json internal fun Application.webSockets() { routing { diff --git a/settings.gradle.kts b/settings.gradle.kts index 8f92f0a6be3..90f8c89fe09 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,6 +14,8 @@ plugins { rootProject.name = "ktor" +includeBuild("ktor-test-server") + include(":ktor-server") include(":ktor-server:ktor-server-core") include(":ktor-server:ktor-server-config-yaml")