Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Dufour2018-11-29 19:42:03 -0500
committerMickael Istria2019-03-18 06:24:01 -0400
commit88054d04764d77a3d2f80054cd12319b735b1b13 (patch)
tree5cebd43689d3efd8a605ab3ba9fa0cc059cee39d
parent5b6ba58e0dd150ea513b2a0ef08e7cdedf032da9 (diff)
downloadorg.eclipse.tycho-88054d04764d77a3d2f80054cd12319b735b1b13.tar.gz
org.eclipse.tycho-88054d04764d77a3d2f80054cd12319b735b1b13.tar.xz
org.eclipse.tycho-88054d04764d77a3d2f80054cd12319b735b1b13.zip
Bug 485926 : contextfinder as surefire classloader
Change-Id: I6f6fd517cadc1bb9564badb776d61ae69e85ca29 Signed-off-by: Guillaume Dufour <guillaume.duff@gmail.com> Also-by: Jan Sievers <jan.sievers@sap.com>
-rw-r--r--tycho-its/pom.xml4
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/pom.xml36
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/META-INF/MANIFEST.MF12
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/build.properties4
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/pom.xml12
-rw-r--r--tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/src/org/eclipse/tycho/debugtychosurefire/bundle/HelloWorld.java30
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/META-INF/MANIFEST.MF9
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/build.properties4
-rwxr-xr-xtycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/pom.xml11
-rw-r--r--tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/src/org/eclipse/tycho/debugtychosurefire/bundletest/HelloWorldTest.java29
-rw-r--r--tycho-its/src/test/java/org/eclipse/tycho/test/surefire/RequireBundleTest.java32
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/ContextFinderWithoutTychoBundle.java217
-rw-r--r--tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java17
13 files changed, 405 insertions, 12 deletions
diff --git a/tycho-its/pom.xml b/tycho-its/pom.xml
index f5545560..5caf852b 100644
--- a/tycho-its/pom.xml
+++ b/tycho-its/pom.xml
@@ -181,6 +181,10 @@
<id>org.junit.jupiter.api</id>
<version>5.0.0.v20170910-2246</version>
</iu>
+ <iu>
+ <id>org.apache.xerces</id>
+ <version>2.9.0.v201101211617</version>
+ </iu>
</ius>
<includePacked>false</includePacked>
<includeOptional>false</includeOptional>
diff --git a/tycho-its/projects/surefire.requireBundle/pom.xml b/tycho-its/projects/surefire.requireBundle/pom.xml
new file mode 100755
index 00000000..3d1047ba
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/pom.xml
@@ -0,0 +1,36 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>surefire.requireBundle</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>parent</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>surefire.requireBundle.bundle</module>
+ <module>surefire.requireBundle.bundletest</module>
+ </modules>
+
+ <repositories>
+ <repository>
+ <id>oxygen</id>
+ <layout>p2</layout>
+ <url>${oxygen-repo}</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/META-INF/MANIFEST.MF b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/META-INF/MANIFEST.MF
new file mode 100755
index 00000000..94bc8f3a
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle
+Bundle-SymbolicName: surefire.requireBundle.core;singleton:=true
+Bundle-Version: 0.0.1.qualifier
+Bundle-Vendor: STEGMANNSYSTEMS
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.tycho.debugtychosurefire.bundle
+Require-Bundle: org.junit,
+ org.apache.xerces
+
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/build.properties b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/build.properties
new file mode 100755
index 00000000..34d2e4d2
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/pom.xml b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/pom.xml
new file mode 100755
index 00000000..df527302
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/pom.xml
@@ -0,0 +1,12 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>surefire.requireBundle</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>surefire.requireBundle.core</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/src/org/eclipse/tycho/debugtychosurefire/bundle/HelloWorld.java b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/src/org/eclipse/tycho/debugtychosurefire/bundle/HelloWorld.java
new file mode 100644
index 00000000..6482fe76
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundle/src/org/eclipse/tycho/debugtychosurefire/bundle/HelloWorld.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour 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:
+ * Guillaume Dufour - create test for indirect loading of class/resource
+ *******************************************************************************/
+package org.eclipse.tycho.debugtychosurefire.bundle;
+
+import static org.junit.Assert.fail;
+
+import javax.xml.validation.SchemaFactory;
+
+public class HelloWorld
+{
+
+ public String test()
+ {
+ final SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$
+ if (sf == null) {
+ fail("SchemaFactory not found");
+ return "SchemaFactory not found";
+ }
+ return "Hello World";
+ }
+
+}
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/META-INF/MANIFEST.MF b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/META-INF/MANIFEST.MF
new file mode 100755
index 00000000..c663e67a
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundletest
+Bundle-SymbolicName: surefire.requireBundle.coretest
+Bundle-Version: 0.0.1.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.junit,
+ surefire.requireBundle.core;bundle-version="0.0.1"
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/build.properties b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/build.properties
new file mode 100755
index 00000000..34d2e4d2
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/pom.xml b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/pom.xml
new file mode 100755
index 00000000..17dd4017
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/pom.xml
@@ -0,0 +1,11 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>surefire.requireBundle</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>surefire.requireBundle.coretest</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/src/org/eclipse/tycho/debugtychosurefire/bundletest/HelloWorldTest.java b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/src/org/eclipse/tycho/debugtychosurefire/bundletest/HelloWorldTest.java
new file mode 100644
index 00000000..c3bad2fd
--- /dev/null
+++ b/tycho-its/projects/surefire.requireBundle/surefire.requireBundle.bundletest/src/org/eclipse/tycho/debugtychosurefire/bundletest/HelloWorldTest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour 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:
+ * Guillaume Dufour - create test for indirect loading of class/resource
+ *******************************************************************************/
+package org.eclipse.tycho.debugtychosurefire.bundletest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import org.eclipse.tycho.debugtychosurefire.bundle.HelloWorld;
+
+public class HelloWorldTest
+{
+
+ @Test
+ public void test()
+ {
+ final HelloWorld hello = new HelloWorld();
+ assertEquals("Hello World", hello.test());
+ }
+
+}
diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/RequireBundleTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/RequireBundleTest.java
new file mode 100644
index 00000000..26a0558f
--- /dev/null
+++ b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/RequireBundleTest.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 Sonatype Inc. 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:
+ * Sonatype Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.test.surefire;
+
+import java.util.Properties;
+
+import org.apache.maven.it.Verifier;
+import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
+import org.eclipse.tycho.test.util.ResourceUtil.P2Repositories;
+import org.junit.Test;
+
+public class RequireBundleTest extends AbstractTychoIntegrationTest {
+
+ // requested in bug 485926
+ @Test
+ public void loadResourceFromRequireBundle() throws Exception {
+ Verifier verifier = getVerifier("/surefire.requireBundle", false, true);
+ Properties props = verifier.getSystemProperties();
+ props.setProperty("oxygen-repo", P2Repositories.ECLIPSE_OXYGEN.toString());
+ verifier.executeGoal("integration-test");
+ verifier.verifyErrorFreeLog();
+ }
+
+}
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/ContextFinderWithoutTychoBundle.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/ContextFinderWithoutTychoBundle.java
new file mode 100644
index 00000000..cb7109b0
--- /dev/null
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/ContextFinderWithoutTychoBundle.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Guillaume Dufour 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:
+ * Guillaume Dufour - create surefire tycho contextFinder to ignore tycho bundle
+ *******************************************************************************/
+package org.eclipse.tycho.surefire.osgibooter;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * based on org.eclipse.osgi.internal.framework.ContextFinder But remove all dependencies to
+ * org.eclipse.osgi.internal. In particular instanceof
+ * org.eclipse.osgi.internal.loader.ModuleClassLoader in basicFindClassLoaders This contextfinder is
+ * exactly the same as OSGI but exclude this bundle (org.eclipse.tycho.surefire.osgibooter) from
+ * contextfinder resolution.
+ */
+class ContextFinderWithoutTychoBundle extends ClassLoader implements PrivilegedAction<List<ClassLoader>> {
+ static final class Finder extends SecurityManager {
+ public Class<?>[] getClassContext() {
+ return super.getClassContext();
+ }
+ }
+
+ //This is used to detect cycle that could be caused while delegating the loading to other classloaders
+ //It keeps track on a thread basis of the set of requested classes and resources
+ private static ThreadLocal<Set<String>> cycleDetector = new ThreadLocal<Set<String>>();
+ static ClassLoader finderClassLoader;
+ static ContextFinderWithoutTychoBundle.Finder contextFinder;
+ static {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ finderClassLoader = ContextFinderWithoutTychoBundle.class.getClassLoader();
+ contextFinder = new Finder();
+ return null;
+ }
+ });
+ }
+
+ private static Class<ContextFinderWithoutTychoBundle> THIS = ContextFinderWithoutTychoBundle.class;
+ private static Class<CombinedClassLoader> COMBINED = CombinedClassLoader.class;
+
+ private final ClassLoader parentContextClassLoader;
+
+ public ContextFinderWithoutTychoBundle(ClassLoader contextClassLoader) {
+ super(contextClassLoader);
+ this.parentContextClassLoader = contextClassLoader;
+ }
+
+ // Return a list of all classloaders on the stack that are neither the
+ // ContextFinder classloader nor the boot classloader. The last classloader
+ // in the list is either a bundle classloader or the framework's classloader
+ // We assume that the bootclassloader never uses the context classloader to find classes in itself.
+ List<ClassLoader> basicFindClassLoaders() {
+ Class<?>[] stack = contextFinder.getClassContext();
+ List<ClassLoader> result = new ArrayList<ClassLoader>(1);
+ ClassLoader previousLoader = null;
+ for (int i = 1; i < stack.length; i++) {
+ ClassLoader tmp = stack[i].getClassLoader();
+ if (stack[i] != THIS && stack[i] != COMBINED && tmp != null && tmp != this) {
+ if (checkClassLoader(tmp)) {
+ if (previousLoader != tmp) {
+ result.add(tmp);
+ previousLoader = tmp;
+ }
+ }
+ // stop at the framework classloader or the first bundle classloader
+ if (tmp == finderClassLoader || isInstanceOfModuleClassLoader(tmp))
+ break;
+ }
+ }
+ return result;
+ }
+
+ // we cannot use instanceof ModuleClassLoader because it's internal osgi package
+ private boolean isInstanceOfModuleClassLoader(ClassLoader tmp) {
+ Class<?> current = tmp.getClass();
+ do {
+ if (current.getName().equals("org.eclipse.osgi.internal.loader.ModuleClassLoader")) {
+ return true;
+ }
+ current = current.getSuperclass();
+ } while (current != null);
+ return false;
+ }
+
+ // ensures that a classloader does not have the ContextFinder as part of the
+ // parent hierachy. A classloader which has the ContextFinder as a parent must
+ // not be used as a delegate, otherwise we endup in endless recursion.
+ private boolean checkClassLoader(ClassLoader classloader) {
+ if (classloader == null || classloader == getParent())
+ return false;
+ for (ClassLoader parent = classloader.getParent(); parent != null; parent = parent.getParent())
+ if (parent == this)
+ return false;
+ return true;
+ }
+
+ private List<ClassLoader> findClassLoaders() {
+ if (System.getSecurityManager() == null)
+ return basicFindClassLoaders();
+ return AccessController.doPrivileged(this);
+ }
+
+ public List<ClassLoader> run() {
+ return basicFindClassLoaders();
+ }
+
+ //Return whether the request for loading "name" should proceed.
+ //False is returned when a cycle is being detected
+ private boolean startLoading(String name) {
+ Set<String> classesAndResources = cycleDetector.get();
+ if (classesAndResources != null && classesAndResources.contains(name))
+ return false;
+
+ if (classesAndResources == null) {
+ classesAndResources = new HashSet<String>(3);
+ cycleDetector.set(classesAndResources);
+ }
+ classesAndResources.add(name);
+ return true;
+ }
+
+ private void stopLoading(String name) {
+ cycleDetector.get().remove(name);
+ }
+
+ protected Class<?> loadClass(String arg0, boolean arg1) throws ClassNotFoundException {
+ //Shortcut cycle
+ if (startLoading(arg0) == false)
+ throw new ClassNotFoundException(arg0);
+
+ try {
+ List<ClassLoader> toConsult = findClassLoaders();
+ for (Iterator<ClassLoader> loaders = toConsult.iterator(); loaders.hasNext();)
+ try {
+ return loaders.next().loadClass(arg0);
+ } catch (ClassNotFoundException e) {
+ // go to the next class loader
+ }
+ // avoid calling super.loadClass here because it checks the local cache (bug 127963)
+ return parentContextClassLoader.loadClass(arg0);
+ } finally {
+ stopLoading(arg0);
+ }
+ }
+
+ public URL getResource(String arg0) {
+ //Shortcut cycle
+ if (startLoading(arg0) == false)
+ return null;
+ try {
+ List<ClassLoader> toConsult = findClassLoaders();
+ for (Iterator<ClassLoader> loaders = toConsult.iterator(); loaders.hasNext();) {
+ URL result = loaders.next().getResource(arg0);
+ if (result != null)
+ return result;
+ // go to the next class loader
+ }
+ return super.getResource(arg0);
+ } finally {
+ stopLoading(arg0);
+ }
+ }
+
+ public Enumeration<URL> getResources(String arg0) throws IOException {
+ //Shortcut cycle
+ if (startLoading(arg0) == false) {
+ return Collections.enumeration(Collections.<URL> emptyList());
+ }
+ try {
+ List<ClassLoader> toConsult = findClassLoaders();
+ Enumeration<URL> result = null;
+ for (Iterator<ClassLoader> loaders = toConsult.iterator(); loaders.hasNext();) {
+ result = loaders.next().getResources(arg0);
+ if (result != null && result.hasMoreElements()) {
+ // For context finder we do not compound results after this first loader that has resources
+ break;
+ }
+ // no results yet, go to the next class loader
+ }
+ return compoundEnumerations(result, super.getResources(arg0));
+ } finally {
+ stopLoading(arg0);
+ }
+ }
+
+ public static <E> Enumeration<E> compoundEnumerations(Enumeration<E> list1, Enumeration<E> list2) {
+ if (list2 == null || !list2.hasMoreElements())
+ return list1 == null ? Collections.<E> emptyEnumeration() : list1;
+ if (list1 == null || !list1.hasMoreElements())
+ return list2 == null ? Collections.<E> emptyEnumeration() : list2;
+ List<E> compoundResults = new ArrayList<E>();
+ while (list1.hasMoreElements())
+ compoundResults.add(list1.nextElement());
+ while (list2.hasMoreElements()) {
+ E item = list2.nextElement();
+ if (!compoundResults.contains(item)) //don't add duplicates
+ compoundResults.add(item);
+ }
+ return Collections.enumeration(compoundResults);
+ }
+}
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 039064ca..f6b4c016 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
@@ -17,8 +17,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -115,8 +113,12 @@ public class OsgiSurefireBooter {
private static ClassLoader createCombinedClassLoader(String testPlugin) throws BundleException {
ClassLoader testClassLoader = getBundleClassLoader(testPlugin);
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader surefireClassLoader = ForkedBooter.class.getClassLoader();
- return new CombinedClassLoader(testClassLoader, surefireClassLoader);
+ return new CombinedClassLoader(testClassLoader, surefireClassLoader,
+ // Not used contextClassLoader directly because it's a ContextFinder
+ // which not work with tycho sufire osgibooster bundle
+ new ContextFinderWithoutTychoBundle(contextClassLoader.getParent()));
}
/*
@@ -151,14 +153,6 @@ public class OsgiSurefireBooter {
null));
}
- private static List<String> getIncludesExcludes(String string) {
- ArrayList<String> list = new ArrayList<String>();
- if (string != null) {
- list.addAll(Arrays.asList(string.split(",")));
- }
- return list;
- }
-
private static Properties loadProperties(File file) throws IOException {
Properties p = new Properties();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
@@ -192,7 +186,6 @@ public class OsgiSurefireBooter {
}
throw ex;
}
-
return new BundleClassLoader(bundle);
}

Back to the top