Skip to content

Commit 9795627

Browse files
committed
Move ktor test suite to jvmAndNative
1 parent f8135f6 commit 9795627

File tree

12 files changed

+14
-20
lines changed

12 files changed

+14
-20
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ docker-transport-zerodep = { module = "com.github.docker-java:docker-java-transp
9191
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor-version" }
9292
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor-version" }
9393
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor-version" }
94+
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor-version" }
9495
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor-version" }
9596
ktor-server-jetty-jakarta = { module = "io.ktor:ktor-server-jetty-jakarta", version.ref = "ktor-version" }
9697
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor-version" }

runtime/protocol/http-client-engines/test-suite/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ kotlin {
3838

3939
jvmAndNativeMain {
4040
dependencies {
41+
implementation(libs.ktor.server.core)
4142
implementation(libs.kotlinx.coroutines.test)
4243
}
4344
}

runtime/protocol/http-client-engines/test-suite/jvm/src/aws/smithy/kotlin/runtime/http/test/util/TestServers.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import aws.smithy.kotlin.runtime.http.test.suite.tlsTests
1212
import aws.smithy.kotlin.runtime.http.test.suite.uploadTests
1313
import io.ktor.server.application.*
1414
import io.ktor.server.engine.*
15-
import io.ktor.server.jetty.*
1615
import io.ktor.server.jetty.jakarta.Jetty
1716
import io.ktor.server.jetty.jakarta.JettyApplicationEngineBase
1817
import redirectTests
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/*
2-
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
* SPDX-License-Identifier: Apache-2.0
4-
*/
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
55

66
package aws.smithy.kotlin.runtime.http.test.suite
77

88
import io.ktor.server.application.*
99
import io.ktor.server.response.*
1010
import io.ktor.server.routing.*
11+
import io.ktor.utils.io.writeFully
1112
import kotlinx.coroutines.delay
1213
import kotlin.time.Duration.Companion.milliseconds
1314

@@ -24,10 +25,10 @@ internal fun Application.concurrentTests() {
2425
route("slow") {
2526
get {
2627
val chunk = ByteArray(256) { it.toByte() }
27-
call.respondOutputStream {
28+
call.respondBytesWriter {
2829
repeat(10) {
2930
delay(200.milliseconds)
30-
write(chunk)
31+
writeFully(chunk)
3132
}
3233
}
3334
}
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
package aws.smithy.kotlin.runtime.http.test.suite
77

88
import aws.smithy.kotlin.runtime.hashing.sha256
9+
import aws.smithy.kotlin.runtime.io.GzipSdkSource
10+
import aws.smithy.kotlin.runtime.io.readToByteArray
11+
import aws.smithy.kotlin.runtime.io.source
912
import aws.smithy.kotlin.runtime.text.encoding.encodeToHex
1013
import io.ktor.http.*
1114
import io.ktor.server.application.*
1215
import io.ktor.server.response.*
1316
import io.ktor.server.routing.*
1417
import io.ktor.utils.io.*
1518
import kotlinx.coroutines.delay
16-
import java.io.ByteArrayOutputStream
17-
import java.util.zip.GZIPOutputStream
1819
import kotlin.random.Random
1920

2021
internal const val DOWNLOAD_SIZE = 16L * 1024 * 1024 // 16MB
@@ -53,18 +54,9 @@ internal fun Application.downloadTests() {
5354
call.response.header("x-bar", "bar")
5455
}
5556

56-
// FIXME This is the only thing keeping this directory in `jvm`, could be `jvmAndNative`
5757
get("/gzipped") {
5858
val uncompressed = ByteArray(1024) { it.toByte() }
59-
val compressed = ByteArrayOutputStream().use { baStream ->
60-
GZIPOutputStream(baStream).use { gzStream ->
61-
gzStream.write(uncompressed)
62-
gzStream.flush()
63-
}
64-
baStream.flush()
65-
baStream.toByteArray()
66-
}
67-
59+
val compressed = GzipSdkSource(uncompressed.source()).readToByteArray()
6860
call.response.header("Content-Encoding", "gzip")
6961
call.respondBytes(compressed)
7062
}

0 commit comments

Comments
 (0)