Skip to content

Commit

Permalink
Try to migrate to HttpClient for Java requests
Browse files Browse the repository at this point in the history
  • Loading branch information
OptimumCode committed Oct 14, 2024
1 parent 43b9a8a commit 92d6215
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ package io.github.optimumcode.json.schema
import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.core.spec.style.FunSpec
import kotlinx.serialization.ExperimentalSerializationApi
import java.net.URL
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.newHttpClient()
val response =
client.send(
HttpRequest.newBuilder(URI.create("https://json-schema.org/draft-07/schema#"))
.GET()
.timeout(Duration.ofSeconds(10))
.build(),
BodyHandlers.ofInputStream(),
)
response.body().use(JsonSchema::fromStream)
}
}
}
Expand Down

0 comments on commit 92d6215

Please sign in to comment.