Skip to content

Commit 33d9540

Browse files
4.x: Update archetypes and dbclient examples (#7873)
* 4.x: Update archetypes and dbclient examples - Add a property in the SE application parent to control the test profile name (`helidon.test.config.profile`) - Fix META-INF service file for PokemonMapperProvider (and remove transformation 'package-name') - Use ClientResponseTyped as much as possible to avoid try-with-resources when using WebClient in tests - Define database output at the end to have visibility on all inputs, implement db + health intersection (in se) - Restrict programmatic observe feature registration to dbclient only - Update the exercise instructions in README.md - Remove usage of jaxb-maven-plugin in mp + db - Fix examples/dbclient/pokemon ; add unit test - Add unit tests for database in SE - Add missing bom entry for helidon-integrations-db-mysql - Remove config-profile.yaml in SE quickstarts - Add the surefire config in helidon-standalone-quickstart-se to set the test profile * Only set mainClass in MP when jpms=true
1 parent 1f2168c commit 33d9540

File tree

66 files changed

+1976
-1797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1976
-1797
lines changed

applications/se/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<name>Helidon SE applications parent pom</name>
3232
<description>Parent pom for Helidon SE applications</description>
3333

34+
<properties>
35+
<helidon.test.config.profile>test</helidon.test.config.profile>
36+
</properties>
37+
3438
<build>
3539
<pluginManagement>
3640
<plugins>
@@ -40,7 +44,7 @@
4044
<version>${version.plugin.surefire}</version>
4145
<configuration>
4246
<systemPropertyVariables>
43-
<helidon.config.profile>test</helidon.config.profile>
47+
<helidon.config.profile>${helidon.test.config.profile}</helidon.config.profile>
4448
</systemPropertyVariables>
4549
</configuration>
4650
</plugin>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
<transformation id="packaged">
2929
<replace regex="__pkg__" replacement="${package/\./\/}"/>
3030
</transformation>
31-
<transformation id="package-name">
32-
<replace regex="package" replacement="${package}"/>
33-
</transformation>
3431
<transformation id="json-mustache">
3532
<replace regex="\.json.mustache$" replacement=""/>
3633
</transformation>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
<list key="src-dirs" if="!${multi-module}">
6969
<value>src</value>
7070
</list>
71-
<list key="native-sections" if="${db} &amp;&amp; ${flavor} == 'mp'">
72-
<value file="files/README.native.md.mustache" if="${docker.native-image}" template="mustache"/>
71+
<list key="native-sections" if="${docker.native-image}">
72+
<value file="files/README.native.md"/>
7373
</list>
7474
<list key="readme-sections">
7575
<value order="50" template="mustache">

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,21 @@ restrictive-cors:
274274
]]></value>
275275
</list>
276276
<list key="Main-routing-builder" if="${flavor} == 'se'">
277-
<value><![CDATA[ .register("/cors-greet", corsSupportForGreeting(config), new GreetService())
277+
<value><![CDATA[ .register("/cors-greet", corsSupportForGreeting(), new GreetService())
278278
]]></value>
279279
</list>
280280
<list key="main-class-content" if="${flavor} == 'se'">
281281
<value><![CDATA[
282-
private static CorsSupport corsSupportForGreeting(Config config) {
283-
Config restrictiveConfig = config.get("restrictive-cors");
282+
private static CorsSupport corsSupportForGreeting() {
283+
Config restrictiveConfig = Config.global().get("restrictive-cors");
284284
if (!restrictiveConfig.exists()) {
285285
Logger.getLogger(Main.class.getName())
286286
.warning("Missing restrictive config; continuing with default CORS support");
287287
}
288288
289289
CorsSupport.Builder corsBuilder = CorsSupport.builder();
290290
291-
config.get("cors")
291+
Config.global().get("cors")
292292
.ifExists(c -> {
293293
Logger.getLogger(Main.class.getName()).info("Using the override configuration");
294294
corsBuilder.mappedConfig(c);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
The generation of native binaries requires an installation of GraalVM 22.1.0+.
2+
3+
You can build a native binary using Maven as follows:
4+
5+
```
6+
mvn -Pnative-image install -DskipTests
7+
```
8+
9+
The generation of the executable binary may take a few minutes to complete depending on
10+
your hardware and operating system. When completed, the executable file will be available
11+
under the `target` directory and be named after the artifact ID you have chosen during the
12+
project generation phase.

archetypes/helidon/src/main/archetype/common/files/README.native.md.mustache

Lines changed: 0 additions & 37 deletions
This file was deleted.

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,10 @@
5050
<list key="Abstract-tests">
5151
<value><![CDATA[
5252
@Test
53-
void testRootRoute() {
54-
try (Http1ClientResponse response = client.get("/greet")
55-
.request()) {
56-
57-
assertThat(response.status(), is(Status.OK_200));
58-
JsonObject json = response.as(JsonObject.class);
59-
assertThat(json.getString("message"), is("Hello World!"));
60-
}
53+
void testGreeting() {
54+
ClientResponseTyped<JsonObject> response = client.get("/greet").request(JsonObject.class);
55+
assertThat(response.status(), is(Status.OK_200));
56+
assertThat(response.entity().getString("message"), is("Hello World!"));
6157
}
6258
]]></value>
6359
</list>
@@ -119,18 +115,16 @@
119115
<value><![CDATA[
120116
@Test
121117
void testGreet() {
122-
try (Http1ClientResponse response = client.get("/greet").request()) {
123-
assertThat(response.status(), is(Status.OK_200));
124-
assertThat(response.as(Message.class).getMessage(), is("Hello World!"));
125-
}
118+
ClientResponseTyped<Message> response = client.get("/greet").request(Message.class);
119+
assertThat(response.status(), is(Status.OK_200));
120+
assertThat(response.entity().getMessage(), is("Hello World!"));
126121
}
127122
128123
@Test
129124
void testGreetJoe() {
130-
try (Http1ClientResponse response = client.get("/greet/Joe").request()) {
131-
assertThat(response.status(), is(Status.OK_200));
132-
assertThat(response.as(Message.class).getMessage(), is("Hello Joe!"));
133-
}
125+
ClientResponseTyped<Message> response = client.get("/greet/Joe").request(Message.class);
126+
assertThat(response.status(), is(Status.OK_200));
127+
assertThat(response.entity().getMessage(), is("Hello Joe!"));
134128
}
135129
]]></value>
136130
</list>
@@ -225,6 +219,23 @@
225219
<value key="media-json-jackson" if="!(${media} contains 'json' &amp;&amp; ${media.json-lib} == 'jackson')">false</value>
226220
<value key="json-lib" if="${media} contains 'json'">${media.json-lib}</value>
227221
<value key="multipart" if="${media} contains 'multipart'">true</value>
222+
<list key="readme-exercise-the-application">
223+
<value order="900" if="${media} contains 'json'"><![CDATA[
224+
JSON:
225+
```
226+
curl -X GET http://localhost:8080/greet
227+
{"message":"Hello World!"}
228+
229+
curl -X GET http://localhost:8080/greet/Joe
230+
{"message":"Hello Joe!"}
231+
232+
curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting
233+
234+
curl -X GET http://localhost:8080/greet/Jose
235+
{"message":"Hola Jose!"}
236+
```
237+
]]></value>
238+
</list>
228239
</model>
229240
</output>
230241
</step>

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

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -350,44 +350,9 @@ curl -s -X GET http://localhost:8080/health
350350
<value key="artifactId">helidon-health-checks</value>
351351
</map>
352352
</list>
353-
<list key="Observe-feature-builder" if="${flavor} == 'se'">
354-
<value><![CDATA[.addObserver(HealthObserver.builder()
355-
.details(true)
356-
.useSystemServices(false)
357-
.addCheck(() -> HealthCheckResponse.builder()
358-
.status(HealthCheckResponse.Status.UP)
359-
.detail("time", System.currentTimeMillis())
360-
.build(), HealthCheckType.READINESS)
361-
.addCheck(() -> HealthCheckResponse.builder()
362-
.status(isStarted())
363-
.detail("time", System.currentTimeMillis())
364-
.build(), HealthCheckType.STARTUP)
365-
.build())]]></value>
366-
</list>
367-
<list key="Main-helidon-imports" if="${flavor} == 'se'">
368-
<value>io.helidon.health.HealthCheckResponse</value>
369-
<value>io.helidon.health.HealthCheckType</value>
370-
<value>io.helidon.webserver.observe.health.HealthObserver</value>
371-
</list>
372353
<list key="MainTest-static-imports" if="${flavor} == 'se'">
373354
<value>org.hamcrest.CoreMatchers.containsString</value>
374355
</list>
375-
<list key="Main-java-imports" if="${flavor} == 'se'">
376-
<value>java.time.Duration</value>
377-
</list>
378-
<list key="main-class-fields" if="${flavor} == 'se'">
379-
<value><![CDATA[ private static long serverStartTime;]]></value>
380-
</list>
381-
<list key="Main-main" if="${flavor} == 'se'">
382-
<value><![CDATA[serverStartTime = System.currentTimeMillis();]]></value>
383-
</list>
384-
<list key="main-class-content" if="${flavor} == 'se'">
385-
<value><![CDATA[
386-
private static boolean isStarted() {
387-
return Duration.ofMillis(System.currentTimeMillis() - serverStartTime).getSeconds() >= 8;
388-
}
389-
]]></value>
390-
</list>
391356
<list key="Abstract-test" if="${flavor} == 'se'">
392357
<value><![CDATA[
393358
@Test
@@ -412,8 +377,8 @@ Note the port number reported by the application.
412377
Probe the health endpoints:
413378
414379
```bash
415-
curl -X GET http://localhost:8080/observe/observe/health/
416-
curl -X GET http://localhost:8080/observe/observe/health/ready
380+
curl -X GET http://localhost:8080/observe/health
381+
curl -X GET http://localhost:8080/observe/health/ready
417382
```
418383
419384
]]></value>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@
102102
</list>
103103
<list key="Main-routing" if="${flavor} == 'se'">
104104
<value><![CDATA[
105-
if (config.get("security.enabled").asBoolean().orElse(true)) {
105+
if (Config.global().get("security.enabled").asBoolean().orElse(true)) {
106106
// IDCS requires a web resource for redirects
107-
routing.addFeature(OidcFeature.create(config));
107+
routing.addFeature(OidcFeature.create(Config.global()));
108108
}
109109
]]></value>
110110
</list>
@@ -168,7 +168,6 @@
168168
<value if="${flavor} == 'se'">io.helidon.webclient.security</value>
169169
<value>io.helidon.security.providers.jwt</value>
170170
<value>io.helidon.webserver.context</value>
171-
<value>io.helidon.webclient.http1</value>
172171
</list>
173172
</model>
174173
</output>
@@ -316,7 +315,7 @@
316315
methods: ["get"]
317316
authenticate: true]]></value>
318317
</list>
319-
<list key="config-test" if="${flavor} == 'se'">
318+
<list key="application-test-yaml-entries" if="${flavor} == 'se'">
320319
<value><![CDATA[
321320
security:
322321
enabled: false

archetypes/helidon/src/main/archetype/mp/common/common-mp.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<source src="/common/sources.xml"/>
2626
<output>
2727
<model>
28-
<value key="mainClass">${package}.Main</value>
2928
<value key="parent-artifactId">helidon-mp</value>
3029
<list key="dependencies">
3130
<map>

0 commit comments

Comments
 (0)