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/08/15 15:42:01 UTC

[10/26] tomee git commit: Added MP Metrics.

Added MP Metrics.


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bae6c827
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bae6c827
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bae6c827

Branch: refs/heads/master
Commit: bae6c827c0daac7412a4f48982b0039a2524de42
Parents: da5f80e
Author: Roberto Cortez <ra...@yahoo.com>
Authored: Tue Jul 31 10:45:43 2018 +0100
Committer: Roberto Cortez <ra...@yahoo.com>
Committed: Tue Jul 31 10:45:43 2018 +0100

----------------------------------------------------------------------
 pom.xml                                         |   3 +
 tck/microprofile-tck/metrics/pom.xml            | 120 +++++++++++++++++++
 ...icroProfileMetricsTCKDeploymentPackager.java |  89 ++++++++++++++
 .../MicroProfileMetricsTCKExtension.java        |  31 +++++
 .../metrics/MicroProfileMetricsTCKObserver.java |  32 +++++
 .../metrics/MicroProfileMetricsTCKProtocol.java |  27 +++++
 ....jboss.arquillian.core.spi.LoadableExtension |   1 +
 .../metrics/src/test/resources/arquillian.xml   |  40 +++++++
 tck/microprofile-tck/pom.xml                    |   1 +
 tomee/tomee-microprofile-webapp/pom.xml         |  12 ++
 10 files changed, 356 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 36bb468..891cbbc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -203,6 +203,9 @@
     <microprofile.fault-tolerance.impl.version>1.0</microprofile.fault-tolerance.impl.version>
     <microprofile.health.version>1.0</microprofile.health.version>
     <microprofile.health.impl.version>1.0.0</microprofile.health.impl.version>
