You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2022/08/05 15:55:25 UTC
[sling-org-apache-sling-commons-metrics] branch SLING-11501 created (now 197aa8c)
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a change to branch SLING-11501
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git
at 197aa8c update dependencies and cleanup warnings and deprecations
This branch includes the following new commits:
new 3538d0a SLING-11509 enable PR validation with Java 11 and 17
new 197aa8c update dependencies and cleanup warnings and deprecations
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[sling-org-apache-sling-commons-metrics] 02/02: update dependencies and cleanup warnings and deprecations
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch SLING-11501
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git
commit 197aa8cee41282df0da77483afb7c00925fa9dc0
Author: Joerg Hoh <jo...@apache.org>
AuthorDate: Fri Aug 5 17:55:13 2022 +0200
update dependencies and cleanup warnings and deprecations
---
pom.xml | 20 +++++--
.../metrics/internal/JmxExporterFactoryTest.java | 10 ++--
.../metrics/internal/MetricServiceTest.java | 6 +-
.../internal/MetricWebConsolePluginTest.java | 67 ++++++++++------------
.../metrics/test/MetricsServiceFactoryIT.java | 7 ---
5 files changed, 53 insertions(+), 57 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2a533e5..4c5429c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>46</version>
+ <version>48</version>
<relativePath />
</parent>
@@ -39,7 +39,7 @@
</description>
<properties>
- <org.ops4j.pax.exam.version>4.13.3</org.ops4j.pax.exam.version>
+ <org.ops4j.pax.exam.version>4.13.4</org.ops4j.pax.exam.version>
<project.build.outputTimestamp>1</project.build.outputTimestamp>
</properties>
@@ -110,6 +110,16 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
</dependency>
<!-- Apache Commons -->
<dependency>
@@ -148,8 +158,8 @@
<!-- Apache Sling -->
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <version>2.1.0</version>
+ <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
+ <version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -209,7 +219,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
- <version>2.32</version>
+ <version>2.63.0</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/src/test/java/org/apache/sling/commons/metrics/internal/JmxExporterFactoryTest.java b/src/test/java/org/apache/sling/commons/metrics/internal/JmxExporterFactoryTest.java
index 38d2220..57e5b37 100644
--- a/src/test/java/org/apache/sling/commons/metrics/internal/JmxExporterFactoryTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/internal/JmxExporterFactoryTest.java
@@ -121,16 +121,16 @@ public class JmxExporterFactoryTest {
// Integer
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_0_INT_NAME), intSupplierCaptor.capture());
- assertEquals(new Integer(0),intSupplierCaptor.getValue().get());
+ assertEquals(Integer.valueOf(0),intSupplierCaptor.getValue().get());
// test that an update in the mbean reflects in the metrics
mbeans[0].setInt(10);
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_0_INT_NAME), intSupplierCaptor.capture());
- assertEquals(new Integer(10),intSupplierCaptor.getValue().get());
+ assertEquals(Integer.valueOf(10),intSupplierCaptor.getValue().get());
// Long
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_0_LONG_NAME), longSupplierCaptor.capture());
- assertEquals(new Long(0L),longSupplierCaptor.getValue().get());
+ assertEquals(Long.valueOf(0L),longSupplierCaptor.getValue().get());
// String
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_0_STRING_NAME), stringSupplierCaptor.capture());
@@ -142,10 +142,10 @@ public class JmxExporterFactoryTest {
// MBean 1
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_1_INT_NAME), intSupplierCaptor.capture());
- assertEquals(new Integer(1),intSupplierCaptor.getValue().get());
+ assertEquals(Integer.valueOf(1),intSupplierCaptor.getValue().get());
Mockito.verify(metrics).gauge(Mockito.eq(EXPECTED_1_LONG_NAME), longSupplierCaptor.capture());
- assertEquals(new Long(1L),longSupplierCaptor.getValue().get());
+ assertEquals(Long.valueOf(1L),longSupplierCaptor.getValue().get());
// verify that no metrics for MBean2 have been registered
Mockito.verify(metrics, never()).gauge(Mockito.eq(EXPECTED_2_INT_NAME), intSupplierCaptor.capture());
diff --git a/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java b/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java
index b412e50..12a44c8 100644
--- a/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java
@@ -22,8 +22,6 @@ package org.apache.sling.commons.metrics.internal;
import java.lang.management.ManagementFactory;
import java.util.Collections;
import java.util.Set;
-import java.util.function.Supplier;
-
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.Query;
@@ -49,14 +47,16 @@ import static org.apache.sling.commons.metrics.internal.BundleMetricsMapper.JMX_
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+
+
public class MetricServiceTest {
@Rule
public final OsgiContext context = new OsgiContext();
diff --git a/src/test/java/org/apache/sling/commons/metrics/internal/MetricWebConsolePluginTest.java b/src/test/java/org/apache/sling/commons/metrics/internal/MetricWebConsolePluginTest.java
index 5091c03..16efdb6 100644
--- a/src/test/java/org/apache/sling/commons/metrics/internal/MetricWebConsolePluginTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/internal/MetricWebConsolePluginTest.java
@@ -19,6 +19,19 @@
package org.apache.sling.commons.metrics.internal;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
@@ -27,41 +40,26 @@ import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import com.codahale.metrics.JvmAttributeGaugeSet;
-import com.codahale.metrics.MetricRegistry;
-import com.gargoylesoftware.htmlunit.StringWebResponse;
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.WebResponse;
-import com.gargoylesoftware.htmlunit.html.HTMLParser;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlTable;
import org.apache.felix.inventory.Format;
import org.apache.felix.utils.json.JSONParser;
import org.apache.sling.testing.mock.osgi.MockOsgi;
-import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import com.codahale.metrics.JvmAttributeGaugeSet;
+import com.codahale.metrics.MetricRegistry;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlTable;
@RunWith(MockitoJUnitRunner.class)
public class MetricWebConsolePluginTest {
@Rule
- public final OsgiContext context = new OsgiContext();
+ public final SlingContext context = new SlingContext();
private MetricWebConsolePlugin plugin = new MetricWebConsolePlugin();
@@ -157,22 +155,17 @@ public class MetricWebConsolePluginTest {
activatePlugin();
- StringWriter sw = new StringWriter();
+ plugin.doGet(mock(HttpServletRequest.class), context.response());
- HttpServletResponse response = mock(HttpServletResponse.class);
- when(response.getWriter()).thenReturn(new PrintWriter(sw));
-
- plugin.doGet(mock(HttpServletRequest.class), response);
-
- WebClient client = new WebClient();
- WebResponse resp = new StringWebResponse(sw.toString(), WebClient.URL_ABOUT_BLANK);
- HtmlPage page = HTMLParser.parseHtml(resp, client.getCurrentWindow());
-
- assertTable("data-meters", page);
- assertTable("data-counters", page);
- assertTable("data-timers", page);
- assertTable("data-histograms", page);
- assertTable("data-gauges", page);
+ try (WebClient client = new WebClient();) {
+ HtmlPage page = client.loadHtmlCodeIntoCurrentWindow(context.response().getOutputAsString());
+
+ assertTable("data-meters", page);
+ assertTable("data-counters", page);
+ assertTable("data-timers", page);
+ assertTable("data-histograms", page);
+ assertTable("data-gauges", page);
+ }
}
private void assertTable(String name, HtmlPage page) {
diff --git a/src/test/java/org/apache/sling/commons/metrics/test/MetricsServiceFactoryIT.java b/src/test/java/org/apache/sling/commons/metrics/test/MetricsServiceFactoryIT.java
index 8282eb5..0e6bd55 100644
--- a/src/test/java/org/apache/sling/commons/metrics/test/MetricsServiceFactoryIT.java
+++ b/src/test/java/org/apache/sling/commons/metrics/test/MetricsServiceFactoryIT.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.commons.metrics.test;
-import javax.inject.Inject;
-
import org.apache.sling.commons.metrics.MetricsService;
import org.apache.sling.commons.metrics.MetricsServiceFactory;
import org.apache.sling.testing.paxexam.TestSupport;
@@ -30,8 +28,6 @@ import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.osgi.framework.BundleContext;
-
import static org.apache.sling.testing.paxexam.SlingOptions.scr;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -43,9 +39,6 @@ import static org.ops4j.pax.exam.CoreOptions.options;
@ExamReactorStrategy(PerClass.class)
public class MetricsServiceFactoryIT extends TestSupport {
- @Inject
- private BundleContext bundleContext;
-
@Configuration
public Option[] configuration() {
return options(
[sling-org-apache-sling-commons-metrics] 01/02: SLING-11509 enable PR validation with Java 11 and 17
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch SLING-11501
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git
commit 3538d0aab742c0a2568a0c7408ac9a6dab0c5699
Author: Joerg Hoh <jo...@apache.org>
AuthorDate: Fri Aug 5 17:54:42 2022 +0200
SLING-11509 enable PR validation with Java 11 and 17
---
.sling-module.json | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..9097f10
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,8 @@
+{
+ "jenkins": {
+ "jdks": [
+ 17,
+ 11
+ ]
+ }
+}
\ No newline at end of file