File tree 4 files changed +153
-120
lines changed
src/jvmTest/kotlin/io/github/optimumcode/json/schema
4 files changed +153
-120
lines changed Original file line number Diff line number Diff line change 1
1
[versions ]
2
- kotlin = " 2.0.10 "
3
- kotest = " 5.9.1 "
2
+ kotlin = " 2.0.21 "
3
+ kotest = " 6.0.0.M1 "
4
4
detekt = " 1.23.7"
5
5
ktlint = " 1.1.0"
6
6
okio = " 3.9.1"
Original file line number Diff line number Diff line change 2
2
3
3
import io.gitlab.arturbosch.detekt.Detekt
4
4
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
5
+ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
5
6
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
6
7
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
7
- import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
8
8
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
9
9
10
10
plugins {
Original file line number Diff line number Diff line change 1
1
package io.github.optimumcode.json.schema
2
2
3
+ import io.kotest.assertions.asClue
3
4
import io.kotest.assertions.throwables.shouldNotThrowAny
4
5
import io.kotest.core.spec.style.FunSpec
5
6
import kotlinx.serialization.ExperimentalSerializationApi
6
- import java.net.URL
7
+ import java.io.ByteArrayInputStream
8
+ import java.net.URI
9
+ import java.net.http.HttpClient
10
+ import java.net.http.HttpRequest
11
+ import java.net.http.HttpResponse.BodyHandlers
12
+ import java.time.Duration
7
13
8
14
@OptIn(ExperimentalSerializationApi ::class )
9
15
@Suppress(" unused" )
10
16
class JsonSchemaStreamTest : FunSpec () {
11
17
init {
12
18
test(" definition is loaded from input stream" ) {
13
- shouldNotThrowAny {
14
- URL (" https://json-schema.org/draft-07/schema#" ).openStream().use { input ->
15
- JsonSchema .fromStream(input)
19
+
20
+ val client =
21
+ HttpClient .newBuilder()
22
+ .followRedirects(HttpClient .Redirect .NORMAL )
23
+ .build()
24
+
25
+ val response =
26
+ client.send(
27
+ HttpRequest .newBuilder(URI .create(" https://json-schema.org/draft-07/schema#" ))
28
+ .GET ()
29
+ .timeout(Duration .ofSeconds(10 ))
30
+ .build(),
31
+ BodyHandlers .ofByteArray(),
32
+ )
33
+ val body = response.body()
34
+ " Response code: ${response.statusCode()} " .asClue {
35
+ body.toString(Charsets .UTF_8 ).asClue {
36
+ shouldNotThrowAny {
37
+ JsonSchema .fromStream(ByteArrayInputStream (body))
38
+ }
16
39
}
17
40
}
18
41
}
You can’t perform that action at this time.
0 commit comments