From a8b1b460bb3ac405e164bc44e710c39d0a552b81 Mon Sep 17 00:00:00 2001 From: "tim.quinn@oracle.com" Date: Fri, 18 Aug 2023 02:22:04 -0500 Subject: [PATCH] Fix style; add simple feature impl selection test --- .../java/io/helidon/metrics/api/Metrics.java | 2 +- .../observe/metrics/MetricsFeature4.java | 1 - .../observe/metrics/SimpleFeatureTest.java | 41 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 webserver/observe/metrics/src/test/java/io/helidon/webserver/observe/metrics/SimpleFeatureTest.java diff --git a/metrics/api/src/main/java/io/helidon/metrics/api/Metrics.java b/metrics/api/src/main/java/io/helidon/metrics/api/Metrics.java index 55fac159a31..a1d7080284f 100644 --- a/metrics/api/src/main/java/io/helidon/metrics/api/Metrics.java +++ b/metrics/api/src/main/java/io/helidon/metrics/api/Metrics.java @@ -37,7 +37,7 @@ static MeterRegistry globalRegistry() { /** * Creates a meter registry, not added to the global registry, based on - * the provide metrics config. + * the provided metrics config. * * @param metricsConfig metrics config * @return new meter registry diff --git a/webserver/observe/metrics/src/main/java/io/helidon/webserver/observe/metrics/MetricsFeature4.java b/webserver/observe/metrics/src/main/java/io/helidon/webserver/observe/metrics/MetricsFeature4.java index a6284596e5d..5a0de249640 100644 --- a/webserver/observe/metrics/src/main/java/io/helidon/webserver/observe/metrics/MetricsFeature4.java +++ b/webserver/observe/metrics/src/main/java/io/helidon/webserver/observe/metrics/MetricsFeature4.java @@ -47,7 +47,6 @@ import io.helidon.webserver.http.HttpService; import io.helidon.webserver.http.ServerRequest; import io.helidon.webserver.http.ServerResponse; -import io.helidon.webserver.servicecommon.HelidonFeatureSupport; import static io.helidon.http.Http.HeaderNames.ALLOW; import static io.helidon.http.Http.Status.METHOD_NOT_ALLOWED_405; diff --git a/webserver/observe/metrics/src/test/java/io/helidon/webserver/observe/metrics/SimpleFeatureTest.java b/webserver/observe/metrics/src/test/java/io/helidon/webserver/observe/metrics/SimpleFeatureTest.java new file mode 100644 index 00000000000..a0ae80eb5b5 --- /dev/null +++ b/webserver/observe/metrics/src/test/java/io/helidon/webserver/observe/metrics/SimpleFeatureTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.helidon.webserver.observe.metrics; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.not; + +class SimpleFeatureTest { + +// TODO remove once we do not have selective building based on the system property + @Test + void testSelection() { + MetricsFeature metricsFeature = MetricsFeature.builder().build(); + assertThat("Feature selection", metricsFeature, not(instanceOf(MetricsFeature4.class))); + + try { + System.setProperty("newMetricsAPI", "true"); + + metricsFeature = MetricsFeature.builder().build(); + assertThat("Feature selection", metricsFeature, instanceOf(MetricsFeature4.class)); + } finally { + System.clearProperty("newMetricsAPI"); + } + } +}