diff options
author | Lars Vogel | 2017-07-26 15:12:57 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-07-26 16:02:37 +0000 |
commit | 8d843c7e907241dd8dfc9ff89757a0bff8bf5d26 (patch) | |
tree | 9f25b950358967de9e3205fec6e7af242add3fcb | |
parent | 95ff5618eb3c6217e6d61c46dfaadb6e1d3a8fff (diff) | |
download | rt.equinox.framework-8d843c7e907241dd8dfc9ff89757a0bff8bf5d26.tar.gz rt.equinox.framework-8d843c7e907241dd8dfc9ff89757a0bff8bf5d26.tar.xz rt.equinox.framework-8d843c7e907241dd8dfc9ff89757a0bff8bf5d26.zip |
Bug 520220 - Remove tests for old 2.0 plug-in supportI20170726-2000
Removes tests and test data for the 2.0 plug-ins.
Change-Id: Ie34a45d1b778b4f1e55110713bed6be6d9977853
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
18 files changed, 0 insertions, 514 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath index 3fda40040..5e0b83342 100644 --- a/bundles/org.eclipse.osgi.tests/.classpath +++ b/bundles/org.eclipse.osgi.tests/.classpath @@ -112,13 +112,6 @@ <classpathentry kind="src" output="bundle_tests/geturl" path="bundles_src/geturl"/> <classpathentry kind="src" output="bundle_tests/test.bug375784" path="bundles_src/test.bug375784"/> <classpathentry kind="src" output="bundle_tests/storage.hooks.a" path="bundles_src/storage.hooks.a"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.a" path="bundles_src/test.plugins.a"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.b" path="bundles_src/test.plugins.b"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.c" path="bundles_src/test.plugins.c"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.d" path="bundles_src/test.plugins.d"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.e" path="bundles_src/test.plugins.e"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.f" path="bundles_src/test.plugins.f"/> - <classpathentry kind="src" output="bundle_tests/test.plugins.g" path="bundles_src/test.plugins.g"/> <classpathentry kind="src" output="bundle_tests/test.bug412228" path="bundles_src/test.bug412228"/> <classpathentry kind="src" output="bundle_tests/test.uninstall.start1" path="bundles_src/test.uninstall.start1"/> <classpathentry kind="src" output="bundle_tests/test.uninstall.start2" path="bundles_src/test.uninstall.start2"/> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.a/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.a/plugin.xml deleted file mode 100644 index 591634c55..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.a/plugin.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.a" - name="test.plugins.a" - version="1.0" - provider-name="Eclipse.org"> -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.b/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.b/plugin.xml deleted file mode 100644 index 4d6f8b3cb..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.b/plugin.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.b" - name="test.plugins.b" - version="1.0" - provider-name="Eclipse.org"> - <requires> - <import plugin="x1" version="1.0.0" match="perfect"/> - <import plugin="x2" version="1.0.0" match="equivalent"/> - <import plugin="x3" version="1.0.0" match="compatible"/> - <import plugin="x4" version="1.0.0" match="greaterOrEqual"/> - <import plugin="x5" version="1.0.0"/> - <import plugin="x6" version="1.0.0" export="true"/> - <import plugin="x7" version="1.0.0" optional="true"/> - </requires> - -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/plugin.xml deleted file mode 100644 index eac1182e1..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/plugin.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.c" - name="test.plugins.c" - version="1.0" - provider-name="Eclipse.org"> - <runtime> - <library name="."> - <export - name="test.plugins.c.exported.*"> - </export> - </library> - </runtime> -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/Test.java deleted file mode 100644 index a10afc869..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.c; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/Test.java deleted file mode 100644 index 8f7806fa1..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.c.exported; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/sub/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/sub/Test.java deleted file mode 100644 index 13d138762..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.c/test/plugins/c/exported/sub/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.c.exported.sub; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/plugin.xml deleted file mode 100644 index e6efcc1ff..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/plugin.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.d" - name="test.plugins.d" - version="1.0" - provider-name="Eclipse.org"> - <runtime> - <library name="."> - <export - name="*"> - </export> - </library> - </runtime> -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/Test.java deleted file mode 100644 index efb401d8c..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.d; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/Test.java deleted file mode 100644 index 6afbc6cde..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.d.exported; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/sub/Test.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/sub/Test.java deleted file mode 100644 index bbb6a8d05..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.d/test/plugins/d/exported/sub/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 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 test.plugins.d.exported.sub; - -public class Test { - // nothing -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/plugin.xml deleted file mode 100644 index 3096d7919..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/plugin.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.e" - name="test.plugins.e" - version="1.0" - provider-name="Eclipse.org" - class="test.plugins.e.Activator"> - <requires> - <import plugin="org.eclipse.core.runtime"/> - </requires> -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/test/plugins/e/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/test/plugins/e/Activator.java deleted file mode 100644 index afee7e8c3..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.e/test/plugins/e/Activator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ -package test.plugins.e; - -import java.util.Dictionary; -import java.util.Hashtable; -import org.osgi.framework.*; - -public class Activator implements BundleActivator { - - @Override - public void start(BundleContext context) throws Exception { - Dictionary<String, String> props = new Hashtable<String, String>(); - props.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, context.getBundle().getSymbolicName()); - context.registerService(Object.class, new Object(), props); - } - - @Override - public void stop(BundleContext context) throws Exception { - // nothing - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.f/plugin.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.f/plugin.xml deleted file mode 100644 index bc4f2d0e4..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.f/plugin.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin - id="test.plugins.f" - name="test.plugins.f" - version="1.0" - provider-name="Eclipse.org"> - <extension - id="test.plugin.f" - point="org.eclipse.core.runtime.applications"> - <application - cardinality="singleton-global" - thread="main" - visible="true"> - </application> - </extension> -</plugin> diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.g/fragment.xml b/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.g/fragment.xml deleted file mode 100644 index 734f8d66d..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.plugins.g/fragment.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<fragment - id="test.plugins.g" - name="test.plugins.g" - version="1.0" - provider-name="Eclipse.org" - plugin-id="x" - plugin-version="1.0"> -</fragment> diff --git a/bundles/org.eclipse.osgi.tests/pom.xml b/bundles/org.eclipse.osgi.tests/pom.xml index 3205e5eba..68bb935eb 100644 --- a/bundles/org.eclipse.osgi.tests/pom.xml +++ b/bundles/org.eclipse.osgi.tests/pom.xml @@ -58,11 +58,6 @@ <versionRange>0.0.0</versionRange> </requirement> <requirement> - <id>org.eclipse.osgi.compatibility.plugins</id> - <type>p2-installable-unit</type> - <versionRange>0.0.0</versionRange> - </requirement> - <requirement> <id>org.eclipse.osgi.compatibility.state</id> <type>p2-installable-unit</type> <versionRange>0.0.0</versionRange> diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java index 32d3b2a53..cc76d5b93 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java @@ -20,7 +20,6 @@ import org.eclipse.osgi.tests.internal.plugins.InstallTests; import org.eclipse.osgi.tests.listeners.ExceptionHandlerTests; import org.eclipse.osgi.tests.misc.MiscTests; import org.eclipse.osgi.tests.permissions.PermissionTests; -import org.eclipse.osgi.tests.plugins.OldStylePluginTests; import org.eclipse.osgi.tests.serviceregistry.ServiceRegistryTests; public class AutomatedTests extends TestCase { @@ -59,7 +58,6 @@ public class AutomatedTests extends TestCase { suite.addTest(org.eclipse.osgi.tests.util.AllTests.suite()); suite.addTest(MiscTests.suite()); suite.addTest(BundleTests.suite()); - suite.addTest(OldStylePluginTests.suite()); suite.addTest(ServiceRegistryTests.suite()); suite.addTest(EventManagerTests.suite()); suite.addTest(FilterTests.suite()); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/plugins/OldStylePluginTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/plugins/OldStylePluginTests.java deleted file mode 100644 index 0a2eb018c..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/plugins/OldStylePluginTests.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 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.plugins; - -import java.util.*; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.eclipse.core.tests.harness.CoreTest; -import org.eclipse.osgi.service.pluginconversion.PluginConverter; -import org.eclipse.osgi.tests.OSGiTestsActivator; -import org.eclipse.osgi.tests.bundles.BundleInstaller; -import org.osgi.framework.*; -import org.osgi.framework.namespace.*; -import org.osgi.framework.wiring.*; -import org.osgi.resource.Namespace; - -public class OldStylePluginTests extends CoreTest { - public static int BUNDLE_LISTENER = 0x01; - public static int SYNC_BUNDLE_LISTENER = 0x02; - public static int SIMPLE_RESULTS = 0x04; - public static final String BUNDLES_ROOT = "bundle_tests"; - private BundleInstaller installer; - private boolean compatPluginInstalled = false; - - public static Test suite() { - return new TestSuite(OldStylePluginTests.class); - } - - protected void setUp() throws Exception { - compatPluginInstalled = false; - for (BundleWire hostWire : getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(BundleWiring.class).getProvidedWires(HostNamespace.HOST_NAMESPACE)) { - if ("org.eclipse.osgi.compatibility.plugins".equals(hostWire.getRequirer().getSymbolicName())) { - compatPluginInstalled = true; - break; - } - } - if (compatPluginInstalled) { - assertTrue("Plugin compatibility fragment not configured.", getContext().getServiceReference(PluginConverter.class) != null); - } - installer = new BundleInstaller(BUNDLES_ROOT, OSGiTestsActivator.getContext()); - installer.refreshPackages(null); - } - - protected void tearDown() throws Exception { - installer.shutdown(); - installer = null; - } - - public BundleContext getContext() { - return OSGiTestsActivator.getContext(); - } - - public void testSimplePlugin() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.a"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - assertTrue("Did not expect any requirements.", revision.getDeclaredRequirements(null).isEmpty()); - } - - public void testImportPlugin() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.b"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - - Collection<BundleRequirement> requirements = revision.getDeclaredRequirements(null); - assertEquals("Wrong number of requirements: " + requirements, 7, requirements.size()); - int index = 0; - for (BundleRequirement req : requirements) { - index++; - Map<String, Object> matchAttributes = new HashMap<String, Object>(); - Map<String, Object> noMatchAttributes = new HashMap<String, Object>(); - - matchAttributes.put(BundleNamespace.BUNDLE_NAMESPACE, "x" + index); - noMatchAttributes.put(BundleNamespace.BUNDLE_NAMESPACE, "x" + index); - - Version match = null; - Version noMatch = null; - switch (index) { - case 1 : - match = Version.parseVersion("1.0.0"); - noMatch = Version.parseVersion("1.0.0.x"); - break; - case 2 : - match = Version.parseVersion("1.0.100"); - noMatch = Version.parseVersion("1.1"); - break; - case 4 : - match = Version.parseVersion("90000"); - noMatch = Version.parseVersion("0.1"); - break; - default : - match = Version.parseVersion("1.1"); - noMatch = Version.parseVersion("2.0"); - break; - } - - matchAttributes.put(AbstractWiringNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, match); - noMatchAttributes.put(AbstractWiringNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, noMatch); - Filter f = null; - try { - f = getContext().createFilter(req.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE)); - } catch (InvalidSyntaxException e) { - fail("Failed to create filter.", e); - } - assertTrue("Did not match requirement: " + req + ": against: " + matchAttributes, f.matches(matchAttributes)); - assertFalse("Unexpected match requirement: " + req + ": against: " + matchAttributes, f.matches(noMatchAttributes)); - - String resolution = req.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE); - if (resolution == null) { - resolution = Namespace.RESOLUTION_MANDATORY; - } - String visibility = req.getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE); - if (visibility == null) { - visibility = BundleNamespace.VISIBILITY_PRIVATE; - } - - if (index == 6) { - assertEquals("Wrong visibility: " + req, BundleNamespace.VISIBILITY_REEXPORT, visibility); - } else { - assertEquals("Wrong visibility: " + req, BundleNamespace.VISIBILITY_PRIVATE, visibility); - } - if (index == 7) { - assertEquals("Wrong resolution: " + req, Namespace.RESOLUTION_OPTIONAL, resolution); - } else { - assertEquals("Wrong resolution: " + req, Namespace.RESOLUTION_MANDATORY, resolution); - } - } - } - - public void testExportSinglePackage() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.c"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - assertTrue("Did not expect any requirements.", revision.getDeclaredRequirements(null).isEmpty()); - - Collection<BundleCapability> packages = revision.getDeclaredCapabilities(PackageNamespace.PACKAGE_NAMESPACE); - assertEquals("Wrong number of exports: " + packages, 1, packages.size()); - assertEquals("Wrong package name.", pluginName + ".exported", packages.iterator().next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)); - } - - public void testExportAllPackage() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.d"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - assertTrue("Did not expect any requirements.", revision.getDeclaredRequirements(null).isEmpty()); - - Collection<BundleCapability> packages = revision.getDeclaredCapabilities(PackageNamespace.PACKAGE_NAMESPACE); - assertEquals("Wrong number of exports: " + packages, 4, packages.size()); - Iterator<BundleCapability> iPackages = packages.iterator(); - // Note that '.' is exported because scaning for * found a resource (plugin.xml) in root of the bundle. - assertEquals("Wrong package name.", ".", iPackages.next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)); - assertEquals("Wrong package name.", pluginName, iPackages.next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)); - assertEquals("Wrong package name.", pluginName + ".exported", iPackages.next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)); - assertEquals("Wrong package name.", pluginName + ".exported.sub", iPackages.next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)); - } - - public void testActivator() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.e"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - - try { - bundle.start(); - Collection<ServiceReference<Object>> testServices = getContext().getServiceReferences(Object.class, "(" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + bundle.getSymbolicName() + ")"); - assertFalse("Did not find registered service.", testServices.isEmpty()); - } catch (BundleException e) { - fail("Failed to start bundle.", e); - } catch (InvalidSyntaxException e) { - fail("Failed to create filter.", e); - } - } - - public void testExtensionSingleton() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.f"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, true); - } - - public void testFragment() { - if (!compatPluginInstalled) { - return; - } - String pluginName = "test.plugins.g"; - Version pluginVersion = Version.parseVersion("1.0.0"); - Bundle bundle = installPlugin(pluginName, false); - BundleRevision revision = bundle.adapt(BundleRevision.class); - assertIdentity(revision, pluginName, pluginVersion, false); - assertTrue("revision is not a fragment.", (revision.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0); - Collection<BundleRequirement> reqs = revision.getDeclaredRequirements(HostNamespace.HOST_NAMESPACE); - assertEquals("Wrong number of host requirements.", 1, reqs.size()); - BundleRequirement req = reqs.iterator().next(); - - Map<String, Object> matchAttributes = new HashMap<String, Object>(); - Map<String, Object> noMatchAttributes = new HashMap<String, Object>(); - - matchAttributes.put(HostNamespace.HOST_NAMESPACE, "x"); - noMatchAttributes.put(HostNamespace.HOST_NAMESPACE, "x"); - - Version match = Version.parseVersion("1.1"); - Version noMatch = Version.parseVersion("2.0"); - - matchAttributes.put(AbstractWiringNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, match); - noMatchAttributes.put(AbstractWiringNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, noMatch); - Filter f = null; - try { - f = getContext().createFilter(req.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE)); - } catch (InvalidSyntaxException e) { - fail("Failed to create filter.", e); - } - assertTrue("Did not match requirement: " + req + ": against: " + matchAttributes, f.matches(matchAttributes)); - assertFalse("Unexpected match requirement: " + req + ": against: " + matchAttributes, f.matches(noMatchAttributes)); - - } - - private void assertIdentity(BundleRevision revision, String pluginName, Version pluginVersion, boolean isSingleton) { - assertEquals("Wrong symbolic name", pluginName, revision.getSymbolicName()); - assertEquals("Wrong version.", pluginVersion, revision.getVersion()); - Collection<BundleCapability> capabilities = new ArrayList<BundleCapability>(); - capabilities.addAll(revision.getDeclaredCapabilities(IdentityNamespace.IDENTITY_NAMESPACE)); - capabilities.addAll(revision.getDeclaredCapabilities(BundleNamespace.BUNDLE_NAMESPACE)); - capabilities.addAll(revision.getDeclaredCapabilities(HostNamespace.HOST_NAMESPACE)); - int expectedNumCaps = (revision.getTypes() & BundleRevision.TYPE_FRAGMENT) == 0 ? 3 : 1; - assertEquals("Wrong number of capabilities: " + capabilities, expectedNumCaps, capabilities.size()); - for (BundleCapability cap : capabilities) { - String namespace = cap.getNamespace(); - String versionKey = IdentityNamespace.IDENTITY_NAMESPACE.equals(namespace) ? IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE : AbstractWiringNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE; - Map<String, Object> attrs = cap.getAttributes(); - assertEquals("Wrong name: " + namespace, pluginName, attrs.get(namespace)); - assertEquals("Wrong version: " + namespace, pluginVersion, attrs.get(versionKey)); - String singletonDirective = cap.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE); - singletonDirective = singletonDirective == null ? Boolean.FALSE.toString() : singletonDirective; - assertEquals("Wrong singleton directive.", isSingleton, Boolean.TRUE.toString().equals(singletonDirective)); - } - } - - private Bundle installPlugin(String plugin, boolean expectedFailure) { - try { - return installer.installBundle(plugin); - } catch (BundleException e) { - if (!expectedFailure) { - fail("Failed to install plugin.", e); - } - return null; - } - } -}
\ No newline at end of file |