Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties10
-rw-r--r--bundles/org.eclipse.osgi.tests/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi.tests/profile.list28
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java88
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java39
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/TestService.java18
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/AllFrameworkHookTests.java1
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java52
9 files changed, 138 insertions, 102 deletions
diff --git a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
index e3d6680d1..42400e6dc 100644
--- a/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core OSGi Tests
Bundle-SymbolicName: org.eclipse.osgi.tests;singleton:=true
-Bundle-Version: 3.13.0.qualifier
+Bundle-Version: 3.13.100.qualifier
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Require-Bundle:
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index d9b008e35..73a1df83c 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -15,7 +15,8 @@ bin.includes = .,\
META-INF/,\
test.xml,\
bundle_tests/*.jar,\
- plugin.xml
+ plugin.xml,\
+ profile.list
source.bundle_tests/test.jar = bundles_src/test/
manifest.bundle_tests/test.jar = META-INF/MANIFEST.MF
@@ -235,13 +236,6 @@ source.bundle_tests/test.bug375784.jar = bundles_src/test.bug306181b/
manifest.bundle_tests/test.bug375784.jar = META-INF/MANIFEST.MF
source.bundle_tests/storage.hooks.a.jar = bundles_src/storage.hooks.a/
manifest.bundle_tests/storage.hooks.a.jar = META-INF/MANIFEST.MF
-source.bundle_tests/test.plugins.a.jar = bundles_src/test.plugins.a/
-source.bundle_tests/test.plugins.b.jar = bundles_src/test.plugins.b/
-source.bundle_tests/test.plugins.c.jar = bundles_src/test.plugins.c/
-source.bundle_tests/test.plugins.d.jar = bundles_src/test.plugins.d/
-source.bundle_tests/test.plugins.e.jar = bundles_src/test.plugins.e/
-source.bundle_tests/test.plugins.f.jar = bundles_src/test.plugins.f/
-source.bundle_tests/test.plugins.g.jar = bundles_src/test.plugins.g/
source.bundle_tests/test.bug412228.jar = bundles_src/test.bug412228/
manifest.bundle_tests/test.bug412228.jar = META-INF/MANIFEST.MF
source.bundle_tests/test.uninstall.start1.jar = bundles_src/test.uninstall.start1/
diff --git a/bundles/org.eclipse.osgi.tests/pom.xml b/bundles/org.eclipse.osgi.tests/pom.xml
index 3ed38f55d..1ecbb96b2 100644
--- a/bundles/org.eclipse.osgi.tests/pom.xml
+++ b/bundles/org.eclipse.osgi.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.tests</artifactId>
- <version>3.13.0-SNAPSHOT</version>
+ <version>3.13.100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/bundles/org.eclipse.osgi.tests/profile.list b/bundles/org.eclipse.osgi.tests/profile.list
new file mode 100644
index 000000000..b250cc50b
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/profile.list
@@ -0,0 +1,28 @@
+###############################################################################
+# Copyright (c) 2003, 2013 IBM Corporation 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+java.profiles = \
+ JavaSE-9.profile,\
+ JavaSE-1.8.profile,\
+ JavaSE-1.7.profile,\
+ JavaSE-1.6.profile,\
+ J2SE-1.5.profile,\
+ J2SE-1.4.profile,\
+ J2SE-1.3.profile,\
+ J2SE-1.2.profile,\
+ JRE-1.1.profile,\
+ JavaSE_compact1-1.8.profile,\
+ JavaSE_compact2-1.8.profile,\
+ JavaSE_compact3-1.8.profile,\
+ CDC-1.1_Foundation-1.1.profile,\
+ CDC-1.0_Foundation-1.0.profile,\
+ OSGi_Minimum-1.0.profile,\
+ OSGi_Minimum-1.1.profile,\
+ OSGi_Minimum-1.2.profile
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 32088dde0..5bbc8d2f9 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -32,16 +32,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.jws.WebService;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Service;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.ModuleClassLoader;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.Bundle;
@@ -52,7 +47,6 @@ import org.osgi.framework.BundleReference;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -1735,76 +1729,22 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
global.loadClass("test.bug438904.frag.Test2");
}
- public void testContextFinderGetResource() throws IOException, InvalidSyntaxException {
- // get the context finder explicitly to test incase the thread context class loader has changed
- ClassLoader contextFinder = getContext().getService(getContext().getServiceReferences(ClassLoader.class, "(equinox.classloader.type=contextClassLoader)").iterator().next());
- // Using a resource we know is in java 8.
- String resource = "META-INF/services/javax.print.PrintServiceLookup";
- URL systemURL = ClassLoader.getSystemClassLoader().getResource(resource);
- assertNotNull("Did not find a parent resource: " + resource, systemURL);
- //should return the file defined in test bundle.
- URL url = contextFinder.getResource(resource);
- //the first element should be the file define in this bundle.
- List<URL> urls = Collections.list(contextFinder.getResources(resource));
- // make sure we have a resource located in the parent
- assertTrue("Did not find a parent resource: " + urls, urls.size() > 1);
- //assert failed as it return the one defined in parent class.
- assertEquals(url.toExternalForm(), urls.get(0).toExternalForm());
- }
-
- @WebService(endpointInterface = "org.eclipse.osgi.tests.bundles.TestService")
- public static class TestServiceImpl implements TestService {
-
- @Override
- public String hello(final String name) {
- return "Hello " + name;
- }
-
- }
-
- /*
- * This test depends on the behavior of the JVM Endpoint implementation to use
- * the context class loader to try and find resources using an executor.
- * This is important because it causes the thread stack to have NO classes
- * loaded by a bundle class loader. This causes a condition that would
- * make ContextFinder.getResources to return null
- */
- public void testContextFinderEmptyGetResources() throws Exception {
- // get the context finder explicitly to test incase the thread context class loader has changed
- ClassLoader contextFinder = getContext().getService(getContext().getServiceReferences(ClassLoader.class, "(equinox.classloader.type=contextClassLoader)").iterator().next());
- ClassLoader previousTCCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(contextFinder);
- ExecutorService pool = null;
- try {
- pool = Executors.newFixedThreadPool(3);
+ public void testUnitTestForcompoundEnumerations() {
+ Enumeration<Object> result = BundleLoader.compoundEnumerations(null, Collections.emptyEnumeration());
+ assertNotNull("Null result.", result);
+ assertFalse("Found elements.", result.hasMoreElements());
- final String address = "http://localhost:23512/service";
+ result = BundleLoader.compoundEnumerations(Collections.emptyEnumeration(), null);
+ assertNotNull("Null result.", result);
+ assertFalse("Found elements.", result.hasMoreElements());
- final WebService annotation = TestService.class.getAnnotation(WebService.class);
- final String namespaceURI = annotation.serviceName();
- final String localPart = annotation.targetNamespace();
- final QName serviceName = new QName(namespaceURI, localPart);
+ result = BundleLoader.compoundEnumerations(null, null);
+ assertNotNull("Null result.", result);
+ assertFalse("Found elements.", result.hasMoreElements());
- final TestServiceImpl tsi = new TestServiceImpl();
- final Endpoint endpoint = Endpoint.create(tsi);
- final HashMap<String, Object> props = new HashMap<String, Object>();
- props.put(Endpoint.WSDL_SERVICE, serviceName);
-
- endpoint.setProperties(props);
- endpoint.setExecutor(pool);
- endpoint.publish(address);
- final URL wsdlURL = new URL(address + "?wsdl");
- final Service s = Service.create(wsdlURL, serviceName);
- assertNotNull("Service is null.", s);
- final TestService port = s.getPort(TestService.class);
-
- assertEquals("Wrong result.", "Hello World", port.hello("World"));
- } finally {
- Thread.currentThread().setContextClassLoader(previousTCCL);
- if (pool != null) {
- pool.shutdown();
- }
- }
+ result = BundleLoader.compoundEnumerations(Collections.emptyEnumeration(), Collections.emptyEnumeration());
+ assertNotNull("Null result.", result);
+ assertFalse("Found elements.", result.hasMoreElements());
}
public void testBundleClassLoaderEmptyGetResources() throws Exception {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index a294d54e3..df800f410 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -3763,4 +3763,43 @@ public class SystemBundleTests extends AbstractBundleTests {
}
}
+ public void testContextFinderGetResource() throws IOException, InvalidSyntaxException {
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map configuration = new HashMap();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ configuration.put(EquinoxConfiguration.PROP_CONTEXTCLASSLOADER_PARENT, EquinoxConfiguration.CONTEXTCLASSLOADER_PARENT_FWK);
+ Equinox equinox = null;
+ try {
+ equinox = new Equinox(configuration);
+ equinox.init();
+ BundleContext bc = equinox.getBundleContext();
+ // get the context finder explicitly to test
+ ClassLoader contextFinder = bc.getService(bc.getServiceReferences(ClassLoader.class, "(equinox.classloader.type=contextClassLoader)").iterator().next());
+ // Using a resource we know is in the framework
+ String resource = "profile.list";
+ URL fwkURL = Bundle.class.getClassLoader().getResource(resource);
+ assertNotNull("Did not find a parent resource: " + resource, fwkURL);
+ // should return the file defined in test bundle.
+ URL url = contextFinder.getResource(resource);
+ // the first element should be the file define in this bundle.
+ List<URL> urls = Collections.list(contextFinder.getResources(resource));
+ // make sure we have a resource located in the parent
+ assertTrue("Did not find a parent resource: " + urls, urls.size() > 1);
+ // assert failed as it return the one defined in parent class.
+ assertEquals(url.toExternalForm(), urls.get(0).toExternalForm());
+ } catch (BundleException e) {
+ fail("Failed init", e);
+ } finally {
+ try {
+ if (equinox != null) {
+ equinox.stop();
+ equinox.waitForStop(1000);
+ }
+ } catch (BundleException e) {
+ fail("Failed to stop framework.", e);
+ } catch (InterruptedException e) {
+ fail("Failed to stop framework.", e);
+ }
+ }
+ }
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/TestService.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/TestService.java
deleted file mode 100644
index c3d2ea34f..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/TestService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.bundles;
-
-import javax.jws.WebService;
-
-@WebService(serviceName = "Foo", targetNamespace = "http://bar")
-public interface TestService {
- String hello(String name);
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/AllFrameworkHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/AllFrameworkHookTests.java
index 7f46fee67..877062acd 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/AllFrameworkHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/AllFrameworkHookTests.java
@@ -19,6 +19,7 @@ public class AllFrameworkHookTests {
suite.addTest(new TestSuite(StorageHookTests.class));
suite.addTest(new TestSuite(ClassLoaderHookTests.class));
suite.addTest(new TestSuite(BundleFileWrapperFactoryHookTests.class));
+ suite.addTest(new TestSuite(ContextFinderTests.class));
return suite;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java
new file mode 100644
index 000000000..8521eb651
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2017 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.hooks.framework;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.launch.Framework;
+
+public class ContextFinderTests extends AbstractFrameworkHookTests {
+
+ private Map<String, String> configuration;
+ private Framework framework;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ File file = OSGiTestsActivator.getContext().getDataFile(getName());
+ configuration = new HashMap<String, String>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, file.getAbsolutePath());
+ framework = createFramework(configuration);
+ initAndStart(framework);
+ }
+
+ protected void tearDown() throws Exception {
+ stopQuietly(framework);
+ super.tearDown();
+ }
+
+ public void testContextClassLoaderNullLocal() throws InvalidSyntaxException, IOException {
+ BundleContext bc = framework.getBundleContext();
+ ClassLoader contextFinder = bc.getService(bc.getServiceReferences(ClassLoader.class, "(equinox.classloader.type=contextClassLoader)").iterator().next());
+ Enumeration<URL> result = contextFinder.getResources("does/not/exist.txt");
+ assertNotNull("Null result.", result);
+ assertFalse("Found unexpected result", result.hasMoreElements());
+ }
+
+}

Back to the top