Github user rmannibucau commented on a diff in the pull request: https://github.com/apache/tomee/pull/218#discussion_r236249672 --- Diff: examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java --- @@ -0,0 +1,151 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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. + */ + +import org.apache.cxf.jaxrs.client.WebClient; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.StringReader; +import java.net.URL; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(Arquillian.class) +public class WeatherServiceTest { + + @Deployment(testable = false) + public static WebArchive createDeployment() { + final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war") + .addClass(WeatherService.class) + .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml"); + return webArchive; + } + + @ArquillianResource + private URL base; + + @Test + public void testTimedMetric() { + WebClient.create(base.toExternalForm()) + .path("/weather/day/status") + .get(String.class); + + final String metricPath = "/metrics/application/weather_day_status"; + assertPrometheusFormat(metricPath); + assertJsonFormat(metricPath); + } + + private void assertPrometheusFormat(final String metricPath) { + final String metric = WebClient.create(base.toExternalForm()) + .path(metricPath) + .accept(MediaType.TEXT_PLAIN) + .get(String.class); + + assertTrue(metric.contains("# TYPE application:weather_day_status_seconds summary timer")); --- End diff -- as a general rule put a small description and the actual value in "message" parameter of the assert proposal: Stream.of("expected text 1", "expected text 2") .forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text))); Also for an example you don't need to assert that much so just checking "application:weather_day_status_seconds_count 1.0" can be sufficient for the demonstration IMHO
---