Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2016-04-11 11:57:10 +0000
committerSopot Cela2016-04-11 11:57:10 +0000
commit20de7888ff28d7a8a1606794a0603a5f37aa1b53 (patch)
tree61b02da3aa4c751aa9941c539a754a377078d316 /bundles/org.eclipse.equinox.cm.test
parent4cfd78983d5e2e91d69f8f0edfbe100f2392475e (diff)
downloadrt.equinox.bundles-20de7888ff28d7a8a1606794a0603a5f37aa1b53.tar.gz
rt.equinox.bundles-20de7888ff28d7a8a1606794a0603a5f37aa1b53.tar.xz
rt.equinox.bundles-20de7888ff28d7a8a1606794a0603a5f37aa1b53.zip
Bug 490273 - Move tests to JUnit 4
Port of o.e.e.cm.test project. Includes some Dictionary changes required for the java 1.5 compliance level bump (which is required for annotations). Also cleaned up the pom of a hack to override the BREE. Change-Id: I63370d9520874474a0c990861425cfd6b806e251 Signed-off-by: Sopot Cela <scela@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.cm.test')
-rw-r--r--bundles/org.eclipse.equinox.cm.test/.classpath2
-rw-r--r--bundles/org.eclipse.equinox.cm.test/.settings/org.eclipse.jdt.core.prefs20
-rw-r--r--bundles/org.eclipse.equinox.cm.test/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.equinox.cm.test/pom.xml22
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/AllTests.java21
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java42
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java28
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java25
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java22
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java31
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java25
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java26
12 files changed, 147 insertions, 124 deletions
diff --git a/bundles/org.eclipse.equinox.cm.test/.classpath b/bundles/org.eclipse.equinox.cm.test/.classpath
index 751c8f2e..304e8618 100644
--- a/bundles/org.eclipse.equinox.cm.test/.classpath
+++ b/bundles/org.eclipse.equinox.cm.test/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.equinox.cm.test/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.cm.test/.settings/org.eclipse.jdt.core.prefs
index f31f2500..0a67bc6f 100644
--- a/bundles/org.eclipse.equinox.cm.test/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.cm.test/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,3 @@
-#Tue Aug 21 11:27:47 CDT 2007
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -7,24 +6,24 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
@@ -72,7 +71,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=en
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
@@ -144,7 +143,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
diff --git a/bundles/org.eclipse.equinox.cm.test/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.cm.test/META-INF/MANIFEST.MF
index 93f0f5c0..b0dfe2bd 100644
--- a/bundles/org.eclipse.equinox.cm.test/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.cm.test/META-INF/MANIFEST.MF
@@ -4,11 +4,14 @@ Bundle-Name: Test Plug-in
Bundle-SymbolicName: org.eclipse.equinox.cm.test
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.equinox.cm.test.Activator
-Import-Package: junit.framework;version="3.8.1",
- org.eclipse.equinox.log,
+Import-Package: org.eclipse.equinox.log,
+ org.junit;version="4.12.0",
+ org.junit.runner;version="4.12.0",
+ org.junit.runners;version="4.12.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.cm;version="1.2.0",
org.osgi.service.event;version="1.1.0",
org.osgi.service.log;version="1.3.0",
org.osgi.service.packageadmin;version="1.2.0"
Eclipse-LazyStart: true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/bundles/org.eclipse.equinox.cm.test/pom.xml b/bundles/org.eclipse.equinox.cm.test/pom.xml
index c957c695..91b9bda3 100644
--- a/bundles/org.eclipse.equinox.cm.test/pom.xml
+++ b/bundles/org.eclipse.equinox.cm.test/pom.xml
@@ -20,25 +20,5 @@
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.cm.test</artifactId>
<version>1.0.0</version>
- <packaging>eclipse-plugin</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.tycho</groupId>
- <artifactId>target-platform-configuration</artifactId>
- <configuration>
- <!--
- Default BREE J2SE-1.5+ results in compile errors similar to
-
- 1. ERROR in /private/var/tmp/lts/R4_platform-aggregator/rt.equinox.bundles/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java (at line 47)
- config.update(props);
- ^^^^^^
-The method update(Dictionary<String,?>) in the type Configuration is not applicable for the arguments (Properties)
- -->
- <executionEnvironment>J2SE-1.4</executionEnvironment>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/AllTests.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/AllTests.java
index 958b8a6d..763bcb4d 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/AllTests.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/AllTests.java
@@ -10,21 +10,12 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+@RunWith(Suite.class)
+@SuiteClasses({ConfigurationAdminTest.class, ManagedServiceFactoryTest.class, ManagedServiceTest.class, ConfigurationDictionaryTest.class, ConfigurationPluginTest.class, ConfigurationListenerTest.class, ConfigurationEventAdapterTest.class})
public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.eclipse.equinox.cm.test");
- suite.addTestSuite(ConfigurationAdminTest.class);
- suite.addTestSuite(ManagedServiceFactoryTest.class);
- suite.addTestSuite(ManagedServiceTest.class);
- suite.addTestSuite(ConfigurationDictionaryTest.class);
- suite.addTestSuite(ConfigurationPluginTest.class);
- suite.addTestSuite(ConfigurationListenerTest.class);
- suite.addTestSuite(ConfigurationEventAdapterTest.class);
- return suite;
- }
-
+ // see @SuitClasses
}
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java
index 1c06c9cc..625b49e5 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java
@@ -10,38 +10,41 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import java.util.Properties;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.junit.*;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-public class ConfigurationAdminTest extends TestCase {
+public class ConfigurationAdminTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
- public ConfigurationAdminTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testCreateConfig() throws Exception {
Configuration config = cm.getConfiguration("test");
assertEquals("test", config.getPid());
}
+ @Test
public void testCreateConfigNullPid() throws Exception {
try {
cm.getConfiguration(null);
@@ -51,11 +54,13 @@ public class ConfigurationAdminTest extends TestCase {
fail();
}
+ @Test
public void testCreateConfigWithLocation() throws Exception {
Configuration config = cm.getConfiguration("test", null);
assertEquals("test", config.getPid());
}
+ @Test
public void testCreateConfigNullPidWithLocation() throws Exception {
try {
cm.getConfiguration(null, null);
@@ -65,6 +70,7 @@ public class ConfigurationAdminTest extends TestCase {
fail();
}
+ @Test
public void testCreateConfigWithAndWithoutLocation() throws Exception {
Configuration config = cm.getConfiguration("test", "x");
config.update();
@@ -76,6 +82,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testCreateConfigWithAndWithoutNullLocation() throws Exception {
Configuration config = cm.getConfiguration("test", null);
config.update();
@@ -89,11 +96,13 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testCreateFactoryConfig() throws Exception {
Configuration config = cm.createFactoryConfiguration("test");
assertEquals("test", config.getFactoryPid());
}
+ @Test
public void testCreateFactoryConfigNullPid() throws Exception {
try {
cm.createFactoryConfiguration(null);
@@ -103,11 +112,13 @@ public class ConfigurationAdminTest extends TestCase {
fail();
}
+ @Test
public void testCreateFactoryConfigWithLocation() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", null);
assertEquals("test", config.getFactoryPid());
}
+ @Test
public void testCreateFactoryConfigNullPidWithLocation() throws Exception {
try {
cm.createFactoryConfiguration(null, null);
@@ -117,6 +128,7 @@ public class ConfigurationAdminTest extends TestCase {
fail();
}
+ @Test
public void testCreateFactoryConfigWithAndWithoutLocation() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", "x");
config.update();
@@ -128,6 +140,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testCreateFactoryConfigWithAndWithoutNullLocation() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", null);
config.update();
@@ -141,6 +154,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testListConfiguration() throws Exception {
Configuration config = cm.getConfiguration("test", null);
config.update();
@@ -152,6 +166,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testListConfigurationWithBoundLocation() throws Exception {
Configuration config = cm.getConfiguration("test", null);
config.update();
@@ -168,6 +183,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testListFactoryConfiguration() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", null);
config.update();
@@ -179,6 +195,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testListFactoryConfigurationWithBoundLocation() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", null);
config.update();
@@ -195,6 +212,7 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testListConfigurationNull() throws Exception {
Configuration config = cm.createFactoryConfiguration("test", null);
config.update();
@@ -206,10 +224,11 @@ public class ConfigurationAdminTest extends TestCase {
}
}
+ @Test
public void testPersistentConfig() throws Exception {
Configuration config = cm.getConfiguration("test");
assertNull(config.getProperties());
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
assertTrue(config.getPid().equals("test"));
@@ -225,10 +244,11 @@ public class ConfigurationAdminTest extends TestCase {
assertNull(config.getProperties());
}
+ @Test
public void testPersistentFactoryConfig() throws Exception {
Configuration config = cm.createFactoryConfiguration("test");
assertNull(config.getProperties());
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
assertTrue(config.getFactoryPid().equals("test"));
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java
index f4bdbb44..05a6b7cd 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java
@@ -10,35 +10,36 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
-import junit.framework.TestCase;
+import org.junit.*;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-public class ConfigurationDictionaryTest extends TestCase {
+public class ConfigurationDictionaryTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
- public ConfigurationDictionaryTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testGoodConfigProperties() throws Exception {
Configuration config = cm.getConfiguration("test");
config.update();
@@ -127,6 +128,7 @@ public class ConfigurationDictionaryTest extends TestCase {
config.delete();
}
+ @Test
public void testNullKey() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -141,6 +143,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testNullValue() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -155,6 +158,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testObjectValue() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -169,6 +173,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testObjectArray() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -183,6 +188,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testObjectVector() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -199,6 +205,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testObjectCollection() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -215,6 +222,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testPutGetCustomCollection() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -232,6 +240,7 @@ public class ConfigurationDictionaryTest extends TestCase {
}
}
+ @Test
public void testGet() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -243,6 +252,7 @@ public class ConfigurationDictionaryTest extends TestCase {
}
}
+ @Test
public void testGetNull() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -257,6 +267,7 @@ public class ConfigurationDictionaryTest extends TestCase {
fail();
}
+ @Test
public void testRemove() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
@@ -270,6 +281,7 @@ public class ConfigurationDictionaryTest extends TestCase {
}
}
+ @Test
public void testRemoveNull() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java
index d4d6e9cf..43f9a922 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java
@@ -10,15 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import java.util.*;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.junit.*;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.event.*;
-public class ConfigurationEventAdapterTest extends TestCase {
+public class ConfigurationEventAdapterTest {
private ConfigurationAdmin cm;
private ServiceReference cmReference;
@@ -26,27 +29,26 @@ public class ConfigurationEventAdapterTest extends TestCase {
boolean locked = false;
Object lock = new Object();
- public ConfigurationEventAdapterTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.event").start();
Activator.getBundle("org.eclipse.equinox.cm").start();
cmReference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(cmReference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(cmReference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
Activator.getBundle("org.eclipse.equinox.event").stop();
}
+ @Test
public void testConfigurationEvent() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -82,10 +84,11 @@ public class ConfigurationEventAdapterTest extends TestCase {
reg.unregister();
}
+ @Test
public void testConfigurationFactoryEvent() throws Exception {
Configuration config = cm.createFactoryConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java
index d4de3a7a..06ff57f3 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java
@@ -10,38 +10,40 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import java.util.Properties;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.junit.*;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.*;
-public class ConfigurationListenerTest extends TestCase {
+public class ConfigurationListenerTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
boolean locked = false;
Object lock = new Object();
- public ConfigurationListenerTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testListener() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java
index 988e91de..008c0d97 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
+import static org.junit.Assert.*;
+
import java.util.*;
-import junit.framework.TestCase;
+import org.junit.*;
import org.osgi.framework.*;
import org.osgi.service.cm.*;
-public class ConfigurationPluginTest extends TestCase {
+public class ConfigurationPluginTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
@@ -23,25 +25,24 @@ public class ConfigurationPluginTest extends TestCase {
Object lock = new Object();
boolean success;
- public ConfigurationPluginTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testPlugin() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -81,10 +82,11 @@ public class ConfigurationPluginTest extends TestCase {
config.delete();
}
+ @Test
public void testPidSpecificPlugin() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -126,10 +128,11 @@ public class ConfigurationPluginTest extends TestCase {
config.delete();
}
+ @Test
public void testPidSpecificMissPlugin() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -169,10 +172,11 @@ public class ConfigurationPluginTest extends TestCase {
config.delete();
}
+ @Test
public void testRankedPlugin() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -224,10 +228,11 @@ public class ConfigurationPluginTest extends TestCase {
config.delete();
}
+ @Test
public void testSameRankedPlugin() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
final List pluginsCalled = new ArrayList();
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java
index ef6cd928..a93fd091 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java
@@ -10,13 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import java.util.Dictionary;
-import java.util.Properties;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.util.*;
+import org.junit.*;
import org.osgi.framework.*;
import org.osgi.service.cm.*;
-public class ManagedServiceFactoryTest extends TestCase {
+public class ManagedServiceFactoryTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
@@ -24,26 +25,25 @@ public class ManagedServiceFactoryTest extends TestCase {
boolean locked = false;
Object lock = new Object();
- public ManagedServiceFactoryTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testSamePidManagedServiceFactory() throws Exception {
Configuration config = cm.createFactoryConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -97,6 +97,7 @@ public class ManagedServiceFactoryTest extends TestCase {
config.delete();
}
+ @Test
public void testGeneralManagedServiceFactory() throws Exception {
updateCount = 0;
ManagedServiceFactory msf = new ManagedServiceFactory() {
@@ -137,7 +138,7 @@ public class ManagedServiceFactoryTest extends TestCase {
Configuration config = cm.createFactoryConfiguration("test");
assertNull(config.getProperties());
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
synchronized (lock) {
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java
index 29e7a6e5..811c5fed 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java
@@ -10,16 +10,17 @@
*******************************************************************************/
package org.eclipse.equinox.cm.test;
-import java.util.Dictionary;
-import java.util.Properties;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.util.*;
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.equinox.log.LogFilter;
+import org.junit.*;
import org.osgi.framework.*;
import org.osgi.service.cm.*;
import org.osgi.service.log.*;
-public class ManagedServiceTest extends TestCase {
+public class ManagedServiceTest {
private ConfigurationAdmin cm;
private ServiceReference reference;
@@ -27,25 +28,24 @@ public class ManagedServiceTest extends TestCase {
boolean locked = false;
Object lock = new Object();
- public ManagedServiceTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Activator.getBundle("org.eclipse.equinox.cm").start();
reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
cm = (ConfigurationAdmin) Activator.getBundleContext().getService(reference);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Activator.getBundleContext().ungetService(reference);
Activator.getBundle("org.eclipse.equinox.cm").stop();
}
+ @Test
public void testSamePidManagedService() throws Exception {
Configuration config = cm.getConfiguration("test");
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
@@ -88,6 +88,7 @@ public class ManagedServiceTest extends TestCase {
config.delete();
}
+ @Test
public void testBug374637() throws Exception {
ManagedService ms = new ManagedService() {
@@ -129,6 +130,7 @@ public class ManagedServiceTest extends TestCase {
}
}
+ @Test
public void testGeneralManagedService() throws Exception {
updateCount = 0;
ManagedService ms = new ManagedService() {
@@ -158,7 +160,7 @@ public class ManagedServiceTest extends TestCase {
Configuration config = cm.getConfiguration("test");
assertNull(config.getProperties());
- Properties props = new Properties();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
synchronized (lock) {

Back to the top