+    <!-- MP 1.2 requires Metrics 1.0, but Geronimo implementation started right from 1.1 Metrics API -->
+    <microprofile.metrics.version>1.1</microprofile.metrics.version>
+    <microprofile.metrics.impl.version>1.0.0</microprofile.metrics.impl.version>
   </properties>
 
   <build>

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/pom.xml
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/pom.xml b/tck/microprofile-tck/metrics/pom.xml
new file mode 100644
index 0000000..0a7a1a7
--- /dev/null
+++ b/tck/microprofile-tck/metrics/pom.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.tomee</groupId>
+    <artifactId>microprofile-tck</artifactId>
+    <version>8.0.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>microprofile-metrics-tck</artifactId>
+  <name>OpenEJB :: TCK :: MicroProfile Metrics TCK</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.22.0</version>
+        <configuration>
+          <reuseForks>false</reuseForks>
+          <dependenciesToScan>
+            <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-api-tck</dependency>
+            <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
+          </dependenciesToScan>
+          <environmentVariables>
+            <MP_METRICS_TAGS>tier=integration</MP_METRICS_TAGS>
+          </environmentVariables>
+          <systemPropertyVariables>
+            <test.url>http://localhost:50290</test.url>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.eclipse.microprofile.metrics</groupId>
+      <artifactId>microprofile-metrics-api</artifactId>
+      <version>${microprofile.metrics.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.microprofile.metrics</groupId>
+      <artifactId>microprofile-metrics-api-tck</artifactId>
+      <version>${microprofile.metrics.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-wlp-managed-8.5</artifactId>
+        </exclusion>
+      </exclusions>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.microprofile.metrics</groupId>
+      <artifactId>microprofile-metrics-rest-tck</artifactId>
+      <version>${microprofile.metrics.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-all</artifactId>
+      <version>1.3</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>apache-tomee</artifactId>
+      <version>${project.version}</version>
+      <type>zip</type>
+      <classifier>microprofile</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>arquillian-tomee-remote</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+      <version>${version.arquillian}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKDeploymentPackager.java
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKDeploymentPackager.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKDeploymentPackager.java
new file mode 100644
index 0000000..ece8314
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKDeploymentPackager.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.apache.openejb.tck.microprofile.metrics;
+
+import org.jboss.arquillian.container.spi.client.deployment.TargetDescription;
+import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription;
+import org.jboss.arquillian.container.test.spi.TestDeployment;
+import org.jboss.arquillian.container.test.spi.client.deployment.ProtocolArchiveProcessor;
+import org.jboss.arquillian.protocol.servlet.v_2_5.ServletProtocolDeploymentPackager;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+import java.util.Collection;
+
+/**
+ * Metrics TCK provides Archives in JAR format. Arquillian transforms them in EAR. To simplify, override the behavior
+ * and wrap them into a WAR.
+ */
+public class MicroProfileMetricsTCKDeploymentPackager extends ServletProtocolDeploymentPackager {
+    @Override
+    public Archive<?> generateDeployment(final TestDeployment testDeployment,
+                                         final Collection<ProtocolArchiveProcessor> processors) {
+        final Archive<?> applicationArchive = testDeployment.getApplicationArchive();
+        if (applicationArchive instanceof JavaArchive) {
+            final WebArchive wrapperWar =
+                    ShrinkWrap.create(WebArchive.class, "microprofile-metrics.war").addAsLibrary(applicationArchive);
+            return super.generateDeployment(new TestDeploymentDelegate(testDeployment, wrapperWar), processors);
+        }
+
+        return super.generateDeployment(testDeployment, processors);
+    }
+
+    private static class TestDeploymentDelegate extends TestDeployment {
+        private TestDeployment testDeployment;
+        private Archive<?> archive;
+
+        public TestDeploymentDelegate(final TestDeployment testDeployment, final Archive<?> archive) {
+            super(null, archive, testDeployment.getAuxiliaryArchives());
+            this.testDeployment = testDeployment;
+            this.archive = archive;
+        }
+
+        @Override
+        public TargetDescription getTargetDescription() {
+            return testDeployment.getTargetDescription();
+        }
+
+        @Override
+        public ProtocolDescription getProtocolDescription() {
+            return testDeployment.getProtocolDescription();
+        }
+
+        @Override
+        public String getDeploymentName() {
+            return testDeployment.getDeploymentName();
+        }
+
+        @Override
+        public Archive<?> getArchiveForEnrichment() {
+            return testDeployment.getArchiveForEnrichment();
+        }
+
+        @Override
+        public Archive<?> getApplicationArchive() {
+            return archive;
+        }
+
+        @Override
+        public Collection<Archive<?>> getAuxiliaryArchives() {
+            return testDeployment.getAuxiliaryArchives();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKExtension.java
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKExtension.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKExtension.java
new file mode 100644
index 0000000..8d4a085
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKExtension.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package org.apache.openejb.tck.microprofile.metrics;
+
+import org.jboss.arquillian.container.test.spi.client.protocol.Protocol;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+import org.jboss.arquillian.protocol.servlet.v_2_5.ServletProtocol;
+
+public class MicroProfileMetricsTCKExtension implements LoadableExtension {
+    @Override
+    public void register(final ExtensionBuilder extensionBuilder) {
+        extensionBuilder
+                .override(Protocol.class, ServletProtocol.class, MicroProfileMetricsTCKProtocol.class)
+                .observer(MicroProfileMetricsTCKObserver.class)
+        ;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKObserver.java
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKObserver.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKObserver.java
new file mode 100644
index 0000000..4589234
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKObserver.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.openejb.tck.microprofile.metrics;
+
+import com.jayway.restassured.RestAssured;
+import org.apache.openejb.arquillian.common.TomEEContainer;
+import org.jboss.arquillian.container.spi.event.container.AfterDeploy;
+import org.jboss.arquillian.core.api.annotation.Observes;
+
+/**
+ * Metrics TCK expect the deployed test archives to be in the root context. In here, we just set the RestAssured path
+ * so the test archives are not required to be deployed in the / context root.
+ */
+public class MicroProfileMetricsTCKObserver {
+    public void AfterDeploy(@Observes final AfterDeploy afterDeploy) {
+        RestAssured.basePath = "microprofile-metrics";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKProtocol.java
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKProtocol.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKProtocol.java
new file mode 100644
index 0000000..4defccf
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/openejb/tck/microprofile/metrics/MicroProfileMetricsTCKProtocol.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+package org.apache.openejb.tck.microprofile.metrics;
+
+import org.jboss.arquillian.container.test.spi.client.deployment.DeploymentPackager;
+import org.jboss.arquillian.protocol.servlet.v_2_5.ServletProtocol;
+
+public class MicroProfileMetricsTCKProtocol extends ServletProtocol {
+    @Override
+    public DeploymentPackager getPackager() {
+        return new MicroProfileMetricsTCKDeploymentPackager();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/tck/microprofile-tck/metrics/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
new file mode 100644
index 0000000..5c60218
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.apache.openejb.tck.microprofile.metrics.MicroProfileMetricsTCKExtension

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml b/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..7804dcd
--- /dev/null
+++ b/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
@@ -0,0 +1,40 @@
+<?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="http://jboss.org/schema/arquillian"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="
+              http://jboss.org/schema/arquillian
+              http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+  <container qualifier="tomee-remote" default="true">
+    <configuration>
+      <property name="debug">false</property>
+      <property name="httpPort">50290</property>
+      <property name="ajpPort">-1</property>
+      <property name="stopPort">-1</property>
+      <property name="classifier">microprofile</property>
+      <property name="conf">src/test/conf</property>
+      <property name="dir">target/tomee</property>
+      <property name="appWorkingDir">target/workdir</property>
+      <property name="cleanOnStartUp">true</property>
+      <property name="properties">
+        MP_METRICS_TAGS = tier=integration
+      </property>
+    </configuration>
+  </container>
+</arquillian>

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tck/microprofile-tck/pom.xml
----------------------------------------------------------------------
diff --git a/tck/microprofile-tck/pom.xml b/tck/microprofile-tck/pom.xml
index 0c8ebec..15433c7 100644
--- a/tck/microprofile-tck/pom.xml
+++ b/tck/microprofile-tck/pom.xml
@@ -35,6 +35,7 @@
     <module>jwt</module>
     <module>fault-tolerance</module>
     <module>health</module>
+    <module>metrics</module>
   </modules>
 
 </project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/bae6c827/tomee/tomee-microprofile-webapp/pom.xml
----------------------------------------------------------------------
diff --git a/tomee/tomee-microprofile-webapp/pom.xml b/tomee/tomee-microprofile-webapp/pom.xml
index 7ba0462..38f2efb 100644
--- a/tomee/tomee-microprofile-webapp/pom.xml
+++ b/tomee/tomee-microprofile-webapp/pom.xml
@@ -94,6 +94,18 @@
       <artifactId>geronimo-health</artifactId>
       <version>${microprofile.health.impl.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.microprofile.metrics</groupId>
+      <artifactId>microprofile-metrics-api</artifactId>
+      <version>${microprofile.metrics.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.geronimo</groupId>
+      <artifactId>geronimo-metrics</artifactId>
+      <version>${microprofile.metrics.impl.version}</version>
+    </dependency>
   </dependencies>
 
   <build>