diff options
author | John Ross | 2013-01-23 14:27:48 +0000 |
---|---|---|
committer | John Ross | 2013-01-23 14:39:37 +0000 |
commit | 2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce (patch) | |
tree | c4984c43537a889ffcde6b3689f8c54fbff5f31b | |
parent | 98ba80bbb423e570559c61f6eeb18ac43e7cfe9e (diff) | |
download | rt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.tar.gz rt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.tar.xz rt.equinox.bundles-2ae2bd1ef80a6e257d7bd7a190a33b83b003dcce.zip |
[Bug 395196] Add test for reject default value when not one of the options.
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 e4d907e4f..e54cc1e93 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 f97bf31a6..4a7666500 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 000000000..28dff1638 --- /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(); + } +} |