File tree 1 file changed +15
-4
lines changed
json-schema-validator/src/jvmTest/kotlin/io/github/optimumcode/json/schema
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,28 @@ package io.github.optimumcode.json.schema
3
3
import io.kotest.assertions.throwables.shouldNotThrowAny
4
4
import io.kotest.core.spec.style.FunSpec
5
5
import kotlinx.serialization.ExperimentalSerializationApi
6
- import java.net.URL
6
+ import java.net.URI
7
+ import java.net.http.HttpClient
8
+ import java.net.http.HttpRequest
9
+ import java.net.http.HttpResponse.BodyHandlers
10
+ import java.time.Duration
7
11
8
12
@OptIn(ExperimentalSerializationApi ::class )
9
13
@Suppress(" unused" )
10
14
class JsonSchemaStreamTest : FunSpec () {
11
15
init {
12
16
test(" definition is loaded from input stream" ) {
13
17
shouldNotThrowAny {
14
- URL (" https://json-schema.org/draft-07/schema#" ).openStream().use { input ->
15
- JsonSchema .fromStream(input)
16
- }
18
+ val client = HttpClient .newHttpClient()
19
+ val response =
20
+ client.send(
21
+ HttpRequest .newBuilder(URI .create(" https://json-schema.org/draft-07/schema#" ))
22
+ .GET ()
23
+ .timeout(Duration .ofSeconds(10 ))
24
+ .build(),
25
+ BodyHandlers .ofInputStream(),
26
+ )
27
+ response.body().use(JsonSchema ::fromStream)
17
28
}
18
29
}
19
30
}
You can’t perform that action at this time.
0 commit comments