-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTOR-7731 Add implementation for the deprecated FileItem.streamProvid…
…er (#4469)
- Loading branch information
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ktor-http/jvm/test/io/ktor/tests/http/content/MultipartJvmTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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.tests.http.content | ||
|
||
import io.ktor.http.* | ||
import io.ktor.http.content.* | ||
import io.ktor.utils.io.* | ||
import kotlin.test.* | ||
|
||
class MultipartJvmTest { | ||
|
||
@Suppress("DEPRECATION") | ||
@Test | ||
fun testStreamProvider() { | ||
val fileItem = PartData.FileItem({ ByteReadChannel(ByteArray(4097) { 1 }) }, {}, Headers.Empty) | ||
val stream = fileItem.streamProvider() | ||
|
||
val buffer = ByteArray(4097) | ||
val read = stream.read(buffer) | ||
assertEquals(4097, read) | ||
assertEquals(ByteArray(4097) { 1 }.toList(), buffer.toList()) | ||
} | ||
} |