Skip to content
Merged
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "2.0.10"
kotest = "5.9.1"
kotlin = "2.0.21"
kotest = "6.0.0.M1"
detekt = "1.23.7"
ktlint = "1.1.0"
okio = "3.9.1"
Expand Down
2 changes: 1 addition & 1 deletion json-schema-validator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
package io.github.optimumcode.json.schema

import io.kotest.assertions.asClue
import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.core.spec.style.FunSpec
import kotlinx.serialization.ExperimentalSerializationApi
import java.net.URL
import java.io.ByteArrayInputStream
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse.BodyHandlers
import java.time.Duration

@OptIn(ExperimentalSerializationApi::class)
@Suppress("unused")
class JsonSchemaStreamTest : FunSpec() {
init {
test("definition is loaded from input stream") {
shouldNotThrowAny {
URL("https://json-schema.org/draft-07/schema#").openStream().use { input ->
JsonSchema.fromStream(input)

val client =
HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NORMAL)
.build()

val response =
client.send(
HttpRequest.newBuilder(URI.create("https://json-schema.org/draft-07/schema#"))
.GET()
.timeout(Duration.ofSeconds(10))
.build(),
BodyHandlers.ofByteArray(),
)
val body = response.body()
"Response code: ${response.statusCode()}".asClue {
body.toString(Charsets.UTF_8).asClue {
shouldNotThrowAny {
JsonSchema.fromStream(ByteArrayInputStream(body))
}
}
}
}
Expand Down
Loading
Loading