This is an automated email from the ASF dual-hosted git repository. olli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git
commit 9e56653af30b1b4da5969edd1dc520d1609e758c Author: Oliver Lietz <[email protected]> AuthorDate: Sat Sep 8 11:25:43 2018 +0200 SLING-7899 Update test dependencies and minimize MetricsServiceFactoryIT --- pom.xml | 444 +++++++++++---------- .../metrics/test/MetricsServiceFactoryIT.java | 50 +-- 2 files changed, 246 insertions(+), 248 deletions(-) diff --git a/pom.xml b/pom.xml index f583d8e..4d76e1f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,230 +1,240 @@ -<?xml version="1.0"?> +<?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 + 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 + 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. + 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> +<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> - <groupId>org.apache.sling</groupId> - <artifactId>sling</artifactId> - <version>34</version> - <relativePath/> - </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.sling.commons.metrics</artifactId> - <version>1.2.5-SNAPSHOT</version> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling</artifactId> + <version>34</version> + <relativePath /> + </parent> - <name>Apache Sling Metrics</name> - <description> - Integrates Metric library with Sling. Refer to - https://sling.apache.org/documentation/bundles/metrics.html - for details - </description> - - <properties> - <org.ops4j.pax.exam.version>4.10.0</org.ops4j.pax.exam.version> - </properties> + <artifactId>org.apache.sling.commons.metrics</artifactId> + <version>1.2.5-SNAPSHOT</version> - <scm> - <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git</connection> - <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git</developerConnection> - <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-commons-metrics.git</url> - <tag>HEAD</tag> + <name>Apache Sling Metrics</name> + <description> + Integrates Metric library with Sling. Refer to + https://sling.apache.org/documentation/bundles/metrics.html + for details + </description> + + <properties> + <org.ops4j.pax.exam.version>4.12.0</org.ops4j.pax.exam.version> + </properties> + + <scm> + <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git</connection> + <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git + </developerConnection> + <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-commons-metrics.git</url> + <tag>HEAD</tag> </scm> - <build> - <plugins> - <plugin> - <groupId>biz.aQute.bnd</groupId> - <artifactId>bnd-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>biz.aQute.bnd</groupId> - <artifactId>bnd-baseline-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - <configuration> - <redirectTestOutputToFile>true</redirectTestOutputToFile> - <systemProperties> - <property> - <name>bundle.filename</name> - <value>${basedir}/target/${project.build.finalName}.jar</value> - </property> - </systemProperties> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.servicemix.tooling</groupId> - <artifactId>depends-maven-plugin</artifactId> - </plugin> - </plugins> - </build> + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-baseline-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + <systemProperties> + <property> + <name>bundle.filename</name> + <value>${basedir}/target/${project.build.finalName}.jar</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.servicemix.tooling</groupId> + <artifactId>depends-maven-plugin</artifactId> + </plugin> + </plugins> + </build> - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>io.dropwizard.metrics</groupId> - <artifactId>metrics-core</artifactId> - <version>3.2.3</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>osgi.core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>osgi.cmpn</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.annotation.versioning</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.inventory</artifactId> - <version>1.0.2</version> - <scope>provided</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.2</version> - <scope>provided</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.utils</artifactId> - <version>1.9.0</version> - <scope>provided</scope> - </dependency> + <dependencies> + <!-- javax --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <optional>true</optional> + </dependency> + <!-- OSGi --> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi.cmpn</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.annotation.versioning</artifactId> + <scope>provided</scope> + </dependency> + <!-- Apache Commons --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.2</version> + <scope>provided</scope> + <optional>true</optional> + </dependency> + <!-- Apache Felix --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>5.6.10</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.inventory</artifactId> + <version>1.0.2</version> + <scope>provided</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.utils</artifactId> + <version>1.9.0</version> + <scope>provided</scope> + </dependency> + <!-- Apache Sling --> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.testing.osgi-mock</artifactId> + <version>2.1.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.testing.paxexam</artifactId> + <version>2.0.0</version> + <scope>test</scope> + </dependency> + <!-- Dropwizard Metrics --> + <dependency> + <groupId>io.dropwizard.metrics</groupId> + <artifactId>metrics-core</artifactId> + <version>3.2.3</version> + <scope>provided</scope> + </dependency> + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <scope>test</scope> + </dependency> + <!-- testing --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit-addons</groupId> + <artifactId>junit-addons</artifactId> + <version>1.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.sourceforge.htmlunit</groupId> + <artifactId>htmlunit</artifactId> + <version>2.32</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-cm</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-forked</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + </dependencies> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.testing.osgi-mock</artifactId> - <version>2.1.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>1.10.19</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>net.sourceforge.htmlunit</groupId> - <artifactId>htmlunit</artifactId> - <version>2.12</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam</artifactId> - <version>${org.ops4j.pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-cm</artifactId> - <version>${org.ops4j.pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-container-forked</artifactId> - <version>${org.ops4j.pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-junit4</artifactId> - <version>${org.ops4j.pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-link-mvn</artifactId> - <version>${org.ops4j.pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.framework</artifactId> - <version>5.6.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit-addons</groupId> - <artifactId>junit-addons</artifactId> - <version>1.4</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.testing.paxexam</artifactId> - <version>0.0.4</version> - <scope>provided</scope> - </dependency> - </dependencies> </project> 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 1e7cd83..a0184f9 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 @@ -19,78 +19,66 @@ 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 static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOakTar; import org.apache.sling.testing.paxexam.TestSupport; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; -import static org.ops4j.pax.exam.CoreOptions.composite; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; 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; +import static org.ops4j.pax.exam.CoreOptions.junitBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) public class MetricsServiceFactoryIT extends TestSupport { @Inject private BundleContext bundleContext; - + @Configuration public Option[] configuration() { return new Option[]{ - baseConfiguration() - }; - } - - @Override - protected Option baseConfiguration() { - return composite( - super.baseConfiguration(), - launchpad(), + baseConfiguration(), + scr(), + // Commons Metrics testBundle("bundle.filename"), mavenBundle().groupId("io.dropwizard.metrics").artifactId("metrics-core").versionAsInProject(), - mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.testing.paxexam").versionAsInProject(), - mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.junit.core").version("1.0.23") - ); - } - - protected Option launchpad() { - final int httpPort = findFreePort(); - final String workingDirectory = workingDirectory(); - return slingLaunchpadOakTar(workingDirectory, httpPort); + junitBundles() + }; } - + @Test public void nullClass() { try { MetricsServiceFactory.getMetricsService(null); fail("Expecting an Exception"); - } catch(IllegalArgumentException asExpected) { + } catch (IllegalArgumentException asExpected) { } - } - + @Test public void classNotLoadedFromOsgiBundle() { try { MetricsServiceFactory.getMetricsService(String.class); fail("Expecting an Exception"); - } catch(IllegalArgumentException asExpected) { + } catch (IllegalArgumentException asExpected) { } } - + @Test public void classFromBundle() { final MetricsService m = MetricsServiceFactory.getMetricsService(getClass()); assertNotNull("Expecting a MetricsService", m); } - + }
