From 07ea8b391925fcd62197c354f8d6b04e6a8a763e Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Fri, 28 Apr 2023 21:47:05 +0200 Subject: [PATCH] fix filter properties (#6722) Signed-off-by: tvallin --- archetypes/helidon/filters.properties | 4 ++-- .../src/main/archetype/common/extra.xml | 20 +++++++++++++++++++ .../main/archetype/common/observability.xml | 3 +++ .../microprofile-config.properties.mustache | 3 +++ .../FileServiceTest.java.multipart.mustache | 6 ++++++ .../java/__pkg__/FtResourceTest.java.mustache | 1 + .../test/java/__pkg__/TestCORS.java.mustache | 15 +------------- 7 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 archetypes/helidon/src/main/archetype/mp/common/files/src/test/resources/META-INF/microprofile-config.properties.mustache diff --git a/archetypes/helidon/filters.properties b/archetypes/helidon/filters.properties index e28316a0176..b78743f8318 100644 --- a/archetypes/helidon/filters.properties +++ b/archetypes/helidon/filters.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 Oracle and/or its affiliates. +# Copyright (c) 2022, 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. @@ -40,7 +40,7 @@ metrics=!${metrics} || (${metrics.builtin}) tracing=!${tracing} || (${tracing} && ${metrics.provider} == 'microprofile') # group extra options -extra=${extra} == [] || ${extra} == ['cors', 'webclient', 'fault-tolerance'] +extra=${extra} == [] || ${extra} == ['cors', 'fault-tolerance'] # group docker, k8s and v8o packaging=!(${docker} || ${k8s} || ${v8o}) || (${docker} && ${k8s} && ${v8o}) diff --git a/archetypes/helidon/src/main/archetype/common/extra.xml b/archetypes/helidon/src/main/archetype/common/extra.xml index c935bf79c32..e4e6d846989 100644 --- a/archetypes/helidon/src/main/archetype/common/extra.xml +++ b/archetypes/helidon/src/main/archetype/common/extra.xml @@ -49,6 +49,19 @@ java.util.concurrent.TimeoutException + + + org.apache.maven.plugins + maven-surefire-plugin + + + true + + + +]]> + @@ -74,6 +87,13 @@ jakarta.ws.rs.core.Response jakarta.ws.rs.HttpMethod + + + @AddExtension(CorsCdiExtension.class) + + + io.helidon.microprofile.cors.CorsCdiExtension + + + tracing.global=false + diff --git a/archetypes/helidon/src/main/archetype/mp/common/files/src/test/resources/META-INF/microprofile-config.properties.mustache b/archetypes/helidon/src/main/archetype/mp/common/files/src/test/resources/META-INF/microprofile-config.properties.mustache new file mode 100644 index 00000000000..0e1a3d92ced --- /dev/null +++ b/archetypes/helidon/src/main/archetype/mp/common/files/src/test/resources/META-INF/microprofile-config.properties.mustache @@ -0,0 +1,3 @@ +{{#config-properties}} +{{.}} +{{/config-properties}} \ No newline at end of file diff --git a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FileServiceTest.java.multipart.mustache b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FileServiceTest.java.multipart.mustache index 5a544689f7b..a916b68e7d1 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FileServiceTest.java.multipart.mustache +++ b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FileServiceTest.java.multipart.mustache @@ -9,6 +9,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +{{#FileServiceTest-helidon-imports}} +import {{.}}; +{{/FileServiceTest-helidon-imports}} import io.helidon.microprofile.server.JaxRsCdiExtension; import io.helidon.microprofile.server.ServerCdiExtension; import io.helidon.microprofile.tests.junit5.AddBean; @@ -46,6 +49,9 @@ import static org.hamcrest.Matchers.notNullValue; @AddExtension(ServerCdiExtension.class) @AddExtension(JaxRsCdiExtension.class) @AddExtension(CdiComponentProvider.class) +{{#FileServiceTest-annotations}} +{{.}} +{{/FileServiceTest-annotations}} @AddBean(FileService.class) @AddBean(FileStorage.class) @AddBean(MultiPartFeatureProvider.class) diff --git a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FtResourceTest.java.mustache b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FtResourceTest.java.mustache index c613be855a5..a3616fb41ad 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FtResourceTest.java.mustache +++ b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FtResourceTest.java.mustache @@ -40,3 +40,4 @@ class FtResourceTest { assertThat(response, is("failures: 2")); } +} \ No newline at end of file diff --git a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/TestCORS.java.mustache b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/TestCORS.java.mustache index 5675e09c217..a625be7211f 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/TestCORS.java.mustache +++ b/archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/TestCORS.java.mustache @@ -24,19 +24,6 @@ class TestCORS { @Inject private WebTarget target; - private static final String ALLOW_RESTRICTED_HEADERS = "sun.net.http.allowRestrictedHeaders"; - private static boolean originalAllowRestrictedHeaders; - - @BeforeAll - static void permitCorsHeaders() { - originalAllowRestrictedHeaders = Boolean.getBoolean(ALLOW_RESTRICTED_HEADERS); - System.setProperty(ALLOW_RESTRICTED_HEADERS, "true"); - } - - @AfterAll - static void restoreHeadersSetting() { - System.setProperty(ALLOW_RESTRICTED_HEADERS, Boolean.toString(originalAllowRestrictedHeaders)); - } @Test void testAnonymousGreetWithCors() { @@ -48,7 +35,7 @@ class TestCORS { assertThat("HTTP response", r.getStatus(), is(200)); String payload = fromPayload(r); - assertThat("HTTP response payload", payload, is("{\"message\":\"Hello World!\"}")); + assertThat("HTTP response payload", payload.contains("Hello World!"), is(true)); assertThat("CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN, r.getHeaders().getFirst(Http.Header.ACCESS_CONTROL_ALLOW_ORIGIN.defaultCase()), is("http://foo.com"));