aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2013-01-23 09:27:48 (EST)
committerJohn Ross2013-01-23 09:39:37 (EST)
commit2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce (patch)
treec4984c43537a889ffcde6b3689f8c54fbff5f31b
parent98ba80bbb423e570559c61f6eeb18ac43e7cfe9e (diff)
downloadrt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.zip
rt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.tar.gz
rt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.tar.bz2
[Bug 395196] Add test for reject default value when not one of the options.
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb1/OSGI-INF/metatype/testfile.xml9
-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/Bug395196Test.java53
3 files changed, 63 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb1/OSGI-INF/metatype/testfile.xml b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb1/OSGI-INF/metatype/testfile.xml
index e4d907e..e54cc1e 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb1/OSGI-INF/metatype/testfile.xml
+++ b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb1/OSGI-INF/metatype/testfile.xml
@@ -53,10 +53,19 @@
<AD id="23" cardinality="4" default=",," type="String"/> <!-- String[3]{"","",""} -->
<AD id="24" cardinality="-8" default=",,,," type="Password"/> <!-- String[5]{"","","","",""} -->
</OCD>
+ <ocd id="ocd3" name="testRejectDefaultValueWhenNotAnOption">
+ <ad id="ocd3-ad1" default="" type="String">
+ <option label="Male" value="male"/>
+ <option label="Female" value="female"/>
+ </ad>
+ </ocd>
<Designate pid="org.eclipse.equinox.metatype.tests.tb1">
<Object ocdref="ocd1"/>
</Designate>
<Designate pid="org.eclipse.equinox.metatype.tests.tb1.getDefaultValues">
<Object ocdref="ocd2"/>
</Designate>
+ <Designate pid="org.eclipse.equinox.metatype.tests.tb1.testRejectDefaultValueWhenNotAnOption">
+ <Object ocdref="ocd3"/>
+ </Designate>
</md: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 f97bf31..4a76665 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
@@ -26,6 +26,7 @@ public class AllTests {
suite.addTestSuite(UnresolvedBundleTest.class);
suite.addTestSuite(GetDefaultValueTest.class);
suite.addTestSuite(IconTest.class);
+ suite.addTestSuite(Bug395196Test.class);
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug395196Test.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug395196Test.java
new file mode 100644
index 0000000..28dff16
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug395196Test.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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 org.eclipse.equinox.metatype.tests;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.metatype.*;
+
+/*
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=395196.
+ *
+ * This test enforces the behavior of rejecting a the default value of an
+ * attribute definition in an XML file that does not match one of the specified
+ * options. The attribute definition behaves as if no default value was
+ * declared.
+ */
+public class Bug395196Test extends AbstractTest {
+ private AttributeDefinition[] ads;
+ private Bundle bundle;
+ private MetaTypeInformation mti;
+ private ObjectClassDefinition ocd;
+
+ public void testRejectDefaultValueWhenNotAnOption() {
+ AttributeDefinition ad = findAttributeDefinitionById("ocd3-ad1", ads); //$NON-NLS-1$
+ assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
+ assertNull("Default value not matching one of the options was not rejected", ad.getDefaultValue()); //$NON-NLS-1$
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bundle = bundleInstaller.installBundle("tb1"); //$NON-NLS-1$
+ bundle.start();
+ mti = metatype.getMetaTypeInformation(bundle);
+ assertNotNull("Metatype information not found", mti); //$NON-NLS-1$
+ ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1.testRejectDefaultValueWhenNotAnOption", null); //$NON-NLS-1$
+ assertNotNull("Object class definition not found", ocd); //$NON-NLS-1$
+ ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
+ assertNotNull("Attribute definitions not found", ads); //$NON-NLS-1$
+ assertEquals("Wrong number of attribute definitions", 1, ads.length); //$NON-NLS-1$
+ }
+
+ protected void tearDown() throws Exception {
+ bundle.stop();
+ super.tearDown();
+ }
+}