Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Sievers2012-09-04 10:02:52 -0400
committerJan Sievers2014-08-18 08:38:11 -0400
commit0449913869b5efc79ec8a4cdbcdaab56aafd8b8d (patch)
tree911488f5f50e59da2d7a3a8829b50093f965e30a
parent2fc170e5314445cb863b42e1d10fbbfb03c90469 (diff)
downloadorg.eclipse.tycho-0449913869b5efc79ec8a4cdbcdaab56aafd8b8d.tar.gz
org.eclipse.tycho-0449913869b5efc79ec8a4cdbcdaab56aafd8b8d.tar.xz
org.eclipse.tycho-0449913869b5efc79ec8a4cdbcdaab56aafd8b8d.zip
386481 update maven surefire to 2.17
- adapt to various surefire changes - remove OsgiEnabled* workaround classes because http://jira.codehaus.org/browse/SUREFIRE-876 is fixed now - test class scanning is now done outside of the forked process - update Import-Package for surefire-junit jars Bug: 386481 CQ: 8567, 8566, 8565, 8564, 8563, 8562, 8561, 8560 Change-Id: Ibcb439a24add880c4cdafe67b42e29ca3cb14ff1 Signed-off-by: Jan Sievers <jan.sievers@sap.com>
-rw-r--r--tycho-its/src/test/java/org/eclipse/tycho/test/surefire/ParallelTestExecutionTest.java1
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF2
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties2
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF2
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties2
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF10
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties3
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml10
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java126
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreRunListener.java100
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF7
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml5
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/CombinedClassLoader.java63
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java54
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java42
-rw-r--r--tycho-surefire/pom.xml6
-rw-r--r--tycho-surefire/tycho-surefire-plugin/pom.xml5
-rw-r--r--tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java65
-rw-r--r--tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java2
19 files changed, 180 insertions, 327 deletions
diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/ParallelTestExecutionTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/ParallelTestExecutionTest.java
index 84d637880..3aea79be5 100644
--- a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/ParallelTestExecutionTest.java
+++ b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/ParallelTestExecutionTest.java
@@ -43,7 +43,6 @@ public class ParallelTestExecutionTest extends AbstractTychoIntegrationTest {
verifier.getSystemProperties().setProperty("parallel", "classes");
verifier.executeGoal("integration-test");
verifier.verifyErrorFreeLog();
- verifier.verifyTextInLog("Concurrency config is parallel='classes', perCoreThreadCount=true, threadCount=3, useUnlimitedThreads=false");
File surefireReportsDir = new File(verifier.getBasedir(), "target/surefire-reports");
assertTrue(surefireReportsDir.isDirectory());
File[] surefireXmlReports = surefireReportsDir.listFiles(new FilenameFilter() {
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
index 5fe382c59..3e11aab5b 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
@@ -7,5 +7,5 @@ Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.14.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
Require-Bundle: org.junit;bundle-version="[3.8.0,4.0.0)"
-Bundle-ClassPath: jars/surefire-junit3-2.10.jar
+Bundle-ClassPath: jars/surefire-junit3-2.17.jar
Bundle-Vendor: %providerName
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
index 499ce76f5..fe88b194e 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
@@ -9,5 +9,5 @@
# Sonatype Inc. - initial API and implementation
###############################################################################
bin.includes = META-INF/,\
- jars/surefire-junit3-2.10.jar,\
+ jars/,\
plugin.properties
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
index af521b206..9255370a3 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
@@ -6,7 +6,7 @@ Bundle-Version: 0.22.0.qualifier
Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.14.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
-Bundle-ClassPath: jars/surefire-junit4-2.10.jar
+Bundle-ClassPath: jars/surefire-junit4-2.17.jar
Import-Package: junit.framework;version="3.0.0",
org.junit;version="4.0.0",
org.junit.runner;version="4.0.0",
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
index b78714953..fe88b194e 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
@@ -9,5 +9,5 @@
# Sonatype Inc. - initial API and implementation
###############################################################################
bin.includes = META-INF/,\
- jars/surefire-junit4-2.10.jar,\
+ jars/,\
plugin.properties
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
index 160da5641..9862b1607 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
@@ -6,11 +6,17 @@ Bundle-Version: 0.22.0.qualifier
Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.16.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,
- jars/surefire-junit47-2.10.jar
+ jars/surefire-junit47-2.17.jar,
+ jars/common-junit48-2.17.jar,
+ jars/surefire-grouper-2.17.jar
Import-Package: junit.framework;version="3.0.0",
org.junit;version="[4.7,5)",
org.junit.runner;version="[4.7,5)",
org.junit.runner.notification;version="[4.7,5)",
org.junit.runners;version="[4.7,5)",
- org.junit.runners.model;version="[4.7,5)"
+ org.junit.runners.model;version="[4.7,5)",
+ org.junit.runner.manipulation;version="[4.7,5)",
+ org.junit.experimental.categories;version="[4.7,5)",
+ org.junit.experimental.runners;version="[4.7,5)",
+ org.junit.internal.runners;version="[4.7,5)"
Bundle-Vendor: %providerName
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
index 61905c2d2..2589258c3 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
@@ -10,8 +10,7 @@
###############################################################################
bin.includes = .,\
META-INF/,\
- jars/surefire-junit47-2.10.jar,\
+ jars/,\
plugin.properties,\
about.html,\
about_files/
-source.. = src/main/java/
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
index 9b97cf5d4..f5e3d1a2b 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
@@ -44,6 +44,16 @@
<artifactId>surefire-junit47</artifactId>
<version>${surefire-version}</version>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>common-junit48</artifactId>
+ <version>${surefire-version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-grouper</artifactId>
+ <version>${surefire-version}</version>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java b/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java
deleted file mode 100644
index eaa8dc428..000000000
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.apache.maven.surefire.junitcore;
-
-/*
- * 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.
- */
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory;
-import org.apache.maven.surefire.common.junit4.JUnit4TestChecker;
-import org.apache.maven.surefire.providerapi.AbstractProvider;
-import org.apache.maven.surefire.providerapi.ProviderParameters;
-import org.apache.maven.surefire.report.ConsoleLogger;
-import org.apache.maven.surefire.report.ConsoleOutputCapture;
-import org.apache.maven.surefire.report.ConsoleOutputReceiver;
-import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.report.RunListener;
-import org.apache.maven.surefire.suite.RunResult;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.DirectoryScanner;
-import org.apache.maven.surefire.util.ScannerFilter;
-import org.apache.maven.surefire.util.TestsToRun;
-
-/**
- * This class is a workaround for surefire bug {@link http://jira.codehaus.org/browse/SUREFIRE-876 }. It's a copy of
- * {@link JUnitCoreProvider} with the only change to use OsgiEnabledJUnitCoreRunListener instead of
- * JUnitCoreRunListener. TODO remove and use {@link JUnitCoreProvider} instead when surefire release with proposed
- * bugfix is available.
- *
- * @author Kristian Rosenvold
- * @author Jan Sievers (SAP)
- */
-public class OsgiEnabledJUnitCoreProvider
- extends AbstractProvider
-{
- private final ClassLoader testClassLoader;
-
- private final DirectoryScanner directoryScanner;
-
- private final JUnitCoreParameters jUnitCoreParameters;
-
- private final ScannerFilter scannerFilter;
-
- private final List<org.junit.runner.notification.RunListener> customRunListeners;
-
- private final ProviderParameters providerParameters;
-
- private TestsToRun testsToRun;
-
-
- public OsgiEnabledJUnitCoreProvider( ProviderParameters providerParameters )
- {
- this.providerParameters = providerParameters;
- this.testClassLoader = providerParameters.getTestClassLoader();
- this.directoryScanner = providerParameters.getDirectoryScanner();
- this.jUnitCoreParameters = new JUnitCoreParameters( providerParameters.getProviderProperties() );
- this.scannerFilter = new JUnit4TestChecker( testClassLoader );
- customRunListeners = JUnit4RunListenerFactory.
- createCustomListeners( providerParameters.getProviderProperties().getProperty( "listener" ) );
-
- }
-
- public Boolean isRunnable()
- {
- return Boolean.TRUE;
- }
-
- public Iterator getSuites()
- {
- testsToRun = scanClassPath();
- return testsToRun.iterator();
- }
-
- public RunResult invoke( Object forkTestSet )
- throws TestSetFailedException, ReporterException
- {
- final String message = "Concurrency config is " + jUnitCoreParameters.toString() + "\n";
- final ReporterFactory reporterFactory = providerParameters.getReporterFactory();
-
- final ConsoleLogger consoleLogger = providerParameters.getConsoleLogger();
- consoleLogger.info( message );
-
- if ( testsToRun == null )
- {
- testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class) forkTestSet );
- }
- final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();
-
- RunListener listener = ConcurrentReporterManager.createInstance( testSetMap, reporterFactory,
- jUnitCoreParameters.isParallelClasses(),
- jUnitCoreParameters.isParallelBoth(),
- consoleLogger );
-
- ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) listener );
-
- org.junit.runner.notification.RunListener jUnit4RunListener = new OsgiEnabledJUnitCoreRunListener( listener, testSetMap );
- customRunListeners.add( 0, jUnit4RunListener );
-
- JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners );
- return reporterFactory.close();
- }
-
- private TestsToRun scanClassPath()
- {
- return directoryScanner.locateTestClasses( testClassLoader, scannerFilter );
- }
-}
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreRunListener.java b/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreRunListener.java
deleted file mode 100644
index fb6bedef2..000000000
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreRunListener.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.maven.surefire.junitcore;
-/*
- * 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.
- */
-
-import java.util.ArrayList;
-import java.util.Map;
-import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
-import org.apache.maven.surefire.report.RunListener;
-
-import org.junit.runner.Description;
-import org.junit.runner.Result;
-
-/**
- * This class is a workaround or surefire bug
- * {@link http://jira.codehaus.org/browse/SUREFIRE-876 }
- *
- * TODO remove when surefire release with proposed bugfix is available
- */
-public class OsgiEnabledJUnitCoreRunListener
- extends JUnit4RunListener
-{
- private final Map<String, TestSet> classMethodCounts;
-
- /**
- * @param reporter the report manager to log testing events to
- * @param classMethodCounts A map of methods
- */
- public OsgiEnabledJUnitCoreRunListener( RunListener reporter, Map<String, TestSet> classMethodCounts )
- {
- super( reporter );
- this.classMethodCounts = classMethodCounts;
- }
-
- /**
- * Called right before any tests from a specific class are run.
- *
- * @see org.junit.runner.notification.RunListener#testRunStarted(org.junit.runner.Description)
- */
- public void testRunStarted( Description description )
- throws Exception
- {
- fillTestCountMap( description );
- reporter.testSetStarting( null ); // Not entirely meaningful as we can see
- }
-
- @Override
- public void testRunFinished( Result result )
- throws Exception
- {
- reporter.testSetCompleted( null );
- }
-
- private void fillTestCountMap( Description description )
- {
- final ArrayList<Description> children = description.getChildren();
-
- TestSet testSet = new TestSet( description );
- String itemTestClassName = null;
- for ( Description item : children )
- {
- if ( item.isTest() && item.getMethodName() != null )
- {
- testSet.incrementTestMethodCount();
- if ( itemTestClassName == null )
- {
- itemTestClassName = item.getClassName();
- }
- }
- else if ( item.getChildren().size() > 0 )
- {
- fillTestCountMap( item );
- }
- else
- {
- classMethodCounts.put( item.getClassName(), testSet );
- }
- }
- if ( itemTestClassName != null )
- {
- classMethodCounts.put( itemTestClassName, testSet );
- }
- }
-
-}
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
index 6da62ae63..94a68536c 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
@@ -3,10 +3,11 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.2.2",
org.eclipse.ui.workbench;bundle-version="3.2.2";resolution:=optional,
org.eclipse.core.runtime;bundle-version="3.2.0"
Eclipse-AutoStart: true
-Bundle-ClassPath: .,
- jars/surefire-booter-2.10.jar,
- jars/surefire-api-2.10.jar
Bundle-Version: 0.22.0.qualifier
+Bundle-ClassPath: .,
+ jars/surefire-booter-2.17.jar,
+ jars/surefire-api-2.17.jar,
+ jars/maven-surefire-common-2.17.jar
Bundle-Name: Tycho Surefire OSGi Booter Eclipse Application (Incubation)
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.tycho.surefire.osgibooter;singleton:=true
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
index f87e333f4..4f01428cf 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
@@ -52,6 +52,11 @@
<artifactId>surefire-booter</artifactId>
<version>${surefire-version}</version>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>maven-surefire-common</artifactId>
+ <version>${surefire-version}</version>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/CombinedClassLoader.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/CombinedClassLoader.java
new file mode 100644
index 000000000..ccabfa304
--- /dev/null
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/CombinedClassLoader.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2014 SAP SE and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP SE - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.surefire.osgibooter;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+public class CombinedClassLoader extends ClassLoader {
+
+ private ClassLoader[] loaders;
+
+ public CombinedClassLoader(ClassLoader... loaders) {
+ this.loaders = loaders;
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ for (ClassLoader loader : loaders) {
+ try {
+ return loader.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // try next
+ }
+ }
+ throw new ClassNotFoundException(name);
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ List<URL> result = new ArrayList<URL>();
+ for (ClassLoader loader : loaders) {
+ Enumeration<URL> resources = loader.getResources(name);
+ while (resources.hasMoreElements()) {
+ result.add(resources.nextElement());
+ }
+ }
+ return Collections.enumeration(result);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ URL url = null;
+ for (ClassLoader loader : loaders) {
+ url = loader.getResource(name);
+ if (url != null) {
+ return url;
+ }
+ }
+ return null;
+ }
+}
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
index c1de8ec4c..26afcd47c 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.tycho.surefire.osgibooter;
+import static java.util.Collections.emptyList;
+
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -25,16 +27,20 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.apache.maven.plugin.surefire.StartupReportConfiguration;
+import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
+import org.apache.maven.surefire.booter.ClasspathConfiguration;
+import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.ProviderConfiguration;
+import org.apache.maven.surefire.booter.ProviderFactory;
import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.booter.StartupReportConfiguration;
-import org.apache.maven.surefire.booter.SurefireStarter;
import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.RunOrderParameters;
import org.apache.maven.surefire.testset.TestRequest;
-import org.apache.maven.surefire.util.RunOrder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -49,15 +55,13 @@ public class OsgiSurefireBooter {
boolean failIfNoTests = Boolean.parseBoolean(testProps.getProperty("failifnotests", "false"));
boolean redirectTestOutputToFile = Boolean.parseBoolean(testProps.getProperty("redirectTestOutputToFile",
"false"));
- String plugin = testProps.getProperty("testpluginname");
+ String testPlugin = testProps.getProperty("testpluginname");
File testClassesDir = new File(testProps.getProperty("testclassesdirectory"));
File reportsDir = new File(testProps.getProperty("reportsdirectory"));
String provider = testProps.getProperty("testprovider");
String runOrder = testProps.getProperty("runOrder");
- List<String> includes = getIncludesExcludes(testProps.getProperty("includes"));
- List<String> excludes = getIncludesExcludes(testProps.getProperty("excludes"));
- String forkMode = "never";
+ boolean forkRequested = true;
boolean inForkedVM = true;
boolean trimStacktrace = true;
boolean useSystemClassloader = false;
@@ -65,27 +69,35 @@ public class OsgiSurefireBooter {
boolean useFile = true;
boolean printSummary = true;
boolean disableXmlReport = false;
- ClassLoader testClassLoader = getBundleClassLoader(plugin);
- ClassLoader surefireClassLoader = SurefireStarter.class.getClassLoader();
- TychoClasspathConfiguration classPathConfig = new TychoClasspathConfiguration(testClassLoader,
- surefireClassLoader);
+ ClasspathConfiguration classPathConfig = new ClasspathConfiguration(false, false);
StartupConfiguration startupConfiguration = new StartupConfiguration(provider, classPathConfig,
- new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkMode, inForkedVM);
- DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters(testClassesDir, includes,
- excludes, failIfNoTests, RunOrder.valueOf(runOrder));
+ new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkRequested, inForkedVM);
+ // TODO dir scanning with no includes done here (done in TestMojo already)
+ // but without dirScannerParams we get an NPE accessing runOrder
+ DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters(testClassesDir, emptyList(),
+ emptyList(), emptyList(), failIfNoTests, runOrder);
ReporterConfiguration reporterConfig = new ReporterConfiguration(reportsDir, trimStacktrace);
TestRequest testRequest = new TestRequest(null, testClassesDir, null);
- ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, failIfNoTests,
- reporterConfig, null, testRequest, extractProviderProperties(testProps), null);
+ ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams,
+ new RunOrderParameters(runOrder, null), failIfNoTests, reporterConfig, null, testRequest,
+ extractProviderProperties(testProps), null, false);
StartupReportConfiguration startupReportConfig = new StartupReportConfiguration(useFile, printSummary,
StartupReportConfiguration.PLAIN_REPORT_FORMAT, redirectTestOutputToFile, disableXmlReport, reportsDir,
- trimStacktrace);
- SurefireStarter surefireStarter = new SurefireStarter(startupConfiguration, providerConfiguration,
- startupReportConfig);
+ trimStacktrace, null, "TESTHASH", false);
+ ReporterFactory reporterFactory = new DefaultReporterFactory(startupReportConfig);
+ // API indicates we should use testClassLoader below but surefire also tries
+ // to load surefire classes using this classloader
+ RunResult result = ProviderFactory.invokeProvider(null, createCombinedClassLoader(testPlugin), reporterFactory,
+ providerConfiguration, false, startupConfiguration, true);
+ // counter-intuitive, but null indicates OK here
+ return result.getFailsafeCode() == null ? 0 : result.getFailsafeCode();
+ }
- RunResult result = surefireStarter.runSuitesInProcess();
- return result.getForkedProcessCode();
+ private static ClassLoader createCombinedClassLoader(String testPlugin) throws BundleException {
+ ClassLoader testClassLoader = getBundleClassLoader(testPlugin);
+ ClassLoader surefireClassLoader = ForkedBooter.class.getClassLoader();
+ return new CombinedClassLoader(testClassLoader, surefireClassLoader);
}
/*
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java
deleted file mode 100644
index c94d3eabe..000000000
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tycho.surefire.osgibooter;
-
-import org.apache.maven.surefire.booter.ClasspathConfiguration;
-import org.apache.maven.surefire.booter.SurefireExecutionException;
-
-public class TychoClasspathConfiguration extends ClasspathConfiguration {
-
- private ClassLoader testClassLoader;
- private ClassLoader surefireClassLoader;
-
- public TychoClasspathConfiguration(ClassLoader testClassLoader, ClassLoader surefireCLassLoader) {
- super(false, false);
- this.testClassLoader = testClassLoader;
- this.surefireClassLoader = surefireCLassLoader;
- }
-
- @Override
- public ClassLoader createSurefireClassLoader(ClassLoader parent) throws SurefireExecutionException {
- return surefireClassLoader;
- }
-
- @Override
- public ClassLoader createTestClassLoader() throws SurefireExecutionException {
- return testClassLoader;
- }
-
- @Override
- public ClassLoader createTestClassLoader(boolean childDelegation) throws SurefireExecutionException {
- return testClassLoader;
- }
-
-}
diff --git a/tycho-surefire/pom.xml b/tycho-surefire/pom.xml
index 296074f29..b420c4df4 100644
--- a/tycho-surefire/pom.xml
+++ b/tycho-surefire/pom.xml
@@ -26,7 +26,11 @@
<name>Tycho Surefire Parent (Incubation)</name>
<properties>
- <surefire-version>2.10</surefire-version>
+ <surefire-version>2.17</surefire-version>
+ <!-- NOTE: when updating surefire version above, run BND manually to find Import-Package
+ statements to JUnit packages required for org.eclipse.tycho.surefire.junit* OSGi wrappers.
+ Surefire jars are shaded but not fully self-contained (various package dependencies to org.apache.maven.*
+ packages in classes we do not use) so we can't use BND (maven-bundle-plugin) for creating the wrappers -->
</properties>
<modules>
diff --git a/tycho-surefire/tycho-surefire-plugin/pom.xml b/tycho-surefire/tycho-surefire-plugin/pom.xml
index 7d4c34eec..6e5d55b28 100644
--- a/tycho-surefire/tycho-surefire-plugin/pom.xml
+++ b/tycho-surefire/tycho-surefire-plugin/pom.xml
@@ -106,5 +106,10 @@
<artifactId>tycho-p2-facade</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>maven-surefire-common</artifactId>
+ <version>${surefire-version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
index 2305a2a55..629058638 100644
--- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -35,6 +36,7 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.surefire.util.DirectoryScanner;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -42,7 +44,9 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
-import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.booter.ProviderParameterNames;
+import org.apache.maven.surefire.util.DefaultScanResult;
+import org.apache.maven.surefire.util.ScanResult;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.util.FileUtils;
@@ -61,9 +65,9 @@ import org.eclipse.tycho.ArtifactType;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.artifacts.DependencyArtifacts;
import org.eclipse.tycho.core.BundleProject;
+import org.eclipse.tycho.core.DependencyResolver;
import org.eclipse.tycho.core.DependencyResolverConfiguration;
import org.eclipse.tycho.core.TargetPlatformConfiguration;
-import org.eclipse.tycho.core.DependencyResolver;
import org.eclipse.tycho.core.TychoConstants;
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration;
@@ -822,24 +826,12 @@ public class TestMojo extends AbstractMojo {
p.put("reportsdirectory", reportsDirectory.getAbsolutePath());
p.put("redirectTestOutputToFile", String.valueOf(redirectTestOutputToFile));
- if (test != null) {
- String test = this.test;
- test = test.replace('.', '/');
- test = test.endsWith(".class") ? test : test + ".class";
- test = test.startsWith("**/") ? test : "**/" + test;
- p.put("includes", test);
- } else {
- if (testClass != null) {
- p.put("includes", testClass.replace('.', '/') + ".class");
- } else {
- p.put("includes", includes != null ? getIncludesExcludes(includes)
- : "**/Test*.class,**/*Test.class,**/*TestCase.class");
- p.put("excludes", excludes != null ? getIncludesExcludes(excludes) : "**/*$*");
- }
- }
p.put("failifnotests", String.valueOf(failIfNoTests));
p.put("runOrder", runOrder);
- for (Map.Entry entry : getMergedProviderProperties().entrySet()) {
+ Properties mergedProviderProperties = getMergedProviderProperties();
+ ScanResult scanResult = scanForTests();
+ scanResult.writeTo(mergedProviderProperties);
+ for (Map.Entry entry : mergedProviderProperties.entrySet()) {
p.put("__provider." + entry.getKey(), entry.getValue());
}
p.setProperty("testprovider", provider.getSurefireProviderClassName());
@@ -851,16 +843,41 @@ public class TestMojo extends AbstractMojo {
Properties result = new Properties();
result.putAll(providerProperties);
if (parallel != null) {
- result.put("parallel", parallel.name());
+ result.put(ProviderParameterNames.PARALLEL_PROP, parallel.name());
if (threadCount > 0) {
- result.put("threadCount", String.valueOf(threadCount));
+ result.put(ProviderParameterNames.THREADCOUNT_PROP, String.valueOf(threadCount));
}
- result.put("perCoreThreadCount", String.valueOf(perCoreThreadCount));
- result.put("useUnlimitedThreads", String.valueOf(useUnlimitedThreads));
+ result.put(/* JUnitCoreParameters.PERCORETHREADCOUNT_KEY */"perCoreThreadCount",
+ String.valueOf(perCoreThreadCount));
+ result.put(/* JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY */"useUnlimitedThreads",
+ String.valueOf(useUnlimitedThreads));
}
return result;
}
+ private ScanResult scanForTests() {
+ List<String> defaultIncludes = Arrays.asList("**/Test*.class", "**/*Test.class", "**/*TestCase.class");
+ List<String> defaultExcludes = Arrays.asList("**/*$*");
+ List<String> includeList;
+ if (test != null) {
+ String test = this.test;
+ test = test.replace('.', '/');
+ test = test.endsWith(".class") ? test : test + ".class";
+ test = test.startsWith("**/") ? test : "**/" + test;
+ includeList = Collections.singletonList(test);
+ } else if (testClass != null) {
+ includeList = Collections.singletonList(testClass.replace('.', '/') + ".class");
+ } else if (includes != null) {
+ includeList = includes;
+ } else {
+ includeList = defaultIncludes;
+ }
+ DirectoryScanner scanner = new DirectoryScanner(testClassesDirectory, includeList, excludes != null ? excludes
+ : defaultExcludes, Collections.<String> emptyList());
+ DefaultScanResult scanResult = scanner.scan();
+ return scanResult;
+ }
+
private void storeProperties(Properties p, File file) throws MojoExecutionException {
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
@@ -902,7 +919,7 @@ public class TestMojo extends AbstractMojo {
case 0:
getLog().info("All tests passed!");
break;
- case RunResult.NO_TESTS:
+ case 254/* RunResult.NO_TESTS */:
String message = "No tests found.";
if (failIfNoTests) {
throw new MojoFailureException(message);
@@ -910,7 +927,7 @@ public class TestMojo extends AbstractMojo {
getLog().warn(message);
}
break;
- case RunResult.FAILURE:
+ case 255/* RunResult.FAILURE */:
String errorMessage = "There are test failures.\n\nPlease refer to " + reportsDirectory
+ " for the individual test results.";
if (testFailureIgnore) {
diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
index edcc46a8c..5d62d3df1 100644
--- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
@@ -44,7 +44,7 @@ public class JUnit47Provider extends AbstractJUnitProvider {
}
public String getSurefireProviderClassName() {
- return "org.apache.maven.surefire.junitcore.OsgiEnabledJUnitCoreProvider";
+ return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
}
public Version getVersion() {

Back to the top