From 5f90f74f3de34116065e1684e271087036b72290 Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Tue, 3 Oct 2023 10:07:17 +0200 Subject: [PATCH] 3.x: Enable tests that were disabled during renaming to jakarta packages work (#7606) Signed-off-by: tvallin --- .../integrations/cdi/pokemon/MainTest.java | 4 +--- .../data/BeanValidationExceptionMapper.java | 5 +++-- .../micronaut/data/PetResource.java | 5 +++-- .../micronaut/data/MicronautExampleTest.java | 4 ---- .../integrations/neo4j/mp/MainTest.java | 7 ++----- .../implicit/ImplicitHelloWorldTest.java | 5 +---- .../examples/openapi/basic/MainTest.java | 3 --- .../io/helidon/examples/openapi/MainTest.java | 5 +---- .../faulttolerance/RetryTest.java | 2 -- .../io/helidon/openapi/OpenAPISupport.java | 20 ++++++++++++++----- .../io/helidon/tests/bookstore/MainTest.java | 5 +---- .../functional/multipleapps/MainTest.java | 4 +--- .../zipkin/mp22/ZipkinMp22Test.java | 4 +--- 13 files changed, 29 insertions(+), 44 deletions(-) diff --git a/examples/integrations/cdi/pokemons/src/test/java/io/helidon/examples/integrations/cdi/pokemon/MainTest.java b/examples/integrations/cdi/pokemons/src/test/java/io/helidon/examples/integrations/cdi/pokemon/MainTest.java index 83bec4a5ebc..43ee2ebc03f 100644 --- a/examples/integrations/cdi/pokemons/src/test/java/io/helidon/examples/integrations/cdi/pokemon/MainTest.java +++ b/examples/integrations/cdi/pokemons/src/test/java/io/helidon/examples/integrations/cdi/pokemon/MainTest.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. @@ -28,13 +28,11 @@ import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -@Disabled("3.0.0-JAKARTA") // persistence.xml failure class MainTest { private static Server server; 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 c6cf5b4a0d6..4c18e721b84 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 @@ -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,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 0578788dc0a..44b5d1de35a 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/integrations/neo4j/neo4j-mp/src/test/java/io/helidon/examples/integrations/neo4j/mp/MainTest.java b/examples/integrations/neo4j/neo4j-mp/src/test/java/io/helidon/examples/integrations/neo4j/mp/MainTest.java index 50d381daf4c..15946eb8d7b 100644 --- a/examples/integrations/neo4j/neo4j-mp/src/test/java/io/helidon/examples/integrations/neo4j/mp/MainTest.java +++ b/examples/integrations/neo4j/neo4j-mp/src/test/java/io/helidon/examples/integrations/neo4j/mp/MainTest.java @@ -26,7 +26,6 @@ import jakarta.ws.rs.client.ClientBuilder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.neo4j.harness.Neo4j; import org.neo4j.harness.Neo4jBuilders; @@ -37,8 +36,6 @@ /** * Main tests of the application done here. */ -@Disabled("3.0.0-JAKARTA") // OpenAPI -// Caused by: java.lang.NoSuchMethodError: 'java.util.List org.jboss.jandex.ClassInfo.unsortedFields()' class MainTest { private static Server server; private static Neo4j embeddedDatabaseServer; @@ -70,11 +67,11 @@ void testMovies() { Client client = ClientBuilder.newClient(); - JsonArray jsorArray = client + JsonArray jsonArray = client .target(getConnectionString("/movies")) .request() .get(JsonArray.class); - JsonObject first = jsorArray.getJsonObject(0); + JsonObject first = jsonArray.getJsonObject(0); assertThat(first.getString("title"), is("The Matrix")); } diff --git a/examples/microprofile/hello-world-implicit/src/test/java/io/helidon/microprofile/example/helloworld/implicit/ImplicitHelloWorldTest.java b/examples/microprofile/hello-world-implicit/src/test/java/io/helidon/microprofile/example/helloworld/implicit/ImplicitHelloWorldTest.java index 2e5e7e3b072..e6cc1e9b229 100644 --- a/examples/microprofile/hello-world-implicit/src/test/java/io/helidon/microprofile/example/helloworld/implicit/ImplicitHelloWorldTest.java +++ b/examples/microprofile/hello-world-implicit/src/test/java/io/helidon/microprofile/example/helloworld/implicit/ImplicitHelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021 Oracle and/or its affiliates. + * Copyright (c) 2018, 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. @@ -21,7 +21,6 @@ import jakarta.inject.Inject; import jakarta.json.JsonObject; import jakarta.ws.rs.client.WebTarget; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -32,8 +31,6 @@ * Unit test for {@link HelloWorldResource}. */ @HelidonTest -@Disabled("3.0.0-JAKARTA") // OpenAPI: Caused by: java.lang.NoSuchMethodError: - // 'java.util.List org.jboss.jandex.ClassInfo.unsortedFields()' class ImplicitHelloWorldTest { private final WebTarget target; diff --git a/examples/microprofile/openapi-basic/src/test/java/io/helidon/microprofile/examples/openapi/basic/MainTest.java b/examples/microprofile/openapi-basic/src/test/java/io/helidon/microprofile/examples/openapi/basic/MainTest.java index d17a7c8d130..652c9fb9bf4 100644 --- a/examples/microprofile/openapi-basic/src/test/java/io/helidon/microprofile/examples/openapi/basic/MainTest.java +++ b/examples/microprofile/openapi-basic/src/test/java/io/helidon/microprofile/examples/openapi/basic/MainTest.java @@ -32,14 +32,11 @@ import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -@Disabled("3.0.0-JAKARTA") // OpenAPI: Caused by: java.lang.NoSuchMethodError: - // 'java.util.List org.jboss.jandex.ClassInfo.unsortedFields()' class MainTest { private static Server server; diff --git a/examples/openapi/src/test/java/io/helidon/examples/openapi/MainTest.java b/examples/openapi/src/test/java/io/helidon/examples/openapi/MainTest.java index 16299df8a79..d4da62fcd8b 100644 --- a/examples/openapi/src/test/java/io/helidon/examples/openapi/MainTest.java +++ b/examples/openapi/src/test/java/io/helidon/examples/openapi/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022 Oracle and/or its affiliates. + * Copyright (c) 2018, 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. @@ -32,14 +32,11 @@ import jakarta.json.JsonString; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -@Disabled("3.0.0-JAKARTA") // OpenAPI: org.yaml.snakeyaml.constructor.ConstructorException: -// Cannot create property=paths for JavaBean=io.smallrye.openapi.api.models.OpenAPIImpl@5dcd8c7a public class MainTest { private static WebServer webServer; diff --git a/microprofile/fault-tolerance/src/test/java/io/helidon/microprofile/faulttolerance/RetryTest.java b/microprofile/fault-tolerance/src/test/java/io/helidon/microprofile/faulttolerance/RetryTest.java index 640f4c41366..4db82d9448d 100644 --- a/microprofile/fault-tolerance/src/test/java/io/helidon/microprofile/faulttolerance/RetryTest.java +++ b/microprofile/fault-tolerance/src/test/java/io/helidon/microprofile/faulttolerance/RetryTest.java @@ -23,7 +23,6 @@ import io.helidon.microprofile.tests.junit5.AddBean; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -36,7 +35,6 @@ */ @AddBean(RetryBean.class) @AddBean(SyntheticRetryBean.class) -@Disabled("3.0.0-JAKARTA") public class RetryTest extends FaultToleranceTest { static Stream createBeans() { diff --git a/openapi/src/main/java/io/helidon/openapi/OpenAPISupport.java b/openapi/src/main/java/io/helidon/openapi/OpenAPISupport.java index 222f1313580..401955c4c6e 100644 --- a/openapi/src/main/java/io/helidon/openapi/OpenAPISupport.java +++ b/openapi/src/main/java/io/helidon/openapi/OpenAPISupport.java @@ -561,8 +561,7 @@ private Optional chooseResponseMediaType(ServerRequest req) { private static class HelidonAnnotationScannerExtension implements AnnotationScannerExtension { @Override - public Object parseExtension(String key, String value) { - + public Object parseValue(String value) { // Inspired by SmallRye's JsonUtil#parseValue method. if (value == null) { return null; @@ -594,10 +593,9 @@ public Object parseExtension(String key, String value) { JsonValue jsonValue = reader.readValue(); return convertJsonValue(jsonValue); } catch (Exception ex) { - LOGGER.log(Level.SEVERE, String.format("Error parsing extension key: %s, value: %s", key, value), ex); + LOGGER.log(Level.SEVERE, String.format("Error parsing value: %s", value), ex); + throw ex; } - break; - default: break; } @@ -606,6 +604,18 @@ public Object parseExtension(String key, String value) { return value; } + @Override + public Object parseExtension(String key, String value) { + try { + return parseValue(value); + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, + String.format("Error parsing extension key: %s, value: %s", key, value), + ex); + return null; + } + } + private static Object convertJsonValue(JsonValue jsonValue) { switch (jsonValue.getValueType()) { case ARRAY: diff --git a/tests/functional/bookstore/src/test/java/io/helidon/tests/bookstore/MainTest.java b/tests/functional/bookstore/src/test/java/io/helidon/tests/bookstore/MainTest.java index c888d06947d..177587f8b83 100644 --- a/tests/functional/bookstore/src/test/java/io/helidon/tests/bookstore/MainTest.java +++ b/tests/functional/bookstore/src/test/java/io/helidon/tests/bookstore/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021 Oracle and/or its affiliates. + * Copyright (c) 2019, 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. @@ -46,7 +46,6 @@ import jakarta.json.JsonObject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -255,13 +254,11 @@ void basicTestMetricsHealthJackson() throws Exception { } @Test - @Disabled("3.0.0-JAKARTA") void basicTestMetricsHealthSEModules() throws Exception { runMetricsAndHealthTest("se", "jsonp", true); } @Test - @Disabled("3.0.0-JAKARTA") void basicTestMetricsHealthMPModules() throws Exception { runMetricsAndHealthTest("mp", "", true); } diff --git a/tests/functional/jax-rs-multiple-apps/src/test/java/io/helidon/tests/functional/multipleapps/MainTest.java b/tests/functional/jax-rs-multiple-apps/src/test/java/io/helidon/tests/functional/multipleapps/MainTest.java index 27bdf22fac8..362f0043421 100644 --- a/tests/functional/jax-rs-multiple-apps/src/test/java/io/helidon/tests/functional/multipleapps/MainTest.java +++ b/tests/functional/jax-rs-multiple-apps/src/test/java/io/helidon/tests/functional/multipleapps/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022 Oracle and/or its affiliates. + * Copyright (c) 2021, 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. @@ -23,7 +23,6 @@ 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.not; @@ -33,7 +32,6 @@ import static org.hamcrest.Matchers.hasKey; @HelidonTest -@Disabled("3.0.0-JAKARTA") class MainTest { @Inject diff --git a/tests/integration/zipkin-mp-2.2/src/test/java/io/helidon/tests/integration/zipkin/mp22/ZipkinMp22Test.java b/tests/integration/zipkin-mp-2.2/src/test/java/io/helidon/tests/integration/zipkin/mp22/ZipkinMp22Test.java index 8bc7598b4be..99860d76b87 100644 --- a/tests/integration/zipkin-mp-2.2/src/test/java/io/helidon/tests/integration/zipkin/mp22/ZipkinMp22Test.java +++ b/tests/integration/zipkin-mp-2.2/src/test/java/io/helidon/tests/integration/zipkin/mp22/ZipkinMp22Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021 Oracle and/or its affiliates. + * Copyright (c) 2019, 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. @@ -25,7 +25,6 @@ import org.eclipse.microprofile.rest.client.RestClientBuilder; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; @@ -59,7 +58,6 @@ void testZipkin() { } @Test - @Disabled("3.0.0-JAKARTA") // java.lang.IllegalStateException: No RestClientBuilderResolver implementation found! void invokeEndpoint() { MpResource client = RestClientBuilder.newBuilder() .baseUri(URI.create("http://localhost:" + port))