Search in sources :

Example 11 with JsonObject

use of jakarta.json.JsonObject in project resteasy by resteasy.

the class AbstractDigestAuthenticationTest method digestAsyncAuth.

@Test
public void digestAsyncAuth() throws Exception {
    try (Client client = ClientBuilder.newBuilder().register(HttpAuthenticators.digest(CREDENTIALS_USER_1)).build()) {
        final Response response = client.target(TestUtil.generateUri(url, "user")).request(MediaType.APPLICATION_JSON_TYPE).async().get().get(5, TimeUnit.SECONDS);
        Assert.assertEquals(Response.Status.OK, response.getStatusInfo());
        final JsonObject json = response.readEntity(JsonObject.class);
        validate(json);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) JsonObject(jakarta.json.JsonObject) Client(jakarta.ws.rs.client.Client) Test(org.junit.Test)

Example 12 with JsonObject

use of jakarta.json.JsonObject in project zilla by aklivity.

the class HttpConditionConfigAdapter method adaptFromJson.

@Override
public ConditionConfig adaptFromJson(JsonObject object) {
    JsonObject headers = object.containsKey(HEADERS_NAME) ? object.getJsonObject(HEADERS_NAME) : null;
    Map<String, String> newHeaders = null;
    if (headers != null) {
        Map<String, String> newHeaders0 = new LinkedHashMap<>();
        headers.forEach((k, v) -> newHeaders0.put(k, JsonString.class.cast(v).getString()));
        newHeaders = newHeaders0;
    }
    return new HttpConditionConfig(newHeaders);
}
Also used : JsonObject(jakarta.json.JsonObject) JsonString(jakarta.json.JsonString) JsonString(jakarta.json.JsonString) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with JsonObject

use of jakarta.json.JsonObject in project zilla by aklivity.

the class WsOptionsConfigAdapter method adaptFromJson.

@Override
public OptionsConfig adaptFromJson(JsonObject object) {
    JsonObject defaults = object.containsKey(DEFAULTS_NAME) ? object.getJsonObject(DEFAULTS_NAME) : null;
    String protocol = null;
    String scheme = null;
    String authority = null;
    String path = null;
    if (defaults != null) {
        if (defaults.containsKey(PROTOCOL_NAME)) {
            protocol = defaults.getString(PROTOCOL_NAME);
        }
        if (defaults.containsKey(SCHEME_NAME)) {
            scheme = defaults.getString(SCHEME_NAME);
        }
        if (defaults.containsKey(AUTHORITY_NAME)) {
            authority = defaults.getString(AUTHORITY_NAME);
        }
        if (defaults.containsKey(PATH_NAME)) {
            path = defaults.getString(PATH_NAME);
        }
    }
    return new WsOptionsConfig(protocol, scheme, authority, path);
}
Also used : JsonObject(jakarta.json.JsonObject)

Example 14 with JsonObject

use of jakarta.json.JsonObject in project zilla by aklivity.

the class BindingConfigsAdapter method adaptFromJson.

@Override
public BindingConfig[] adaptFromJson(JsonObject object) {
    List<BindingConfig> bindings = new LinkedList<>();
    for (String entry : object.keySet()) {
        JsonObject item = object.getJsonObject(entry);
        String type = item.getString(TYPE_NAME);
        route.adaptType(type);
        options.adaptType(type);
        NamespacedRef vault = item.containsKey(VAULT_NAME) ? NamespacedRef.of(item.getString(VAULT_NAME)) : null;
        KindConfig kind = this.kind.adaptFromJson(item.getJsonString(KIND_NAME));
        OptionsConfig opts = item.containsKey(OPTIONS_NAME) ? options.adaptFromJson(item.getJsonObject(OPTIONS_NAME)) : null;
        MutableInteger order = new MutableInteger();
        List<RouteConfig> routes = item.containsKey(ROUTES_NAME) ? item.getJsonArray(ROUTES_NAME).stream().map(JsonValue::asJsonObject).peek(o -> route.adaptFromJsonIndex(order.value++)).map(route::adaptFromJson).collect(toList()) : ROUTES_DEFAULT;
        RouteConfig exit = item.containsKey(EXIT_NAME) ? new RouteConfig(routes.size(), item.getString(EXIT_NAME)) : null;
        bindings.add(new BindingConfig(vault, entry, type, kind, opts, routes, exit));
    }
    return bindings.toArray(BindingConfig[]::new);
}
Also used : JsonValue(jakarta.json.JsonValue) Collections.emptyList(java.util.Collections.emptyList) JsonArrayBuilder(jakarta.json.JsonArrayBuilder) BindingConfig(io.aklivity.zilla.runtime.engine.config.BindingConfig) Json(jakarta.json.Json) JsonbAdapter(jakarta.json.bind.adapter.JsonbAdapter) JsonObjectBuilder(jakarta.json.JsonObjectBuilder) OptionsConfigAdapterSpi(io.aklivity.zilla.runtime.engine.config.OptionsConfigAdapterSpi) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) OptionsConfig(io.aklivity.zilla.runtime.engine.config.OptionsConfig) RouteConfig(io.aklivity.zilla.runtime.engine.config.RouteConfig) JsonObject(jakarta.json.JsonObject) KindConfig(io.aklivity.zilla.runtime.engine.config.KindConfig) LinkedList(java.util.LinkedList) MutableInteger(org.agrona.collections.MutableInteger) NamespacedRef(io.aklivity.zilla.runtime.engine.config.NamespacedRef) OptionsConfig(io.aklivity.zilla.runtime.engine.config.OptionsConfig) MutableInteger(org.agrona.collections.MutableInteger) JsonValue(jakarta.json.JsonValue) JsonObject(jakarta.json.JsonObject) RouteConfig(io.aklivity.zilla.runtime.engine.config.RouteConfig) NamespacedRef(io.aklivity.zilla.runtime.engine.config.NamespacedRef) LinkedList(java.util.LinkedList) BindingConfig(io.aklivity.zilla.runtime.engine.config.BindingConfig) KindConfig(io.aklivity.zilla.runtime.engine.config.KindConfig)

Example 15 with JsonObject

use of jakarta.json.JsonObject in project zilla by aklivity.

the class SchemaTest method shouldValidateServerTcp4SslVersion.

@Test
public void shouldValidateServerTcp4SslVersion() {
    JsonObject config = schema.validate("server.tcp4.ssl.version.json");
    assertThat(config, not(nullValue()));
}
Also used : JsonObject(jakarta.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonObject (jakarta.json.JsonObject)356 Test (org.junit.Test)125 Test (org.junit.jupiter.api.Test)92 JsonArray (jakarta.json.JsonArray)29 Response (jakarta.ws.rs.core.Response)29 JsonObjectBuilder (jakarta.json.JsonObjectBuilder)24 JsonString (jakarta.json.JsonString)24 JsonValue (jakarta.json.JsonValue)20 WebClientResponse (io.helidon.webclient.WebClientResponse)19 Client (jakarta.ws.rs.client.Client)18 StringReader (java.io.StringReader)17 HelidonTest (io.helidon.microprofile.tests.junit5.HelidonTest)15 JsonReader (jakarta.json.JsonReader)14 List (java.util.List)14 JsonException (jakarta.json.JsonException)13 Map (java.util.Map)13 Logger (java.util.logging.Logger)13 Routing (io.helidon.webserver.Routing)11 Json (jakarta.json.Json)11 Produces (jakarta.ws.rs.Produces)11