aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2011-11-18 13:24:26 (EST)
committerJohn Ross2011-11-18 13:26:34 (EST)
commit1d478e3bff188ccbed8408fa8d12985ea7e02e1a (patch)
tree2c9da13e1899a0bf90fb127823d6971543c86384
parent7a03fea698d27f67f32132fc296a996b99c07d32 (diff)
downloadrt.equinox.bundles-1d478e3bff188ccbed8408fa8d12985ea7e02e1a.zip
rt.equinox.bundles-1d478e3bff188ccbed8408fa8d12985ea7e02e1a.tar.gz
rt.equinox.bundles-1d478e3bff188ccbed8408fa8d12985ea7e02e1a.tar.bz2
Bug 363374: New test for unresolved bundle.
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/.classpath1
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/OSGI-INF/metatype/metadata.xml12
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/UnresolvedBundleTest.java52
5 files changed, 73 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.compendium.tests/.classpath b/bundles/org.eclipse.equinox.compendium.tests/.classpath
index d08a0ac..854e6df 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/.classpath
+++ b/bundles/org.eclipse.equinox.compendium.tests/.classpath
@@ -10,6 +10,7 @@
<classpathentry kind="src" output="bundle_tests/metatype/tb5" path="bundles_src/metatype/tb5"/>
<classpathentry kind="src" output="bundle_tests/metatype/tb6" path="bundles_src/metatype/tb6"/>
<classpathentry kind="src" output="bundle_tests/metatype/tb7" path="bundles_src/metatype/tb7"/>
+ <classpathentry kind="src" output="bundle_tests/metatype/tb8" path="bundles_src/metatype/tb8"/>
<classpathentry kind="src" output="bundle_tests/metatype/extendable.tb1" path="bundles_src/metatype/extendable.tb1"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..c532493
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: MetaType TB8
+Bundle-SymbolicName: org.eclipse.equinox.metatype.tests.tb8
+Bundle-Version: 1.0.0
+Import-Package: does.not.exist
+Bundle-Vendor: IBM
diff --git a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/OSGI-INF/metatype/metadata.xml b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/OSGI-INF/metatype/metadata.xml
new file mode 100644
index 0000000..370592b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb8/OSGI-INF/metatype/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<MetaData
+ xmlns="http://www.org.osgi/xmlns/metatype/v1.2.0/md"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.org.osgi/xmlns/metatype/v1.2.0/md metatype.xsd">
+ <OCD id="ocd1" name="ocd1">
+ <AD name="ad1" id="ad1" type="String"/>
+ </OCD>
+ <Designate pid="org.eclipse.equinox.metatype.tests.tb8">
+ <Object ocdref="ocd1"/>
+ </Designate>
+</MetaData>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
index 3cb601a..f530f08 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
@@ -23,6 +23,7 @@ public class AllTests {
suite.addTestSuite(SameOcdPidFactoryPidTest.class);
suite.addTestSuite(ExtendableTest.class);
suite.addTestSuite(Bug358969Test.class);
+ suite.addTestSuite(UnresolvedBundleTest.class);
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/UnresolvedBundleTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/UnresolvedBundleTest.java
new file mode 100644
index 0000000..ff9242a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/UnresolvedBundleTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.equinox.metatype.tests;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.metatype.*;
+
+/*
+ * Ensure the metadata XML information from an unresolved bundle is provided.
+ *
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=363374.
+ */
+public class UnresolvedBundleTest extends AbstractTest {
+ private Bundle bundle;
+
+ public void testUnresolvedBundle() {
+ assertBundleUnresolved();
+ MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
+ assertNotNull("Metatype information was null", mti); //$NON-NLS-1$
+ ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb8", null); //$NON-NLS-1$
+ assertNotNull("Object class definition was null", ocd); //$NON-NLS-1$
+ AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
+ assertEquals("Wrong number of attribute definitions", 1, ads.length); //$NON-NLS-1$
+ AttributeDefinition ad = ads[0];
+ assertNotNull("Attribute definition was null", ad); //$NON-NLS-1$
+ assertEquals("Wrong attribute definition ID", "ad1", ad.getID()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Wrong attribute definition name", "ad1", ad.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Wrong attribute definition type", AttributeDefinition.STRING, ad.getType()); //$NON-NLS-1$
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bundle = bundleInstaller.installBundle("tb8"); //$NON-NLS-1$
+ assertBundleUnresolved();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private void assertBundleUnresolved() {
+ assertEquals("Bundle should not be resolved", Bundle.INSTALLED, bundle.getState()); //$NON-NLS-1$
+ }
+}