Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-03-25 15:59:39 +0000
committerThomas Watson2019-03-26 13:19:04 +0000
commitb8ef56795cacdff976ba95a295f678a60f2dab57 (patch)
treed8d447752aef14860f33f94e50103b225ba7c464 /bundles/org.eclipse.equinox.compendium.tests
parenteef56d7fab3c18eefe1c226d8eca0e979143e5ed (diff)
downloadrt.equinox.bundles-b8ef56795cacdff976ba95a295f678a60f2dab57.tar.gz
rt.equinox.bundles-b8ef56795cacdff976ba95a295f678a60f2dab57.tar.xz
rt.equinox.bundles-b8ef56795cacdff976ba95a295f678a60f2dab57.zip
Bug 545788 - [metatype] provide caching of metatype informationI20190327-1800I20190326-2305I20190326-1800
Change-Id: If76fa973a32f1dedded57211370c64bd5d81c7cf Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.compendium.tests')
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb9/OSGI-INF/metatype/metadata.xml6
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java24
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java42
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug332161Test.java72
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug340899Test.java18
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug395196Test.java20
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/BugTests.java21
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java8
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java8
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/IconTest.java37
-rwxr-xr-xbundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/NoADTest.java41
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java45
12 files changed, 236 insertions, 106 deletions
diff --git a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb9/OSGI-INF/metatype/metadata.xml b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb9/OSGI-INF/metatype/metadata.xml
index eb86ab3fb..6e45c1ad9 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb9/OSGI-INF/metatype/metadata.xml
+++ b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/tb9/OSGI-INF/metatype/metadata.xml
@@ -5,9 +5,9 @@
xsi:schemaLocation="http://www.org.osgi/xmlns/metatype/v1.2.0/md metatype.xsd">
<OCD id="1" name="ocd1">
<AD name="ad1" id="1" type="String"/>
- <Icon size="10000" resource="icons/tn_ibm_turns_100-100x100.jpg"/>
- <Icon size="22500" resource="icons/tn_ibm_turns_100-150x150.jpg"/>
- <Icon size="40000" resource="icons/tn_ibm_turns_100-200x200.jpg"/>
+ <Icon size="4931" resource="icons/tn_ibm_turns_100-100x100.jpg"/>
+ <Icon size="7933" resource="icons/tn_ibm_turns_100-150x150.jpg"/>
+ <Icon size="10182" resource="icons/tn_ibm_turns_100-200x200.jpg"/>
</OCD>
<OCD id="2" name="ocd2">
<AD id="1" name="ad1" type="Byte"/>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java
index 406d336ad..8c0358430 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java
@@ -17,8 +17,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.*;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
import org.eclipse.equinox.compendium.tests.Activator;
import org.eclipse.equinox.metatype.EquinoxMetaTypeService;
import org.eclipse.osgi.tests.bundles.BundleInstaller;
@@ -72,8 +70,7 @@ public abstract class AbstractTest {
} finally {
icon.close();
}
- Icon i = new ImageIcon(baos.toByteArray());
- Assert.assertEquals("Wrong icon size", size, i.getIconHeight() * i.getIconWidth()); //$NON-NLS-1$
+ Assert.assertEquals("Wrong size.", size, baos.size()); //$NON-NLS-1$
} finally {
baos.close();
}
@@ -146,18 +143,35 @@ public abstract class AbstractTest {
@Before
public void setUp() throws Exception {
+ startMetatype();
+ bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
+ }
+
+ private void startMetatype() throws Exception {
Activator.getBundle(Activator.BUNDLE_METATYPE).start();
metaTypeReference = Activator.getBundleContext().getServiceReference(EquinoxMetaTypeService.class);
Assert.assertNotNull("Metatype service reference not found", metaTypeReference); //$NON-NLS-1$
metatype = Activator.getBundleContext().getService(metaTypeReference);
Assert.assertNotNull("Metatype service not found", metatype); //$NON-NLS-1$
- bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
}
@After
public void tearDown() throws Exception {
bundleInstaller.shutdown();
+ stopMetatype();
+ }
+
+ private void stopMetatype() throws Exception {
Activator.getBundleContext().ungetService(metaTypeReference);
Activator.getBundle(Activator.BUNDLE_METATYPE).stop();
}
+
+ public void restartMetatype() {
+ try {
+ stopMetatype();
+ startMetatype();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java
index e4587b5e4..3393f8564 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java
@@ -27,17 +27,17 @@ public class AttributeTypePasswordTest extends AbstractTest {
bundle.start();
}
- @After
- public void tearDown() throws Exception {
- bundle.stop();
- super.tearDown();
- }
-
/*
* Ensures the PASSWORD type is recognized.
*/
@Test
public void testAttributeTypePassword1() {
+ doTestAttributeTypePassword1();
+ restartMetatype();
+ doTestAttributeTypePassword1();
+ }
+
+ private void doTestAttributeTypePassword1() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
@@ -53,6 +53,12 @@ public class AttributeTypePasswordTest extends AbstractTest {
*/
@Test
public void testAttributeTypePassword2() {
+ doTestAttributeTypePassword2();
+ restartMetatype();
+ doTestAttributeTypePassword2();
+ }
+
+ private void doTestAttributeTypePassword2() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
@@ -66,6 +72,12 @@ public class AttributeTypePasswordTest extends AbstractTest {
*/
@Test
public void testAttributeTypePassword3() {
+ doTestAttributeTypePassword3();
+ restartMetatype();
+ doTestAttributeTypePassword3();
+ }
+
+ private void doTestAttributeTypePassword3() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
@@ -80,6 +92,12 @@ public class AttributeTypePasswordTest extends AbstractTest {
*/
@Test
public void testAttributeTypePassword4() {
+ doTestAttributeTypePassword4();
+ restartMetatype();
+ doTestAttributeTypePassword4();
+ }
+
+ private void doTestAttributeTypePassword4() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
@@ -95,6 +113,12 @@ public class AttributeTypePasswordTest extends AbstractTest {
*/
@Test
public void testAttributeTypePassword5() {
+ doTestAttributeTypePassword5();
+ restartMetatype();
+ doTestAttributeTypePassword5();
+ }
+
+ private void doTestAttributeTypePassword5() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
@@ -110,6 +134,12 @@ public class AttributeTypePasswordTest extends AbstractTest {
*/
@Test
public void testAttributeTypePassword6() {
+ doTestAttributeTypePassword6();
+ restartMetatype();
+ doTestAttributeTypePassword6();
+ }
+
+ private void doTestAttributeTypePassword6() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug332161Test.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug332161Test.java
index 2e09342c3..472a74778 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug332161Test.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug332161Test.java
@@ -109,6 +109,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test1() {
+ doTest1();
+ restartMetatype();
+ doTest1();
+ }
+
+ private void doTest1() {
AttributeDefinition ad = findAttributeDefinitionById("char1", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String defaultValue = getFirstDefaultValue(ad.getDefaultValue());
@@ -133,6 +139,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test2() {
+ doTest2();
+ restartMetatype();
+ doTest2();
+ }
+
+ private void doTest2() {
AttributeDefinition ad = findAttributeDefinitionById("string1", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String defaultValue = getFirstDefaultValue(ad.getDefaultValue());
@@ -148,6 +160,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test3() {
+ doTest3();
+ restartMetatype();
+ doTest3();
+ }
+
+ private void doTest3() {
AttributeDefinition ad = findAttributeDefinitionById("string2", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String[] defaultValue = ad.getDefaultValue();
@@ -186,6 +204,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test4() {
+ doTest4();
+ restartMetatype();
+ doTest4();
+ }
+
+ private void doTest4() {
AttributeDefinition ad = findAttributeDefinitionById("string3", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
assertNull("Default value was not null", ad.getDefaultValue()); //$NON-NLS-1$
@@ -196,6 +220,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test5() {
+ doTest5();
+ restartMetatype();
+ doTest5();
+ }
+
+ private void doTest5() {
AttributeDefinition ad = findAttributeDefinitionById("char2", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
assertNull("Default value was not null", ad.getDefaultValue()); //$NON-NLS-1$
@@ -208,6 +238,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test6() {
+ doTest6();
+ restartMetatype();
+ doTest6();
+ }
+
+ private void doTest6() {
AttributeDefinition ad = findAttributeDefinitionById("string3", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
assertValidationFail(null, ad);
@@ -222,6 +258,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test7() {
+ doTest7();
+ restartMetatype();
+ doTest7();
+ }
+
+ private void doTest7() {
AttributeDefinition ad = findAttributeDefinitionById("char3", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
assertValidationPass("\\\u0009", ad); //$NON-NLS-1$
@@ -242,6 +284,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test8() {
+ doTest8();
+ restartMetatype();
+ doTest8();
+ }
+
+ private void doTest8() {
AttributeDefinition ad = findAttributeDefinitionById("string4", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String[] defaultValue = ad.getDefaultValue();
@@ -262,6 +310,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test9() {
+ doTest9();
+ restartMetatype();
+ doTest9();
+ }
+
+ private void doTest9() {
AttributeDefinition ad = findAttributeDefinitionById("integer1", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String[] defaultValue = ad.getDefaultValue();
@@ -276,6 +330,12 @@ public class Bug332161Test extends AbstractTest {
*/
@Test
public void test10() {
+ doTest10();
+ restartMetatype();
+ doTest10();
+ }
+
+ private void doTest10() {
AttributeDefinition ad = findAttributeDefinitionById("string5", ads); //$NON-NLS-1$
Assert.assertNotNull("Attribute definition not found", ad); //$NON-NLS-1$
String[] defaultValue = ad.getDefaultValue();
@@ -298,6 +358,10 @@ public class Bug332161Test extends AbstractTest {
super.setUp();
bundle = bundleInstaller.installBundle("tb4"); //$NON-NLS-1$
bundle.start();
+ getMetatypeObjects();
+ }
+
+ private void getMetatypeObjects() {
mti = metatype.getMetaTypeInformation(bundle);
Assert.assertNotNull("Metatype information not found", mti); //$NON-NLS-1$
ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb4", null); //$NON-NLS-1$
@@ -307,10 +371,10 @@ public class Bug332161Test extends AbstractTest {
Assert.assertEquals("Wrong number of attribute definitions", 9, ads.length); //$NON-NLS-1$
}
- @After
- public void tearDown() throws Exception {
- bundle.stop();
- super.tearDown();
+ @Override
+ public void restartMetatype() {
+ super.restartMetatype();
+ getMetatypeObjects();
}
private void validateChar1Options(String[] optionLabels, String[] optionValues) {
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug340899Test.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug340899Test.java
index bf9e3fb61..d59c4fa14 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug340899Test.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/Bug340899Test.java
@@ -31,6 +31,12 @@ public class Bug340899Test extends AbstractTest {
*/
@Test
public void test1() throws Exception {
+ doTest1();
+ restartMetatype();
+ doTest1();
+ }
+
+ private void doTest1() throws Exception {
execute("tb5", "org.eclipse.equinox.metatype.tests.tb5"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -41,6 +47,12 @@ public class Bug340899Test extends AbstractTest {
*/
@Test
public void test2() throws Exception {
+ doTest2();
+ restartMetatype();
+ doTest2();
+ }
+
+ private void doTest2() throws Exception {
execute("tb6", "org.eclipse.equinox.metatype.tests.tb6"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -51,6 +63,12 @@ public class Bug340899Test extends AbstractTest {
*/
@Test
public void test3() throws Exception {
+ doTest3();
+ restartMetatype();
+ doTest3();
+ }
+
+ private void doTest3() throws Exception {
execute("tb7", "org.eclipse.equinox.metatype.tests.tb7"); //$NON-NLS-1$ //$NON-NLS-2$
}
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
index f34069f3a..86aa9899a 100644
--- 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
@@ -34,7 +34,13 @@ public class Bug395196Test extends AbstractTest {
private ObjectClassDefinition ocd;
@Test
- public void testRejectDefaultValueWhenNotAnOption() {
+ public void testRejectDefaultValueWhenNotAnOption() throws Exception {
+ doTestRejectDefaultValueWhenNotAnOption();
+ restartMetatype();
+ doTestRejectDefaultValueWhenNotAnOption();
+ }
+
+ private void doTestRejectDefaultValueWhenNotAnOption() {
AttributeDefinition ad = findAttributeDefinitionById("ocd3-ad1", ads); //$NON-NLS-1$
Assert.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$
@@ -45,6 +51,10 @@ public class Bug395196Test extends AbstractTest {
super.setUp();
bundle = bundleInstaller.installBundle("tb1"); //$NON-NLS-1$
bundle.start();
+ getMetaTypeObjects();
+ }
+
+ private void getMetaTypeObjects() {
mti = metatype.getMetaTypeInformation(bundle);
Assert.assertNotNull("Metatype information not found", mti); //$NON-NLS-1$
ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1.testRejectDefaultValueWhenNotAnOption", null); //$NON-NLS-1$
@@ -54,9 +64,9 @@ public class Bug395196Test extends AbstractTest {
Assert.assertEquals("Wrong number of attribute definitions", 1, ads.length); //$NON-NLS-1$
}
- @After
- public void tearDown() throws Exception {
- bundle.stop();
- super.tearDown();
+ @Override
+ public void restartMetatype() {
+ super.restartMetatype();
+ getMetaTypeObjects();
}
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/BugTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/BugTests.java
index 26ad5000f..94e9d5c02 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/BugTests.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/BugTests.java
@@ -27,7 +27,13 @@ public class BugTests extends AbstractTest {
* A cardinality of zero should not require a default value to be specified.
*/
@Test
- public void test334642() {
+ public void test334642() throws Exception {
+ doTest334642();
+ restartMetatype();
+ doTest334642();
+ }
+
+ private void doTest334642() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
Assert.assertNotNull("Metatype information not found", mti); //$NON-NLS-1$
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb3", null); //$NON-NLS-1$
@@ -62,7 +68,13 @@ public class BugTests extends AbstractTest {
* StringIndexOutOfBoundsException when description or name attributes are an empty string
*/
@Test
- public void test341963() {
+ public void test341963() throws Exception {
+ doTest341963();
+ restartMetatype();
+ doTest341963();
+ }
+
+ private void doTest341963() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
Assert.assertNotNull("Metatype information not found", mti); //$NON-NLS-1$
ObjectClassDefinition ocd = mti.getObjectClassDefinition("ocd2", null); //$NON-NLS-1$
@@ -86,9 +98,4 @@ public class BugTests extends AbstractTest {
bundle.start();
}
- @After
- public void tearDown() throws Exception {
- bundle.stop();
- super.tearDown();
- }
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java
index 2aabe9b7e..899a3d6da 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java
@@ -33,7 +33,13 @@ public class ExtendableTest extends AbstractTest {
}
@Test
- public void testExtensions() {
+ public void testExtensions() throws Exception {
+ doTestExtensions();
+ restartMetatype();
+ doTestExtensions();
+ }
+
+ private void doTestExtensions() {
EquinoxMetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
EquinoxObjectClassDefinition ocd = mti.getObjectClassDefinition("metatype.extendable.tb1.1", null); //$NON-NLS-1$
Set<String> schemas = ocd.getExtensionUris();
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java
index c09b4a9a5..83c3ede8a 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java
@@ -30,7 +30,13 @@ public class GetDefaultValueTest extends AbstractTest {
private Bundle bundle;
@Test
- public void testGetDefaultValue() {
+ public void testGetDefaultValue() throws Exception {
+ doTestGetDefaultValue();
+ restartMetatype();
+ doTestGetDefaultValue();
+ }
+
+ private void doTestGetDefaultValue() {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
Assert.assertNotNull("Metatype information was null", mti); //$NON-NLS-1$
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1.getDefaultValues", null); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/IconTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/IconTest.java
index 4226a64f3..c72dfde63 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/IconTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/IconTest.java
@@ -15,7 +15,8 @@ package org.eclipse.equinox.metatype.tests;
import static org.junit.Assert.assertNull;
-import org.junit.*;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.service.metatype.*;
@@ -38,6 +39,12 @@ public class IconTest extends AbstractTest {
@Test
public void testIcon() throws Exception {
+ doTestIcon();
+ restartMetatype();
+ doTestIcon();
+ }
+
+ private void doTestIcon() throws Exception {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
assertNotNull(mti);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb9", null); //$NON-NLS-1$
@@ -45,19 +52,23 @@ public class IconTest extends AbstractTest {
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
assertAttributeDefinitions(ads, 1);
assertAttributeDefinition(ads[0], 0, null, null, "1", "ad1", null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$
- assertIcon(ocd.getIcon(10000), 10000);
- assertIcon(ocd.getIcon(22500), 22500);
- assertIcon(ocd.getIcon(40000), 40000);
- assertIcon(ocd.getIcon(5000), 10000);
- assertIcon(ocd.getIcon(50000), 40000);
- assertIcon(ocd.getIcon(16249), 10000);
- assertIcon(ocd.getIcon(16251), 22500);
- assertIcon(ocd.getIcon(31249), 22500);
- assertIcon(ocd.getIcon(31251), 40000);
+ assertIcon(ocd.getIcon(4931), 4931);
+ assertIcon(ocd.getIcon(7933), 7933);
+ assertIcon(ocd.getIcon(10182), 10182);
+ assertIcon(ocd.getIcon(5000), 4931);
+ assertIcon(ocd.getIcon(50000), 10182);
+ assertIcon(ocd.getIcon(6400), 4931);
+ assertIcon(ocd.getIcon(6500), 7933);
}
@Test
public void testNullIcon() throws Exception {
+ doTestNullIcon();
+ restartMetatype();
+ doTestNullIcon();
+ }
+
+ private void doTestNullIcon() throws Exception {
MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
assertNotNull(mti);
ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb9.2", null); //$NON-NLS-1$
@@ -73,10 +84,4 @@ public class IconTest extends AbstractTest {
super.setUp();
bundle = bundleInstaller.installBundle("tb9"); //$NON-NLS-1$
}
-
- @After
- public void tearDown() throws Exception {
- bundle.uninstall();
- super.tearDown();
- }
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/NoADTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/NoADTest.java
index e8a1d6b72..35ec280dc 100755
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/NoADTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/NoADTest.java
@@ -13,38 +13,17 @@
*******************************************************************************/
package org.eclipse.equinox.metatype.tests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.eclipse.osgi.tests.bundles.BundleInstaller;
import org.junit.*;
import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
import org.osgi.service.metatype.*;
-public class NoADTest {
+public class NoADTest extends AbstractTest {
private Bundle bundle;
- private BundleInstaller bundleInstaller;
- private MetaTypeService metaType;
- private ServiceReference<MetaTypeService> metaTypeReference;
@Before
public void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_METATYPE).start();
- metaTypeReference = Activator.getBundleContext().getServiceReference(MetaTypeService.class);
- metaType = Activator.getBundleContext().getService(metaTypeReference);
- bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
- bundleInstaller.refreshPackages(null);
+ super.setUp();
bundle = bundleInstaller.installBundle("tb10"); //$NON-NLS-1$
- bundle.start();
- }
-
- @After
- public void tearDown() throws Exception {
- bundleInstaller.shutdown();
- Activator.getBundleContext().ungetService(metaTypeReference);
- Activator.getBundle(Activator.BUNDLE_METATYPE).stop();
}
/*
@@ -52,17 +31,23 @@ public class NoADTest {
*/
@Test
public void testNoADs() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
+ doTestNoADs();
+ restartMetatype();
+ doTestNoADs();
+ }
+
+ private void doTestNoADs() {
+ MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
String[] pids = mti.getPids();
- assertNotNull("The pid was not present.", pids); //$NON-NLS-1$
- assertEquals("Not the expected number of pids.", 1, pids.length); //$NON-NLS-1$
- assertEquals("Expected pid was not present.", "no.ad.designate", pids[0]); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertNotNull("The pid was not present.", pids); //$NON-NLS-1$
+ Assert.assertEquals("Not the expected number of pids.", 1, pids.length); //$NON-NLS-1$
+ Assert.assertEquals("Expected pid was not present.", "no.ad.designate", pids[0]); //$NON-NLS-1$ //$NON-NLS-2$
ObjectClassDefinition ocd = mti.getObjectClassDefinition(pids[0], null);
AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
// seems we are not really spec compliant here
if (ads != null) {
// should really be null, but if not then make sure it is an empty array
- assertEquals("Found some ads: " + ads, 0, ads.length); //$NON-NLS-1$
+ Assert.assertEquals("Found some ads: " + ads, 0, ads.length); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java
index b20bf8b8a..64cd7dcea 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java
@@ -13,41 +13,20 @@
*******************************************************************************/
package org.eclipse.equinox.metatype.tests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.eclipse.osgi.tests.bundles.BundleInstaller;
import org.junit.*;
import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
import org.osgi.service.metatype.MetaTypeInformation;
-import org.osgi.service.metatype.MetaTypeService;
-public class SameOcdPidFactoryPidTest {
+public class SameOcdPidFactoryPidTest extends AbstractTest {
private Bundle bundle;
- private BundleInstaller bundleInstaller;
- private MetaTypeService metaType;
- private ServiceReference<MetaTypeService> metaTypeReference;
@Before
public void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_METATYPE).start();
- metaTypeReference = Activator.getBundleContext().getServiceReference(MetaTypeService.class);
- metaType = Activator.getBundleContext().getService(metaTypeReference);
- bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
- bundleInstaller.refreshPackages(null);
+ super.setUp();
bundle = bundleInstaller.installBundle("tb2"); //$NON-NLS-1$
bundle.start();
}
- @After
- public void tearDown() throws Exception {
- bundleInstaller.shutdown();
- Activator.getBundleContext().ungetService(metaTypeReference);
- Activator.getBundle(Activator.BUNDLE_METATYPE).stop();
- }
-
/*
* Ensures the same OCD referred to by two Designate elements, one using
* the factoryPid attribute and the other only the pid attribute, is
@@ -55,14 +34,20 @@ public class SameOcdPidFactoryPidTest {
*/
@Test
public void test1() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
+ doTest1();
+ restartMetatype();
+ doTest1();
+ }
+
+ private void doTest1() {
+ MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle);
String[] pids = mti.getPids();
- assertNotNull("The pid 'singleton' was not present.", pids); //$NON-NLS-1$
- assertEquals("Not the expected number of pids.", 1, pids.length); //$NON-NLS-1$
- assertEquals("Expected pid was not present.", "singleton", pids[0]); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertNotNull("The pid 'singleton' was not present.", pids); //$NON-NLS-1$
+ Assert.assertEquals("Not the expected number of pids.", 1, pids.length); //$NON-NLS-1$
+ Assert.assertEquals("Expected pid was not present.", "singleton", pids[0]); //$NON-NLS-1$ //$NON-NLS-2$
String[] factoryPids = mti.getFactoryPids();
- assertNotNull("The factory pid 'factory' was not present.", factoryPids); //$NON-NLS-1$
- assertEquals("Not the expected number of factory pids.", 1, factoryPids.length); //$NON-NLS-1$
- assertEquals("Expected factory pid was not present.", "factory", factoryPids[0]); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertNotNull("The factory pid 'factory' was not present.", factoryPids); //$NON-NLS-1$
+ Assert.assertEquals("Not the expected number of factory pids.", 1, factoryPids.length); //$NON-NLS-1$
+ Assert.assertEquals("Expected factory pid was not present.", "factory", factoryPids[0]); //$NON-NLS-1$ //$NON-NLS-2$
}
}

Back to the top