File tree Expand file tree Collapse file tree 4 files changed +153
-120
lines changed
src/jvmTest/kotlin/io/github/optimumcode/json/schema Expand file tree Collapse file tree 4 files changed +153
-120
lines changed Original file line number Diff line number Diff line change 11[versions ]
2- kotlin = " 2.0.10 "
3- kotest = " 5.9.1 "
2+ kotlin = " 2.0.21 "
3+ kotest = " 6.0.0.M1 "
44detekt = " 1.23.7"
55ktlint = " 1.1.0"
66okio = " 3.9.1"
Original file line number Diff line number Diff line change 22
33import io.gitlab.arturbosch.detekt.Detekt
44import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
5+ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
56import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
67import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
7- import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
88import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
99
1010plugins {
Original file line number Diff line number Diff line change 11package io.github.optimumcode.json.schema
22
3+ import io.kotest.assertions.asClue
34import io.kotest.assertions.throwables.shouldNotThrowAny
45import io.kotest.core.spec.style.FunSpec
56import 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
713
814@OptIn(ExperimentalSerializationApi ::class )
915@Suppress(" unused" )
1016class JsonSchemaStreamTest : FunSpec () {
1117 init {
1218 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+ }
1639 }
1740 }
1841 }
You can’t perform that action at this time.
0 commit comments