From b9103abe2c584465a5cc46f8419b9bd9dbd44697 Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Tue, 7 Nov 2023 09:02:06 +0100 Subject: [PATCH] 4.x Enable tests that were disabled during renaming to jakarta packages work (#7949) Signed-off-by: tvallin --- .../micronaut/data/BeanValidationExceptionMapper.java | 5 +++-- .../integrations/micronaut/data/PetResource.java | 3 ++- .../micronaut/data/MicronautExampleTest.java | 4 ---- examples/microprofile/cors/pom.xml | 5 +++++ .../microprofile/examples/cors/GreetResource.java | 4 ++-- .../helidon/microprofile/examples/cors/TestCORS.java | 11 ++++++----- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/BeanValidationExceptionMapper.java b/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/BeanValidationExceptionMapper.java index 8407cb1c914..ca2f919979a 100644 --- a/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/BeanValidationExceptionMapper.java +++ b/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/BeanValidationExceptionMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,8 @@ package io.helidon.examples.integrations.micronaut.data; -import jakarta.validation.ConstraintViolationException; +import javax.validation.ConstraintViolationException; + import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.Provider; diff --git a/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/PetResource.java b/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/PetResource.java index 6bd15892796..87bc2391b4a 100644 --- a/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/PetResource.java +++ b/examples/integrations/micronaut/data/src/main/java/io/helidon/examples/integrations/micronaut/data/PetResource.java @@ -16,10 +16,11 @@ package io.helidon.examples.integrations.micronaut.data; +import javax.validation.constraints.Pattern; + import io.helidon.examples.integrations.micronaut.data.model.Pet; import jakarta.inject.Inject; -import jakarta.validation.constraints.Pattern; import jakarta.ws.rs.GET; import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.Path; diff --git a/examples/integrations/micronaut/data/src/test/java/io/helidon/examples/integrations/micronaut/data/MicronautExampleTest.java b/examples/integrations/micronaut/data/src/test/java/io/helidon/examples/integrations/micronaut/data/MicronautExampleTest.java index a20730e23e4..40681eae743 100644 --- a/examples/integrations/micronaut/data/src/test/java/io/helidon/examples/integrations/micronaut/data/MicronautExampleTest.java +++ b/examples/integrations/micronaut/data/src/test/java/io/helidon/examples/integrations/micronaut/data/MicronautExampleTest.java @@ -24,16 +24,12 @@ import jakarta.json.JsonObject; import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Response; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @HelidonTest -@Disabled("3.0.0-JAKARTA") // Micronaut - validation Error instantiating bean of type -// [io.helidon.examples.integrations.micronaut.data.DbPopulateData$ApplicationEventListener$init1$Intercepted]: -// Error loading bean [io.micronaut.validation.ValidatingInterceptor]: javax/validation/Validator class MicronautExampleTest { @Inject private WebTarget webTarget; diff --git a/examples/microprofile/cors/pom.xml b/examples/microprofile/cors/pom.xml index d9321957b61..6cb55571a0b 100644 --- a/examples/microprofile/cors/pom.xml +++ b/examples/microprofile/cors/pom.xml @@ -70,6 +70,11 @@ helidon-webclient test + + io.helidon.http.media + helidon-http-media-jsonb + test + diff --git a/examples/microprofile/cors/src/main/java/io/helidon/microprofile/examples/cors/GreetResource.java b/examples/microprofile/cors/src/main/java/io/helidon/microprofile/examples/cors/GreetResource.java index 7a8b4bb2dae..3975512f249 100644 --- a/examples/microprofile/cors/src/main/java/io/helidon/microprofile/examples/cors/GreetResource.java +++ b/examples/microprofile/cors/src/main/java/io/helidon/microprofile/examples/cors/GreetResource.java @@ -94,10 +94,10 @@ public GreetingMessage getMessage(@PathParam("name") String name) { @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @RequestBody(name = "greeting", + @RequestBody(name = "message", required = true, content = @Content(mediaType = "application/json", - schema = @Schema(type = SchemaType.OBJECT, requiredProperties = { "greeting" }))) + schema = @Schema(type = SchemaType.OBJECT, requiredProperties = { "message" }))) @APIResponses({ @APIResponse(name = "normal", responseCode = "204", description = "Greeting updated"), @APIResponse(name = "missing 'greeting'", responseCode = "400", diff --git a/examples/microprofile/cors/src/test/java/io/helidon/microprofile/examples/cors/TestCORS.java b/examples/microprofile/cors/src/test/java/io/helidon/microprofile/examples/cors/TestCORS.java index 3a2d3e3ec04..2673f5b4539 100644 --- a/examples/microprofile/cors/src/test/java/io/helidon/microprofile/examples/cors/TestCORS.java +++ b/examples/microprofile/cors/src/test/java/io/helidon/microprofile/examples/cors/TestCORS.java @@ -23,6 +23,7 @@ import io.helidon.http.HeaderNames; import io.helidon.http.Headers; import io.helidon.http.Method; +import io.helidon.http.media.jsonb.JsonbSupport; import io.helidon.microprofile.server.Server; import io.helidon.webclient.http1.Http1Client; import io.helidon.webclient.http1.Http1ClientRequest; @@ -46,8 +47,6 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -@Disabled("3.0.0-JAKARTA") // OpenAPI: Caused by: java.lang.NoSuchMethodError: -// 'java.util.List io.smallrye.jandex.ClassInfo.unsortedFields()' public class TestCORS { private static Http1Client client; @@ -55,7 +54,8 @@ public class TestCORS { @BeforeAll static void init() { - Config serverConfig = Config.create().get("server"); + Config config = Config.create(); + Config serverConfig = config.get("server"); Server.Builder serverBuilder = Server.builder(); serverConfig.ifExists(serverBuilder::config); server = serverBuilder @@ -64,6 +64,7 @@ static void init() { .start(); client = Http1Client.builder() .baseUri("http://localhost:" + server.port()) + .addMediaSupport(JsonbSupport.create(config)) .build(); } @@ -184,7 +185,7 @@ void testNamedGreetWithCors() { @Test void testGreetingChangeWithCorsAndOtherOrigin() { Http1ClientRequest req = client.put() - .header(HeaderNames.ORIGIN, "http://foo.com") + .header(HeaderNames.ORIGIN, "http://other.com") .header(HeaderNames.HOST, "here.com"); try (Http1ClientResponse r = putResponse("/greet/greeting", "Ahoy", req)) { @@ -213,7 +214,7 @@ private static String fromPayload(Http1ClientResponse response) { } private static GreetingMessage toPayload(String message) { - return new GreetingMessage(message); + return new GreetingMessage(message); } private static Http1ClientResponse putResponse(String path, String message) {