From 5d97ed3cd299e74430eaa64e2536de0053ac5d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Marti=C5=A1ka?= Date: Thu, 7 Oct 2021 09:49:01 +0200 Subject: [PATCH] SmallRye Health codestart --- .../base/README.tpl.qute.md | 1 + .../smallrye-health-codestart/codestart.yml | 12 +++++++ .../main/java/org/acme/MyLivenessCheck.java | 15 +++++++++ .../main/kotlin/org/acme/MyLivenessCheck.kt | 14 +++++++++ .../resources/META-INF/quarkus-extension.yaml | 6 ++++ .../quarkus/SmallRyeHealthCodestartTest.java | 31 +++++++++++++++++++ ...ain_java_ilove_quark_us_MyHealthCheck.java | 15 +++++++++ ...n_java_ilove_quark_us_MyLivenessCheck.java | 15 +++++++++ ...ain_kotlin_ilove_quark_us_MyHealthCheck.kt | 7 +++++ ...n_kotlin_ilove_quark_us_MyLivenessCheck.kt | 14 +++++++++ 10 files changed, 130 insertions(+) create mode 100644 devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/base/README.tpl.qute.md create mode 100644 devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/codestart.yml create mode 100644 devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/java/src/main/java/org/acme/MyLivenessCheck.java create mode 100755 devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/kotlin/src/main/kotlin/org/acme/MyLivenessCheck.kt create mode 100644 integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/SmallRyeHealthCodestartTest.java create mode 100644 integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyHealthCheck.java create mode 100644 integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyLivenessCheck.java create mode 100644 integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyHealthCheck.kt create mode 100644 integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyLivenessCheck.kt diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/base/README.tpl.qute.md b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/base/README.tpl.qute.md new file mode 100644 index 0000000000000..405280158877d --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/base/README.tpl.qute.md @@ -0,0 +1 @@ +{#include readme-header /} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/codestart.yml b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/codestart.yml new file mode 100644 index 0000000000000..7752aaff2542c --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/codestart.yml @@ -0,0 +1,12 @@ +name: smallrye-health-codestart +ref: smallrye-health +type: code +tags: extension-codestart +metadata: + title: SmallRye Health + description: Monitor your application's health using SmallRye Health + related-guide-section: https://quarkus.io/guides/smallrye-health +language: + base: + dependencies: + - io.quarkus:quarkus-smallrye-health diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/java/src/main/java/org/acme/MyLivenessCheck.java b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/java/src/main/java/org/acme/MyLivenessCheck.java new file mode 100644 index 0000000000000..5c7f82a503c4d --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/java/src/main/java/org/acme/MyLivenessCheck.java @@ -0,0 +1,15 @@ +package org.acme; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.Liveness; + +@Liveness +public class MyLivenessCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up("alive"); + } + +} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/kotlin/src/main/kotlin/org/acme/MyLivenessCheck.kt b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/kotlin/src/main/kotlin/org/acme/MyLivenessCheck.kt new file mode 100755 index 0000000000000..fc049ee1656d1 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/smallrye-health-codestart/kotlin/src/main/kotlin/org/acme/MyLivenessCheck.kt @@ -0,0 +1,14 @@ +package org.acme + +import org.eclipse.microprofile.health.HealthCheck +import org.eclipse.microprofile.health.HealthCheckResponse +import org.eclipse.microprofile.health.Liveness + +@Liveness +public class MyLivenessCheck : HealthCheck { + + override fun call(): HealthCheckResponse { + return HealthCheckResponse.up("alive") + } + +} \ No newline at end of file diff --git a/extensions/smallrye-health/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/smallrye-health/runtime/src/main/resources/META-INF/quarkus-extension.yaml index a1f542e0e026e..d638540b3cce7 100644 --- a/extensions/smallrye-health/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/smallrye-health/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -17,3 +17,9 @@ metadata: - "quarkus.health." - "quarkus.smallrye-health." - "mp.health." + codestart: + name: "smallrye-health" + languages: + - "java" + - "kotlin" + artifact: "io.quarkus:quarkus-project-core-extension-codestarts" diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/SmallRyeHealthCodestartTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/SmallRyeHealthCodestartTest.java new file mode 100644 index 0000000000000..03e3a773666b0 --- /dev/null +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/SmallRyeHealthCodestartTest.java @@ -0,0 +1,31 @@ +package io.quarkus.devtools.codestarts.quarkus; + +import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; +import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.KOTLIN; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; + +public class SmallRyeHealthCodestartTest { + + @RegisterExtension + public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() + .codestarts("smallrye-health") + .languages(JAVA, KOTLIN) + .build(); + + @Test + void testContent() throws Throwable { + codestartTest.checkGeneratedSource("org.acme.MyLivenessCheck"); + } + + @Test + @EnabledIfSystemProperty(named = "build-projects", matches = "true") + void buildAllProjectsForLocalUse() throws Throwable { + codestartTest.buildAllProjects(); + } + +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyHealthCheck.java b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyHealthCheck.java new file mode 100644 index 0000000000000..55f8640bc3678 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyHealthCheck.java @@ -0,0 +1,15 @@ +package ilove.quark.us; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.Liveness; + +@Liveness +public class MyLivenessCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up("alive"); + } + +} \ No newline at end of file diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyLivenessCheck.java b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyLivenessCheck.java new file mode 100644 index 0000000000000..55f8640bc3678 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_java_ilove_quark_us_MyLivenessCheck.java @@ -0,0 +1,15 @@ +package ilove.quark.us; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.Liveness; + +@Liveness +public class MyLivenessCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up("alive"); + } + +} \ No newline at end of file diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyHealthCheck.kt b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyHealthCheck.kt new file mode 100644 index 0000000000000..e132ad6900ef8 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyHealthCheck.kt @@ -0,0 +1,7 @@ +package ilove.quark.us + +interface MyHealthCheck { + + fun message(): String? + +} \ No newline at end of file diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyLivenessCheck.kt b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyLivenessCheck.kt new file mode 100644 index 0000000000000..e0907b4a54ee7 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/SmallRyeHealthCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyLivenessCheck.kt @@ -0,0 +1,14 @@ +package ilove.quark.us + +import org.eclipse.microprofile.health.HealthCheck +import org.eclipse.microprofile.health.HealthCheckResponse +import org.eclipse.microprofile.health.Liveness + +@Liveness +public class MyLivenessCheck : HealthCheck { + + override fun call(): HealthCheckResponse { + return HealthCheckResponse.up("alive") + } + +} \ No newline at end of file