Skip to content

Commit ca58da5

Browse files
authored
fix filter properties (helidon-io#6721)
Signed-off-by: tvallin <thibault.vallin@oracle.com>
1 parent a634b91 commit ca58da5

6 files changed

Lines changed: 50 additions & 8 deletions

File tree

archetypes/helidon/filters.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022 Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -40,7 +40,9 @@ metrics=!${metrics} || (${metrics.builtin})
4040
tracing=!${tracing} || (${tracing} && ${metrics.provider} == 'microprofile')
4141

4242
# group extra options
43-
extra=${extra} == [] || ${extra} == ['cors', 'webclient', 'fault-tolerance']
43+
extra=${extra} == [] || \
44+
(${flavor} == 'se' && ${extra} == ['cors', 'webclient', 'fault-tolerance']) || \
45+
(${flavor} == 'mp' && ${extra} == ['cors', 'fault-tolerance'])
4446

4547
# group docker, k8s and v8o
4648
packaging=!(${docker} || ${k8s} || ${v8o}) || (${docker} && ${k8s} && ${v8o})

archetypes/helidon/src/main/archetype/common/extra.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2022 Oracle and/or its affiliates.
4+
Copyright (c) 2022, 2023 Oracle and/or its affiliates.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -57,6 +57,10 @@
5757
<value key="groupId">io.helidon.microprofile</value>
5858
<value key="artifactId">helidon-microprofile-fault-tolerance</value>
5959
</map>
60+
<map>
61+
<value key="groupId">io.helidon.webclient</value>
62+
<value key="artifactId">helidon-webclient</value>
63+
</map>
6064
</list>
6165
<list key="Main-helidon-imports">
6266
<value>io.helidon.common.http.Http</value>
@@ -96,11 +100,29 @@
96100
<value key="groupId">io.helidon.microprofile</value>
97101
<value key="artifactId">helidon-microprofile-cors</value>
98102
</map>
103+
<map if="${flavor} == 'mp'">
104+
<value key="groupId">io.helidon.webclient</value>
105+
<value key="artifactId">helidon-webclient</value>
106+
</map>
107+
<map if="${flavor} == 'mp'">
108+
<value key="groupId">io.helidon.webclient</value>
109+
<value key="artifactId">helidon-webclient</value>
110+
</map>
111+
<map if="${flavor} == 'mp'">
112+
<value key="groupId">io.helidon.microprofile.metrics</value>
113+
<value key="artifactId">helidon-microprofile-metrics</value>
114+
</map>
99115
<map if="${flavor} == 'se'">
100116
<value key="groupId">io.helidon.webserver</value>
101117
<value key="artifactId">helidon-webserver-cors</value>
102118
</map>
103119
</list>
120+
<list key="FileServiceTest-annotations" if="${media} contains 'multipart'">
121+
<value>@AddExtension(CorsCdiExtension.class)</value>
122+
</list>
123+
<list key="FileServiceTest-helidon-imports" if="${media} contains 'multipart'">
124+
<value>io.helidon.microprofile.cors.CorsCdiExtension</value>
125+
</list>
104126
<list key="SimpleGreetService-imports" if="${flavor} == 'mp'">
105127
<value>io.helidon.microprofile.cors.CrossOrigin</value>
106128
<value>jakarta.ws.rs.OPTIONS</value>

archetypes/helidon/src/main/archetype/common/observability.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ curl -s -X GET http://localhost:8080/health
517517
<list key="readme-sections">
518518
<value file="/common/files/README.jaeger.md"/>
519519
</list>
520+
<list key="test-config-properties">
521+
<value>tracing.global=false</value>
522+
</list>
520523
</model>
521524
</output>
522525
</option>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#test-config-properties}}
2+
{{.}}
3+
{{/test-config-properties}}

archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/FileServiceTest.java.multipart.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import java.nio.file.Files;
99
import java.nio.file.Path;
1010
import java.util.List;
1111

12+
{{#FileServiceTest-helidon-imports}}
13+
import {{.}};
14+
{{/FileServiceTest-helidon-imports}}
1215
import io.helidon.microprofile.server.JaxRsCdiExtension;
1316
import io.helidon.microprofile.server.ServerCdiExtension;
1417
import io.helidon.microprofile.tests.junit5.AddBean;
@@ -46,6 +49,9 @@ import static org.hamcrest.Matchers.notNullValue;
4649
@AddExtension(ServerCdiExtension.class)
4750
@AddExtension(JaxRsCdiExtension.class)
4851
@AddExtension(CdiComponentProvider.class)
52+
{{#FileServiceTest-annotations}}
53+
{{.}}
54+
{{/FileServiceTest-annotations}}
4955
@AddBean(FileService.class)
5056
@AddBean(FileStorage.class)
5157
@AddBean(MultiPartFeatureProvider.class)

archetypes/helidon/src/main/archetype/mp/custom/files/src/test/java/__pkg__/TestCORS.java.mustache

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import io.helidon.config.Config;
55
import io.helidon.microprofile.server.Server;
66
import io.helidon.webclient.WebClient;
77
import io.helidon.webclient.WebClientRequestBuilder;
8+
import io.helidon.webclient.WebClientRequestHeaders;
89
import io.helidon.webclient.WebClientResponse;
10+
import io.helidon.webclient.WebClientResponseHeaders;
911
import io.helidon.webserver.cors.CrossOriginConfig;
1012
import org.junit.jupiter.api.AfterAll;
1113
import org.junit.jupiter.api.BeforeAll;
@@ -16,7 +18,11 @@ import java.util.List;
1618
import java.util.Optional;
1719

1820
import static org.hamcrest.MatcherAssert.assertThat;
19-
import static org.hamcrest.Matchers.*;
21+
import static org.hamcrest.Matchers.contains;
22+
import static org.hamcrest.Matchers.containsString;
23+
import static org.hamcrest.Matchers.empty;
24+
import static org.hamcrest.Matchers.is;
25+
import static org.hamcrest.Matchers.not;
2026

2127
class TestCORS {
2228
@@ -47,16 +53,16 @@ class TestCORS {
4753
@Test
4854
void testAnonymousGreetWithCors() {
4955
WebClientRequestBuilder builder = client.get();
50-
WebClientRequestHeaders headers = builder.headers();
56+
Headers headers = builder.headers();
5157
headers.add("Origin", "http://foo.com");
5258
headers.add("Host", "here.com");
5359
5460
WebClientResponse r = getResponse(builder);
5561
assertThat("HTTP response", r.status().code(), is(200));
5662
String payload = fromPayload(r);
57-
assertThat("HTTP response payload", payload, is("{\"message\":\"Hello World!\"}"));
58-
WebClientResponseHeaders resHeaders = r.headers();
59-
Optional<String> allowOrigin = resHeaders.value(Http.Header.ACCESS_CONTROL_ALLOW_ORIGIN);
63+
assertThat("HTTP response payload", payload.contains("Hello World!"), is(true));
64+
headers = r.headers();
65+
Optional<String> allowOrigin = headers.value(CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN);
6066
assertThat("Expected CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN + " is present",
6167
allowOrigin.isPresent(), is(true));
6268
assertThat("CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN, allowOrigin.get(), is("http://foo.com"));

0 commit comments

Comments
 (0)