You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/11/20 16:55:23 UTC
[1/7] tomee git commit: changing project name and example names.
Repository: tomee
Updated Branches:
refs/heads/master 51a07decf -> 2f903ec62
changing project name and example names.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/518a1c67
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/518a1c67
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/518a1c67
Branch: refs/heads/master
Commit: 518a1c672e531c5a83058c97adc8184de4aaec3c
Parents: be6bf8f
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 10:06:44 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 10:06:44 2018 -0200
----------------------------------------------------------------------
examples/pom.xml | 2 +-
examples/rest-mp-metrics/README.md | 19 ------
examples/rest-mp-metrics/pom.xml | 70 --------------------
.../java/org/superbiz/rest/GreetingService.java | 24 -------
.../org/superbiz/rest/GreetingServiceTest.java | 61 -----------------
.../src/test/resources/arquillian.xml | 30 ---------
6 files changed, 1 insertion(+), 205 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 4cab9e2..92518e3 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -171,7 +171,7 @@ BROKEN, see TOMEE-2140
<module>moviefun</module>
<module>moviefun-rest</module>
<module>resources-jmx-example</module>
- <module>rest-mp-metrics</module>
+ <module>mp-metrics-counted</module>
</modules>
<dependencies>
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/rest-mp-metrics/README.md
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/README.md b/examples/rest-mp-metrics/README.md
deleted file mode 100644
index 9dafe75..0000000
--- a/examples/rest-mp-metrics/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Microprofile Metrics
-This is an example on how to use microprofile metrics in TomEE.
-
-The command to run the application the application is:
-
- mvn clean install tomee:run
-
-Make a call to the greeting endpoint:
-
- http://localhost:8080/rest-mp-metrics/greeting
-
-Check the metrics in Prometheus format:
-
- http://localhost:8080/rest-mp-metrics/metrics
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/rest-mp-metrics/pom.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/pom.xml b/examples/rest-mp-metrics/pom.xml
deleted file mode 100644
index ded0689..0000000
--- a/examples/rest-mp-metrics/pom.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>examples</artifactId>
- <groupId>org.apache.tomee</groupId>
- <version>8.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>rest-mp-metrics</artifactId>
- <packaging>war</packaging>
-
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>javaee-api</artifactId>
- <version>8.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.microprofile.metrics</groupId>
- <artifactId>microprofile-metrics-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>openejb-cxf-rs</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>1.0.3.Final</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>arquillian-tomee-remote</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>apache-tomee</artifactId>
- <version>${tomee.version}</version>
- <type>zip</type>
- <classifier>microprofile</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.tomee.maven</groupId>
- <artifactId>tomee-maven-plugin</artifactId>
- <version>8.0.0-SNAPSHOT</version>
- <configuration>
- <tomeeClassifier>microprofile</tomeeClassifier>
- <context>${artifactId}</context>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java b/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
deleted file mode 100644
index a75087e..0000000
--- a/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.superbiz.rest;
-
-import org.eclipse.microprofile.metrics.annotation.Counted;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-@Path("/greeting")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-@ApplicationScoped
-public class GreetingService {
-
- @Counted(monotonic = true, name = "message_counter", absolute = true)
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String message() {
- return "Hi Microprofile Metrics!";
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
deleted file mode 100644
index dff4044..0000000
--- a/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.
- */
-package org.superbiz.rest;
-
-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.ws.rs.core.MediaType;
-import java.net.URL;
-
-import static org.junit.Assert.assertEquals;
-
-@RunWith(Arquillian.class)
-public class GreetingServiceTest {
-
- @Deployment(testable = false)
- public static WebArchive createDeployment() {
- final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClass(GreetingService.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
- return webArchive;
- }
-
- @ArquillianResource
- private URL base;
-
- @Test
- public void testPrometheusApplicationMetric() {
- final String message = WebClient.create(base.toExternalForm())
- .path("/greeting/")
- .get(String.class);
- assertEquals("Hi Microprofile Metrics!", message);
-
- final String metric = WebClient.create(base.toExternalForm())
- .path("/metrics/application/message_counter")
- .accept(MediaType.TEXT_PLAIN)
- .get(String.class);
- assertEquals("# TYPE application:message_counter counter\napplication:message_counter 1.0\n", metric);
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/518a1c67/examples/rest-mp-metrics/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/test/resources/arquillian.xml b/examples/rest-mp-metrics/src/test/resources/arquillian.xml
deleted file mode 100644
index 3029d48..0000000
--- a/examples/rest-mp-metrics/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-
- 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
-
- 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.
--->
-<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <container qualifier="tomee" default="true">
- <configuration>
- <property name="httpPort">-1</property>
- <property name="stopPort">-1</property>
- <property name="classifier">microprofile</property>
- <property name="dir">target/apache-tomee-remote</property>
- <property name="appWorkingDir">target/arquillian-test-working-dir</property>
- </configuration>
- </container>
-</arquillian>
\ No newline at end of file
[4/7] tomee git commit: Wording fixes
Posted by jg...@apache.org.
Wording fixes
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5bc648a9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5bc648a9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5bc648a9
Branch: refs/heads/master
Commit: 5bc648a92f443e39b1031c37709c8c3e840e9fa4
Parents: 9e41727
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 13:28:29 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 13:28:29 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-counted/README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5bc648a9/examples/mp-metrics-counted/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/README.md b/examples/mp-metrics-counted/README.md
index 298519a..94a061d 100644
--- a/examples/mp-metrics-counted/README.md
+++ b/examples/mp-metrics-counted/README.md
@@ -16,7 +16,7 @@ Within the application there is an enpoint that will give you weather status for
Hi, today is a sunny day!
-### Counted feature
+#### Counted Feature
Microprofile metrics has a feature that can be used to count requests to a service.
To use this feature you need to annotate the JAX-RS resource method with @Counted.
@@ -57,6 +57,7 @@ Optional. Array of Strings in the <key>=<value> format to supply special tags to
**boolean reusable**
Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges.
+#### Metric data
Check the counter metric doing a _GET_ request:
@@ -117,5 +118,5 @@ Check the metric metadata doing a _OPTIONS_ request:
}
}
-
+You can also try it out using the WeatherServiceTest.java available in the project.
[3/7] tomee git commit: adding options and readme changes
Posted by jg...@apache.org.
adding options and readme changes
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/9e41727a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/9e41727a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/9e41727a
Branch: refs/heads/master
Commit: 9e41727aa042031e78e4ce977d5aef78436f9c65
Parents: 0744352
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 13:24:09 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 13:24:09 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-counted/README.md | 114 ++++++++++++++++++-
.../java/org/superbiz/rest/WeatherService.java | 4 +-
.../org/superbiz/rest/WeatherServiceTest.java | 1 +
3 files changed, 112 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/9e41727a/examples/mp-metrics-counted/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/README.md b/examples/mp-metrics-counted/README.md
index 9dafe75..298519a 100644
--- a/examples/mp-metrics-counted/README.md
+++ b/examples/mp-metrics-counted/README.md
@@ -1,19 +1,121 @@
# Microprofile Metrics
This is an example on how to use microprofile metrics in TomEE.
-The command to run the application the application is:
+##### Run the application:
mvn clean install tomee:run
-Make a call to the greeting endpoint:
+Within the application there is an enpoint that will give you weather status for the day and week.
- http://localhost:8080/rest-mp-metrics/greeting
+##### For the day status call:
+
+ GET http://localhost:8080/rest-mp-metrics/wather/day/status
-Check the metrics in Prometheus format:
+##### Response:
+
+ Hi, today is a sunny day!
- http://localhost:8080/rest-mp-metrics/metrics
+
+### Counted feature
+Microprofile metrics has a feature that can be used to count requests to a service.
+
+To use this feature you need to annotate the JAX-RS resource method with @Counted.
+
+ @Path("/weather")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApplicationScoped
+ public class WeatherService {
+
+ @Path("/day/status")
+ @Counted(monotonic = true, name = "weather_day_status", absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+ ...
+ }
+
+There are some configurations, as part of @Counted, that you need to know:
+
+**String name**
+Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used.
+
+**boolean absolute**
+If true, uses the given name as the absolute name of the metric. If false, prepends the package name and class name before the given name. Default value is false.
+
+**String displayName**
+Optional. A human readable display name for metadata.
+
+**String description**
+Optional. A description of the metric.
+
+**String[] tags**
+Optional. Array of Strings in the <key>=<value> format to supply special tags to a metric.
+
+**boolean reusable**
+Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges.
+
+
+Check the counter metric doing a _GET_ request:
+
+##### Prometheus format:
+
+ GET http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+##### Response:
+
+ # TYPE application:weather_day_status counter
+ application:weather_day_status 1.0
+
+##### JSON Format:
+
+For json format add the header _Accept=application/json_ to the request.
+
+ {
+ "weather_day_status": {
+ "delegate": {},
+ "unit": "none",
+ "count": 1
+ }
+ }
+
+#### Metric metadata
+A metric will have a metadata so you can know more information about it, like displayName, description, tags e etc.
+
+Check the metric metadata doing a _OPTIONS_ request:
+
+##### Request
+
+ OPTIONS http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+
+##### Response:
+
+ {
+ "weather_day_status": {
+ "unit": "none",
+ "displayName": "Weather Day Status",
+ "name": "weather_day_status",
+ "typeRaw": "COUNTER",
+ "description": "This metric shows the weather status of the day.",
+ "type": "counter",
+ "value": {
+ "unit": "none",
+ "displayName": "Weather Day Status",
+ "name": "weather_day_status",
+ "tagsAsString": "",
+ "typeRaw": "COUNTER",
+ "description": "This metric shows the weather status of the day.",
+ "type": "counter",
+ "reusable": false,
+ "tags": {}
+ },
+ "reusable": false,
+ "tags": ""
+ }
+ }
+
-
http://git-wip-us.apache.org/repos/asf/tomee/blob/9e41727a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
index 3475e7b..ec856fe 100644
--- a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
+++ b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
@@ -16,7 +16,9 @@ import javax.ws.rs.core.MediaType;
public class WeatherService {
@Path("/day/status")
- @Counted(monotonic = true, name = "weather_day_status", absolute = true)
+ @Counted(monotonic = true, name = "weather_day_status", absolute = true,
+ displayName = "Weather Day Status",
+ description = "This metric shows the weather status of the day.")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String dayStatus() {
http://git-wip-us.apache.org/repos/asf/tomee/blob/9e41727a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
index a2a30b5..db78d03 100644
--- a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
+++ b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
@@ -45,6 +45,7 @@ public class WeatherServiceTest {
@ArquillianResource
private URL base;
+
@Test
public void testCountedPrometheus() {
final String message = WebClient.create(base.toExternalForm())
[2/7] tomee git commit: adding new examples
Posted by jg...@apache.org.
adding new examples
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/07443527
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/07443527
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/07443527
Branch: refs/heads/master
Commit: 0744352730d1435a0a73263439dbf6f1835e0832
Parents: 518a1c6
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 10:07:10 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 10:07:10 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-counted/README.md | 19 +++++
examples/mp-metrics-counted/pom.xml | 70 ++++++++++++++++++
.../java/org/superbiz/rest/WeatherService.java | 33 +++++++++
.../org/superbiz/rest/WeatherServiceTest.java | 75 ++++++++++++++++++++
.../src/test/resources/arquillian.xml | 30 ++++++++
5 files changed, 227 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/07443527/examples/mp-metrics-counted/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/README.md b/examples/mp-metrics-counted/README.md
new file mode 100644
index 0000000..9dafe75
--- /dev/null
+++ b/examples/mp-metrics-counted/README.md
@@ -0,0 +1,19 @@
+# Microprofile Metrics
+This is an example on how to use microprofile metrics in TomEE.
+
+The command to run the application the application is:
+
+ mvn clean install tomee:run
+
+Make a call to the greeting endpoint:
+
+ http://localhost:8080/rest-mp-metrics/greeting
+
+Check the metrics in Prometheus format:
+
+ http://localhost:8080/rest-mp-metrics/metrics
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/tomee/blob/07443527/examples/mp-metrics-counted/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/pom.xml b/examples/mp-metrics-counted/pom.xml
new file mode 100644
index 0000000..c5d10e8
--- /dev/null
+++ b/examples/mp-metrics-counted/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>examples</artifactId>
+ <groupId>org.apache.tomee</groupId>
+ <version>8.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mp-metrics-counted</artifactId>
+ <packaging>war</packaging>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>8.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.metrics</groupId>
+ <artifactId>microprofile-metrics-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.0.3.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>apache-tomee</artifactId>
+ <version>${tomee.version}</version>
+ <type>zip</type>
+ <classifier>microprofile</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tomee.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>8.0.0-SNAPSHOT</version>
+ <configuration>
+ <tomeeClassifier>microprofile</tomeeClassifier>
+ <context>${artifactId}</context>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/07443527/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
new file mode 100644
index 0000000..3475e7b
--- /dev/null
+++ b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
@@ -0,0 +1,33 @@
+package org.superbiz.rest;
+
+import org.eclipse.microprofile.metrics.annotation.Counted;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/weather")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Counted(monotonic = true, name = "weather_day_status", absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+
+ @Path("/week/status")
+ @Counted(monotonic = true, name = "weather_week_status", absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String weekStatus() {
+ return "Hi, week will be mostly sunny!";
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/07443527/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
new file mode 100644
index 0000000..a2a30b5
--- /dev/null
+++ b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
@@ -0,0 +1,75 @@
+/**
+ * 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.
+ */
+package org.superbiz.rest;
+
+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.ws.rs.core.MediaType;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@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 testCountedPrometheus() {
+ final String message = WebClient.create(base.toExternalForm())
+ .path("/weather/day/status")
+ .get(String.class);
+ assertEquals("Hi, today is a sunny day!", message);
+
+ final String metric = WebClient.create(base.toExternalForm())
+ .path("/metrics/application/weather_day_status")
+ .accept(MediaType.TEXT_PLAIN)
+ .get(String.class);
+ assertEquals("# TYPE application:weather_day_status counter\napplication:weather_day_status 1.0\n", metric);
+ }
+
+ @Test
+ public void testCountedJson() {
+ final String message = WebClient.create(base.toExternalForm())
+ .path("/weather/week/status")
+ .get(String.class);
+ assertEquals("Hi, week will be mostly sunny!", message);
+
+ final String metric = WebClient.create(base.toExternalForm())
+ .path("/metrics/application/weather_week_status")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(String.class);
+ assertEquals("{\"weather_week_status\":{\"delegate\":{},\"unit\":\"none\",\"count\":1}}", metric);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/07443527/examples/mp-metrics-counted/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/test/resources/arquillian.xml b/examples/mp-metrics-counted/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..3029d48
--- /dev/null
+++ b/examples/mp-metrics-counted/src/test/resources/arquillian.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ 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
+
+ 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.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="classifier">microprofile</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
[6/7] tomee git commit: adding metric metadata test
Posted by jg...@apache.org.
adding metric metadata test
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e8b1678c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e8b1678c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e8b1678c
Branch: refs/heads/master
Commit: e8b1678c5afd9bfecacf8498282bc6976ab54059
Parents: eedd705
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 14:08:37 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 14:08:37 2018 -0200
----------------------------------------------------------------------
.../org/superbiz/rest/WeatherServiceTest.java | 45 +++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e8b1678c/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
index 110f7fd..0f87d6c 100644
--- a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
+++ b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
@@ -26,7 +26,11 @@ 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;
@@ -52,7 +56,7 @@ public class WeatherServiceTest {
.get(String.class);
assertEquals("Hi, today is a sunny day!", message);
- String metricPath = "/metrics/application/weather_day_status";
+ final String metricPath = "/metrics/application/weather_day_status";
assertPrometheusFormat(metricPath);
assertJsonFormat(metricPath);
}
@@ -72,4 +76,43 @@ public class WeatherServiceTest {
.get(String.class);
assertEquals("{\"weather_day_status\":{\"delegate\":{},\"unit\":\"none\",\"count\":1}}", metric);
}
+
+ @Test
+ public void testCountedMetricMetadata() {
+ final Response response = WebClient.create(base.toExternalForm())
+ .path("/metrics/application/weather_day_status")
+ .accept(MediaType.APPLICATION_JSON)
+ .options();
+ final String metaData = response.readEntity(String.class);
+ JsonObject metadataJson = Json.createReader(new StringReader(metaData)).readObject();
+
+ final String expected = "{\n" +
+ " \"weather_day_status\": {\n" +
+ " \"unit\": \"none\",\n" +
+ " \"displayName\": \"Weather Day Status\",\n" +
+ " \"name\": \"weather_day_status\",\n" +
+ " \"typeRaw\": \"COUNTER\",\n" +
+ " \"description\": \"This metric shows the weather status of the day.\",\n" +
+ " \"type\": \"counter\",\n" +
+ " \"value\": {\n" +
+ " \"unit\": \"none\",\n" +
+ " \"displayName\": \"Weather Day Status\",\n" +
+ " \"name\": \"weather_day_status\",\n" +
+ " \"tagsAsString\": \"\",\n" +
+ " \"typeRaw\": \"COUNTER\",\n" +
+ " \"description\": \"This metric shows the weather status of the day.\",\n" +
+ " \"type\": \"counter\",\n" +
+ " \"reusable\": false,\n" +
+ " \"tags\": {\n" +
+ " \n" +
+ " }\n" +
+ " },\n" +
+ " \"reusable\": false,\n" +
+ " \"tags\": \"\"\n" +
+ " }\n" +
+ "}";
+
+ JsonObject expectedJson = Json.createReader(new StringReader(expected)).readObject();
+ assertEquals(expectedJson, metadataJson);
+ }
}
[5/7] tomee git commit: Refactoring test methods
Posted by jg...@apache.org.
Refactoring test methods
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/eedd7050
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/eedd7050
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/eedd7050
Branch: refs/heads/master
Commit: eedd705057d30f0e5b0e3329e55abbe08859373a
Parents: 5bc648a
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 20 13:37:02 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 20 13:37:02 2018 -0200
----------------------------------------------------------------------
.../org/superbiz/rest/WeatherServiceTest.java | 23 ++++++++++----------
1 file changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/eedd7050/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
index db78d03..110f7fd 100644
--- a/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
+++ b/examples/mp-metrics-counted/src/test/java/org/superbiz/rest/WeatherServiceTest.java
@@ -45,32 +45,31 @@ public class WeatherServiceTest {
@ArquillianResource
private URL base;
-
@Test
- public void testCountedPrometheus() {
+ public void testCountedMetric() {
final String message = WebClient.create(base.toExternalForm())
.path("/weather/day/status")
.get(String.class);
assertEquals("Hi, today is a sunny day!", message);
+ 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("/metrics/application/weather_day_status")
+ .path(metricPath)
.accept(MediaType.TEXT_PLAIN)
.get(String.class);
assertEquals("# TYPE application:weather_day_status counter\napplication:weather_day_status 1.0\n", metric);
}
- @Test
- public void testCountedJson() {
- final String message = WebClient.create(base.toExternalForm())
- .path("/weather/week/status")
- .get(String.class);
- assertEquals("Hi, week will be mostly sunny!", message);
-
+ private void assertJsonFormat(final String metricPath) {
final String metric = WebClient.create(base.toExternalForm())
- .path("/metrics/application/weather_week_status")
+ .path(metricPath)
.accept(MediaType.APPLICATION_JSON)
.get(String.class);
- assertEquals("{\"weather_week_status\":{\"delegate\":{},\"unit\":\"none\",\"count\":1}}", metric);
+ assertEquals("{\"weather_day_status\":{\"delegate\":{},\"unit\":\"none\",\"count\":1}}", metric);
}
}
[7/7] tomee git commit: Merge branch 'metrics-example' of
github.com:ivanjunckes/tomee
Posted by jg...@apache.org.
Merge branch 'metrics-example' of github.com:ivanjunckes/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2f903ec6
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2f903ec6
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2f903ec6
Branch: refs/heads/master
Commit: 2f903ec62d558415aa09b171195bc4203d64e06f
Parents: 51a07de e8b1678
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Tue Nov 20 16:45:50 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Tue Nov 20 16:45:50 2018 +0000
----------------------------------------------------------------------
examples/mp-metrics-counted/README.md | 122 +++++++++++++++++++
examples/mp-metrics-counted/pom.xml | 70 +++++++++++
.../java/org/superbiz/rest/WeatherService.java | 35 ++++++
.../org/superbiz/rest/WeatherServiceTest.java | 118 ++++++++++++++++++
.../src/test/resources/arquillian.xml | 30 +++++
examples/pom.xml | 2 +-
examples/rest-mp-metrics/README.md | 19 ---
examples/rest-mp-metrics/pom.xml | 70 -----------
.../java/org/superbiz/rest/GreetingService.java | 24 ----
.../org/superbiz/rest/GreetingServiceTest.java | 61 ----------
.../src/test/resources/arquillian.xml | 30 -----
11 files changed, 376 insertions(+), 205 deletions(-)
----------------------------------------------------------------------