From commits-return-43874-archive-asf-public=cust-asf.ponee.io@tomee.apache.org Mon Nov 26 17:01:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0CD80180647 for ; Mon, 26 Nov 2018 17:01:06 +0100 (CET) Received: (qmail 80422 invoked by uid 500); 26 Nov 2018 16:01:06 -0000 Mailing-List: contact commits-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tomee.apache.org Delivered-To: mailing list commits@tomee.apache.org Received: (qmail 80413 invoked by uid 500); 26 Nov 2018 16:01:06 -0000 Delivered-To: apmail-openejb-commits@openejb.apache.org Received: (qmail 80410 invoked by uid 99); 26 Nov 2018 16:01:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2018 16:01:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id BE240CB896 for ; Mon, 26 Nov 2018 16:01:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id h-KXeVUkNuld for ; Mon, 26 Nov 2018 16:01:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id F414A5FAD8 for ; Mon, 26 Nov 2018 16:01:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 577AAE02ED for ; Mon, 26 Nov 2018 16:01:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 191A527765 for ; Mon, 26 Nov 2018 16:01:00 +0000 (UTC) Date: Mon, 26 Nov 2018 16:01:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@openejb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TOMEE-2290) Metrics Microprofile Example for @Timed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/TOMEE-2290?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1669= 9186#comment-16699186 ]=20 ASF GitHub Bot commented on TOMEE-2290: --------------------------------------- Github user rmannibucau commented on a diff in the pull request: https://github.com/apache/tomee/pull/218#discussion_r236314041 =20 --- Diff: examples/mp-metrics-timed/src/test/java/WeatherServiceTest.ja= va --- @@ -0,0 +1,151 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed wi= th + * 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 wit= h + * 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 imp= lied. + * 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 =3D false) + public static WebArchive createDeployment() { + final WebArchive webArchive =3D ShrinkWrap.create(WebArchive.c= lass, "test.war") + .addClass(WeatherService.class) + .addAsWebInfResource(new StringAsset(""), "bea= ns.xml"); + return webArchive; + } + + @ArquillianResource + private URL base; + + @Test + public void testTimedMetric() { + WebClient.create(base.toExternalForm()) --- End diff -- =20 WebClient is a CXF API, you can use the standard JAXRS Client https://d= ocs.oracle.com/javaee/7/api/javax/ws/rs/client/Client.html > Metrics Microprofile Example for @Timed > --------------------------------------- > > Key: TOMEE-2290 > URL: https://issues.apache.org/jira/browse/TOMEE-2290 > Project: TomEE > Issue Type: Sub-task > Reporter: Ivan Junckes Filho > Assignee: Ivan Junckes Filho > Priority: Major > Labels: pull-request-available > > We would like to have an example for MicroProfile Metrics @Timed=C2=A0ann= otation. > Here is a quick tutorial on MicroProfile Metrics if you are not aware: > [https://www.tomitribe.com/blog/getting-started-with-microprofile-metrics= /] > Fork / clone the=C2=A0TomEE project=C2=A0from here: > [https://github.com/apache/tomee] > Example name should be=C2=A0_mp-metrics-timed_, following the standard al= ready in the project. > All the examples are in: > [https://github.com/apache/tomee/tree/master/examples] > See this example of @Counted for reference: > [https://github.com/apache/tomee/tree/master/examples/mp-metrics-counted] > See these two PRs for the diff for @Counted, it will help you see how sim= ple it is: > [https://github.com/apache/tomee/pull/203] > [https://github.com/apache/tomee/pull/207] > What you have to do is: > 1 -=C2=A0Create a=C2=A0JAX-RS resource WeatherService that has one method= with @Timed > 2 - Have a WeatherServiceTest for the GET and OPTIONS scenarios of @Timed > 3 - Make sure you have tests for Prometheus and JSON formats > 4 - Make sure all the tests pass > After that submit a PR and we'll review it. -- This message was sent by Atlassian JIRA (v7.6.3#76005)