Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-01-29 08:34:55 +0000
committerAlexander Kurtakov2020-01-29 08:36:09 +0000
commitf600a80625b497bb00aeebe40eeb4a776f15823a (patch)
treefd045238c261444aebaeee527a525729fd623f6a
parenta1d5c78901332474c7c1120a1d6fcedd1941d44d (diff)
downloadrt.equinox.bundles-f600a80625b497bb00aeebe40eeb4a776f15823a.tar.gz
rt.equinox.bundles-f600a80625b497bb00aeebe40eeb4a776f15823a.tar.xz
rt.equinox.bundles-f600a80625b497bb00aeebe40eeb4a776f15823a.zip
There is failure in nightly: junit.framework.AssertionFailedError at junit.framework.Assert.fail(Assert.java:55) at junit.framework.Assert.assertTrue(Assert.java:22) at junit.framework.Assert.assertNotNull(Assert.java:256) at junit.framework.Assert.assertNotNull(Assert.java:248) at junit.framework.TestCase.assertNotNull(TestCase.java:417) at org.eclipse.equinox.common.tests.registry.RegistryListenerTest.testRegularOrder(RegistryListenerTest.java:88) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Let's have the tests modernized before looking into potential reason as it seems to be unstable test first. Change-Id: I1ae584c16f7c838ba82f999c501c7464118de5d6 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java19
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryDynamicTest.java19
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryStaticTest.java91
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java35
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/MultiLanguageTest.java23
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java24
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java31
7 files changed, 118 insertions, 124 deletions
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
index 8b80592db..46132e3c4 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
@@ -13,13 +13,17 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.spi.IDynamicExtensionRegistry;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -30,16 +34,9 @@ import org.osgi.framework.FrameworkUtil;
*
* @since 3.3
*/
-public class ContributorsTest extends TestCase {
-
- public ContributorsTest() {
- super();
- }
-
- public ContributorsTest(String name) {
- super(name);
- }
+public class ContributorsTest {
+ @Test
public void testResolution() throws IOException, BundleException {
Bundle bundle = null;
Bundle fragment = null;
@@ -79,6 +76,7 @@ public class ContributorsTest extends TestCase {
* @throws IOException
* @throws BundleException
*/
+ @Test
public void testByContributor() throws IOException, BundleException {
Bundle bundleA = null;
Bundle bundleB = null;
@@ -137,6 +135,7 @@ public class ContributorsTest extends TestCase {
* @throws IOException
* @throws BundleException
*/
+ @Test
public void testContributorRemoval() throws IOException {
Object masterKey = new Object();
IExtensionRegistry registry = RegistryFactory.createRegistry(null, masterKey, null);
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryDynamicTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryDynamicTest.java
index b500bbaf4..6a21e91c8 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryDynamicTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryDynamicTest.java
@@ -13,27 +13,24 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.dynamichelpers.*;
import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.eclipse.core.tests.harness.TestRegistryChangeListener;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
-public class ExtensionRegistryDynamicTest extends TestCase {
-
- public ExtensionRegistryDynamicTest() {
- super();
- }
-
- public ExtensionRegistryDynamicTest(String name) {
- super(name);
- }
+public class ExtensionRegistryDynamicTest {
+ @Test
public void testAddition() throws IOException, BundleException {
Bundle bundle01 = null;
Bundle bundle02 = null;
@@ -64,6 +61,7 @@ public class ExtensionRegistryDynamicTest extends TestCase {
/**
* @see bug 65783
*/
+ @Test
public void testReresolving() throws IOException, BundleException {
Bundle bundle01 = null;
Bundle bundle02 = null;
@@ -95,6 +93,7 @@ public class ExtensionRegistryDynamicTest extends TestCase {
/**
* @see bug 178028
*/
+ @Test
public void testEventTracker() throws IOException, BundleException {
Bundle bundle01 = null;
Bundle bundle02 = null;
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryStaticTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryStaticTest.java
index f6964d8f2..e89fbecbe 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryStaticTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ExtensionRegistryStaticTest.java
@@ -14,31 +14,35 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Arrays;
-import junit.framework.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
-public class ExtensionRegistryStaticTest extends TestCase {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ExtensionRegistryStaticTest {
- private BundleContext fBundleContext;
+ private static BundleContext fBundleContext;
- public ExtensionRegistryStaticTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- fBundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
+ @BeforeClass
+ public static void setUp() throws Exception {
+ fBundleContext = FrameworkUtil.getBundle(ExtensionRegistryStaticTest.class).getBundleContext();
}
+ @Test
public void testA() throws IOException, BundleException {
//test the addition of an extension point
String name = "A";
@@ -46,12 +50,12 @@ public class ExtensionRegistryStaticTest extends TestCase {
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {bundle01});
testExtensionPoint(name);
}
-
+ @Test
public void testAFromCache() {
//Check that it has been persisted
testExtensionPoint("A");
}
-
+
private void testExtensionPoint(String name) {
assertNotNull(RegistryFactory.getRegistry().getExtensionPoint("test" + name + ".xpt" + name));
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("test" + name + ".xpt" + name).getLabel(), "Label xpt" + name);
@@ -60,14 +64,14 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("test" + name + ".xpt" + name).getContributor().getName(), "test" + name);
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("test" + name + ".xpt" + name).getSchemaReference(), "schema/xpt" + name + ".exsd");
}
-
+ @Test
public void testB() throws IOException, BundleException {
//test the addition of an extension without extension point
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testB/1");
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {bundle01});
assertNull(RegistryFactory.getRegistry().getExtension("testB2", "xptB2", "ext1"));
}
-
+ @Test
public void testBFromCache() throws IOException, BundleException {
// Test the addition of an extension point when orphans extension exists
assertNull(RegistryFactory.getRegistry().getExtension("testB2", "xptB2", "ext1"));
@@ -99,7 +103,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(RegistryFactory.getRegistry().getExtensionPoints("testB2").length, 0);
assertNull(RegistryFactory.getRegistry().getExtensionPoint("testB2.xptB2"));
}
-
+ @Test
public void testBRemoved() {
//Test if testB has been removed.
assertNull(RegistryFactory.getRegistry().getExtension("testB1.ext1"));
@@ -107,7 +111,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(RegistryFactory.getRegistry().getExtensionPoints("testB2").length, 0);
assertNull(RegistryFactory.getRegistry().getExtensionPoint("testB2.xptB2"));
}
-
+ @Test
public void testC() throws IOException, BundleException {
//test the addition of an extension point then the addition of an extension
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testC/1");
@@ -131,7 +135,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertNotNull(RegistryFactory.getRegistry().getExtensionPoint("testC1.xptC1").getExtension("testC2.ext1"));
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("testC1.xptC1").getExtensions()[0].getUniqueIdentifier(), "testC2.ext1");
}
-
+ @Test
public void testD() throws IOException, BundleException {
//test the addition of an extension then the addition of an extension point
Bundle bundle02 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testD/2");
@@ -155,7 +159,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertNotNull(RegistryFactory.getRegistry().getExtensionPoint("testD1.xptD1").getExtension("testD2.ext1"));
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("testD1.xptD1").getExtensions()[0].getUniqueIdentifier(), "testD2.ext1");
}
-
+ @Test
public void testE() throws IOException, BundleException {
//test the addition of an extension point and then add the extension through a fragment
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testE/1");
@@ -179,7 +183,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertNotNull(RegistryFactory.getRegistry().getExtensionPoint("testE1.xptE1").getExtension("testE1.ext1"));
assertEquals(RegistryFactory.getRegistry().getExtensionPoint("testE1.xptE1").getExtensions()[0].getUniqueIdentifier(), "testE1.ext1");
}
-
+ @Test
public void testF() throws IOException, BundleException {
//test the addition of the extension through a fragment then the addition of an extension point
Bundle bundle02 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testF/2");
@@ -207,7 +211,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testF1"), true);
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testF2"), false);
}
-
+ @Test
public void testG() throws IOException, BundleException {
//fragment contributing an extension point to a plugin that do not have extension or extension point
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testG/1");
@@ -226,7 +230,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testG1"), true);
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testG2"), false);
}
-
+ @Test
public void testH() throws IOException, BundleException {
// fragment contributing an extension to a plugin that does not have extension or extension point
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testH/1");
@@ -258,8 +262,8 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testH3"), true);
assertEquals(Arrays.asList(RegistryFactory.getRegistry().getNamespaces()).contains("testH2"), false); //fragments do not come with their namespace
}
-
- public void test71826() throws MalformedURLException, BundleException, IOException {
+ @Test
+ public void testH71826() throws MalformedURLException, BundleException, IOException {
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/71826/fragmentF");
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {bundle01});
@@ -276,7 +280,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertNotNull("1.2", xp.getExtension("71826A.F1"));
assertNotNull("1.3", xp.getExtension("71826B.B1"));
}
-
+ @Test
public void testJ() throws MalformedURLException, BundleException, IOException {
//Test the third level configuration elements
Bundle bundle01 = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/testI");
@@ -295,7 +299,7 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(ce.getChildren()[0].getChildren()[0].getChildren()[0].getName(), "ce4");
assertNotNull(ce.getChildren()[0].getChildren()[0].getChildren()[0].getValue());
}
-
+ @Test
public void testJbis() {
//Test the third level configuration elements from cache
IExtension ext = RegistryFactory.getRegistry().getExtension("testI.ext1");
@@ -311,49 +315,26 @@ public class ExtensionRegistryStaticTest extends TestCase {
assertEquals(ce.getChildren()[0].getChildren()[0].getChildren()[0].getName(), "ce4");
assertNotNull(ce.getChildren()[0].getChildren()[0].getChildren()[0].getValue());
}
-
- public void testNonSingletonBundle() throws MalformedURLException, BundleException, IOException {
+ @Test
+ public void testKNonSingletonBundle() throws MalformedURLException, BundleException, IOException {
//Non singleton bundles are not supposed to be added
Bundle nonSingletonBundle = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/nonSingleton");
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {nonSingletonBundle});
assertNull(RegistryFactory.getRegistry().getExtensionPoint("NonSingleton.ExtensionPoint"));
}
-
- public void testSingletonFragment() throws MalformedURLException, BundleException, IOException {
+ @Test
+ public void testLSingletonFragment() throws MalformedURLException, BundleException, IOException {
//Fragments to non singleton host can not contribute extension or extension points
Bundle fragmentToNonSingleton = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/fragmentToNonSingleton");
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {fragmentToNonSingleton});
assertNull(RegistryFactory.getRegistry().getExtensionPoint("NonSingleton.Bar"));
}
-
- public void testNonSingletonFragment() throws MalformedURLException, BundleException, IOException {
+ @Test
+ public void testMNonSingletonFragment() throws MalformedURLException, BundleException, IOException {
//Non singleton bundles are not supposed to be added
Bundle regular = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/nonSingletonFragment/plugin");
Bundle nonSingletonFragment = BundleTestingHelper.installBundle("", fBundleContext, "Plugin_Testing/registry/nonSingletonFragment/fragment");
BundleTestingHelper.refreshPackages(fBundleContext, new Bundle[] {regular, nonSingletonFragment});
assertNull(RegistryFactory.getRegistry().getExtensionPoint("Regular.Bar"));
}
-
- public static Test suite() {
- //Order is important
- TestSuite sameSession = new TestSuite(ExtensionRegistryStaticTest.class.getName());
- sameSession.addTest(new ExtensionRegistryStaticTest("testA"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testAFromCache"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testB"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testBFromCache"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testBRemoved"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testC"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testD"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testE"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testF"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testG"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testH"));
- sameSession.addTest(new ExtensionRegistryStaticTest("test71826"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testJ"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testJbis"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testNonSingletonBundle"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testSingletonFragment"));
- sameSession.addTest(new ExtensionRegistryStaticTest("testNonSingletonFragment"));
- return sameSession;
- }
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
index aa604ec77..89ca84a91 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
@@ -13,18 +13,35 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
-import java.io.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
-import junit.framework.TestCase;
+
import org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.junit.Test;
import org.osgi.framework.FrameworkUtil;
/**
* Test proper clean-up in case registry gets invalid XML contribution.
* @since 3.4
*/
-public class InputErrorTest extends TestCase {
+public class InputErrorTest {
static private final String DATA_LOCATION = "Plugin_Testing/registry/errorHandling/";
@@ -46,14 +63,6 @@ public class InputErrorTest extends TestCase {
}
}
- public InputErrorTest() {
- super();
- }
-
- public InputErrorTest(String name) {
- super(name);
- }
-
private InputStream getStream(String location) {
URL xml = FrameworkUtil.getBundle(getClass()).getEntry(DATA_LOCATION + location);
assertNotNull(xml);
@@ -65,6 +74,7 @@ public class InputErrorTest extends TestCase {
return null;
}
+ @Test
public void testErrorCleanupPoints() {
RegistryStrategyLog strategy = new RegistryStrategyLog(null, null, null); // RegistryFactory.createOSGiStrategy(null, null, null);
IExtensionRegistry localRegistry = RegistryFactory.createRegistry(strategy, null, null);
@@ -97,6 +107,7 @@ public class InputErrorTest extends TestCase {
localRegistry.stop(null);
}
+ @Test
public void testErrorCleanupExtensions() {
RegistryStrategyLog strategy = new RegistryStrategyLog(null, null, null); // RegistryFactory.createOSGiStrategy(null, null, null);
IExtensionRegistry localRegistry = RegistryFactory.createRegistry(strategy, null, null);
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/MultiLanguageTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/MultiLanguageTest.java
index a59e605bf..9725df375 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/MultiLanguageTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/MultiLanguageTest.java
@@ -14,15 +14,21 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.Locale;
-import junit.framework.TestCase;
import org.eclipse.core.internal.registry.IRegistryConstants;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.spi.RegistryStrategy;
import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.eclipse.core.tests.harness.FileSystemHelper;
import org.eclipse.osgi.service.localization.LocaleProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.*;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
@@ -30,7 +36,7 @@ import org.osgi.util.tracker.ServiceTracker;
/**
* Run with no NL argument or with "-nl en".
*/
-public class MultiLanguageTest extends TestCase {
+public class MultiLanguageTest {
class LocaleProviderTest implements LocaleProvider {
public Locale currentLocale;
@@ -69,10 +75,8 @@ public class MultiLanguageTest extends TestCase {
private BundleContext testBundleContext;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
testBundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
bundle = BundleTestingHelper.installBundle("0.1", testBundleContext, "Plugin_Testing/registry/multiLang/bundleA");
bundleFragment = BundleTestingHelper.installBundle("0.2", testBundleContext, "Plugin_Testing/registry/multiLang/fragmentA");
@@ -88,8 +92,8 @@ public class MultiLanguageTest extends TestCase {
System.setProperty(IRegistryConstants.PROP_MULTI_LANGUAGE, "true");
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// delete registry cache
FileSystemHelper.clear(tmpPath.toFile());
@@ -109,7 +113,6 @@ public class MultiLanguageTest extends TestCase {
bundleTracker.close();
bundleTracker = null;
}
- super.tearDown();
}
private void refreshPackages(Bundle[] refresh) {
@@ -143,6 +146,7 @@ public class MultiLanguageTest extends TestCase {
/**
* Tests APIs that take Locale as an argument.
*/
+ @Test
public void testMultiLocale() {
Object masterToken = new Object();
// Create a multi-language extension registry
@@ -167,6 +171,7 @@ public class MultiLanguageTest extends TestCase {
/**
* Tests APIs that use implicit default Locale.
*/
+ @Test
public void testMultiLocaleService() {
Object masterToken = new Object();
// Create a multi-language extension registry
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
index c787fa229..b6477919a 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
@@ -13,21 +13,25 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
-public class NamespaceTest extends TestCase {
-
- public NamespaceTest(String name) {
- super(name);
- }
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class NamespaceTest {
+ @Test
public void testNamespaceBasic() throws IOException, BundleException {
//test the addition of an extension point
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
@@ -74,6 +78,7 @@ public class NamespaceTest extends TestCase {
BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01});
}
+ @Test
public void testNamespaceDynamic() throws BundleException, IOException {
// add another bundle
@@ -106,11 +111,4 @@ public class NamespaceTest extends TestCase {
BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {anotherNamespaceBundle});
}
- public static Test suite() {
- //Order is important
- TestSuite sameSession = new TestSuite(NamespaceTest.class.getName());
- sameSession.addTest(new NamespaceTest("testNamespaceBasic"));
- sameSession.addTest(new NamespaceTest("testNamespaceDynamic"));
- return sameSession;
- }
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
index 95dd5782c..a3253f4fa 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
@@ -13,10 +13,16 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.TestCase;
+
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -26,29 +32,21 @@ import org.osgi.framework.FrameworkUtil;
* Tests "new" registry event listener.
* @since 3.4
*/
-public class RegistryListenerTest extends TestCase {
+public class RegistryListenerTest {
final private static int MAX_TIME_PER_BUNDLE = 10000; // maximum time to wait for bundle event in milliseconds
- private BundleContext fBundleContext;
-
- public RegistryListenerTest() {
- super();
- }
-
- public RegistryListenerTest(String name) {
- super(name);
- }
+ private static BundleContext fBundleContext;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- fBundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
+ @BeforeClass
+ public static void setUp() throws Exception {
+ fBundleContext = FrameworkUtil.getBundle(RegistryListenerTest.class).getBundleContext();
}
/**
* Producer and consumer bundles are installed and removed in a "normal" order
*/
+ @Test
public void testRegularOrder() throws IOException, BundleException {
Bundle bundle01 = null;
Bundle bundle02 = null;
@@ -107,6 +105,7 @@ public class RegistryListenerTest extends TestCase {
/**
* Producer and consumer bundles are installed and removed in an inverse order
*/
+ @Test
public void testInverseOrder() throws IOException, BundleException {
Bundle bundle01 = null;
Bundle bundle02 = null;
@@ -166,6 +165,7 @@ public class RegistryListenerTest extends TestCase {
* Tests modifications to multiple extensions and extension points
* Three listeners are tested: global; on xp1 (two extensions); on xp2 (no extensions)
*/
+ @Test
public void testMultiplePoints() throws IOException, BundleException {
Bundle bundle = null;
WaitingRegistryListener listenerGlobal = new WaitingRegistryListener();
@@ -243,6 +243,7 @@ public class RegistryListenerTest extends TestCase {
/**
* Tests listener registered multiple times: once on xp1, once on xp2
*/
+ @Test
public void testMultipleRegistrations() throws IOException, BundleException {
Bundle bundle = null;
WaitingRegistryListener listener = new WaitingRegistryListener();

Back to the top