Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2016-04-12 10:19:55 +0000
committerSopot Cela2016-04-12 10:24:22 +0000
commit86b15ad88978b78f175a00550bf669073872c116 (patch)
tree18c877f58b3250e53becab0e9afdc87abc474460 /bundles/org.eclipse.equinox.cm.test
parent38938123d4863de34bd96be5a722dcc50422641e (diff)
downloadrt.equinox.bundles-86b15ad88978b78f175a00550bf669073872c116.tar.gz
rt.equinox.bundles-86b15ad88978b78f175a00550bf669073872c116.tar.xz
rt.equinox.bundles-86b15ad88978b78f175a00550bf669073872c116.zip
Bug 490273 - Move tests to JUnit 4
Fix to remove various warnings introduced by the BREE bump. Change-Id: I262219776f709fd712d7783cc15881edd71e81ff 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/src/org/eclipse/equinox/cm/test/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationAdminTest.java6
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java56
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationEventAdapterTest.java15
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationListenerTest.java8
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationPluginTest.java88
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceFactoryTest.java29
-rw-r--r--bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ManagedServiceTest.java39
8 files changed, 124 insertions, 123 deletions
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
index 124ceff0c..fdf9e02fb 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
@@ -17,11 +17,11 @@ public class Activator implements BundleActivator {
private static PackageAdmin packageAdmin;
private static BundleContext bundleContext;
- private ServiceReference packageAdminRef;
+ private ServiceReference<PackageAdmin> packageAdminRef;
public void start(BundleContext context) throws Exception {
- packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
- setPackageAdmin((PackageAdmin) context.getService(packageAdminRef));
+ packageAdminRef = context.getServiceReference(PackageAdmin.class);
+ setPackageAdmin(context.getService(packageAdminRef));
setBundleContext(context);
}
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 625b49e59..d1b15de7a 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
@@ -23,13 +23,13 @@ import org.osgi.service.cm.ConfigurationAdmin;
public class ConfigurationAdminTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@After
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 05a6b7cd7..592fd146d 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
@@ -24,13 +24,13 @@ import org.osgi.service.cm.ConfigurationAdmin;
public class ConfigurationDictionaryTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@After
@@ -43,7 +43,7 @@ public class ConfigurationDictionaryTest {
public void testGoodConfigProperties() throws Exception {
Configuration config = cm.getConfiguration("test");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.put("1", new String("x"));
dict.put("2", new Integer(1));
@@ -71,8 +71,8 @@ public class ConfigurationDictionaryTest {
dict.put("24", new short[] {1});
dict.put("25", new char[] {'a'});
dict.put("26", new boolean[] {true});
- dict.put("27", new Vector());
- Vector v = new Vector();
+ dict.put("27", new Vector<Object>());
+ Vector<Object> v = new Vector<Object>();
v.add(new String("x"));
v.add(new Integer(1));
v.add(new Long(1));
@@ -83,7 +83,7 @@ public class ConfigurationDictionaryTest {
v.add(new Character('a'));
v.add(Boolean.TRUE);
dict.put("28", v);
- Collection c = new ArrayList();
+ Collection<Object> c = new ArrayList<Object>();
c.add(new String("x"));
c.add(new Integer(1));
c.add(new Long(1));
@@ -99,16 +99,16 @@ public class ConfigurationDictionaryTest {
}
config.update(dict);
- Dictionary dict2 = config.getProperties();
+ Dictionary<String, Object> dict2 = config.getProperties();
assertTrue(dict.size() == dict2.size());
- Enumeration keys = dict.keys();
+ Enumeration<String> keys = dict.keys();
while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
+ String key = keys.nextElement();
Object value1 = dict.get(key);
- Class class1 = value1.getClass();
+ Class<?> class1 = value1.getClass();
Object value2 = dict2.get(key);
- Class class2 = value2.getClass();
+ Class<?> class2 = value2.getClass();
if (value1.getClass().isArray()) {
assertTrue(class1 == class2);
assertTrue(class1.getComponentType() == class2.getComponentType());
@@ -118,8 +118,8 @@ public class ConfigurationDictionaryTest {
if (value1 instanceof Object[])
assertTrue(Arrays.asList((Object[]) value1).containsAll(Arrays.asList((Object[]) value2)));
} else if (value1 instanceof Collection) {
- Collection c1 = (Collection) value1;
- Collection c2 = (Collection) value2;
+ Collection<?> c1 = (Collection<?>) value1;
+ Collection<?> c2 = (Collection<?>) value2;
assertTrue(c1.size() == c2.size());
assertTrue(c1.containsAll(c2));
} else
@@ -132,7 +132,7 @@ public class ConfigurationDictionaryTest {
public void testNullKey() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.put(null, "x");
} catch (NullPointerException e) {
@@ -147,7 +147,7 @@ public class ConfigurationDictionaryTest {
public void testNullValue() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.put("x", null);
} catch (NullPointerException e) {
@@ -162,7 +162,7 @@ public class ConfigurationDictionaryTest {
public void testObjectValue() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.put("x", new Object());
} catch (IllegalArgumentException e) {
@@ -177,7 +177,7 @@ public class ConfigurationDictionaryTest {
public void testObjectArray() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.put("x", new Object[] {new Object()});
} catch (IllegalArgumentException e) {
@@ -192,9 +192,9 @@ public class ConfigurationDictionaryTest {
public void testObjectVector() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
- Vector v = new Vector();
+ Vector<Object> v = new Vector<Object>();
v.add(new Object());
dict.put("x", v);
} catch (IllegalArgumentException e) {
@@ -209,9 +209,9 @@ public class ConfigurationDictionaryTest {
public void testObjectCollection() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
- Collection c = new ArrayList();
+ Collection<Object> c = new ArrayList<Object>();
c.add(new Object());
dict.put("x", c);
} catch (IllegalArgumentException e) {
@@ -226,9 +226,9 @@ public class ConfigurationDictionaryTest {
public void testPutGetCustomCollection() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
- Collection c = new ArrayList() {
+ Collection<Object> c = new ArrayList<Object>() {
private static final long serialVersionUID = 1L;
};
dict.put("x", c);
@@ -244,7 +244,7 @@ public class ConfigurationDictionaryTest {
public void testGet() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
assertTrue(null != dict.get(Constants.SERVICE_PID));
} finally {
@@ -256,7 +256,7 @@ public class ConfigurationDictionaryTest {
public void testGetNull() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.get(null);
} catch (NullPointerException e) {
@@ -271,7 +271,7 @@ public class ConfigurationDictionaryTest {
public void testRemove() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
assertFalse(dict.isEmpty());
assertTrue(null != dict.remove(Constants.SERVICE_PID));
@@ -285,7 +285,7 @@ public class ConfigurationDictionaryTest {
public void testRemoveNull() throws Exception {
Configuration config = cm.getConfiguration("test2");
config.update();
- Dictionary dict = config.getProperties();
+ Dictionary<String, Object> dict = config.getProperties();
try {
dict.remove(null);
} catch (NullPointerException e) {
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 43f9a9226..6246e467c 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
@@ -24,7 +24,7 @@ import org.osgi.service.event.*;
public class ConfigurationEventAdapterTest {
private ConfigurationAdmin cm;
- private ServiceReference cmReference;
+ private ServiceReference<ConfigurationAdmin> cmReference;
boolean locked = false;
Object lock = new Object();
@@ -33,8 +33,8 @@ public class ConfigurationEventAdapterTest {
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);
+ cmReference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(cmReference);
}
@After
@@ -62,10 +62,10 @@ public class ConfigurationEventAdapterTest {
};
String[] topics = new String[] {"org/osgi/service/cm/ConfigurationEvent/*"};
- Dictionary handlerProps = new Hashtable();
+ Dictionary<String, Object> handlerProps = new Hashtable<String, Object>();
handlerProps.put(EventConstants.EVENT_TOPIC, topics);
- ServiceRegistration reg = Activator.getBundleContext().registerService(EventHandler.class.getName(), handler, handlerProps);
+ ServiceRegistration<EventHandler> reg = Activator.getBundleContext().registerService(EventHandler.class, handler, handlerProps);
synchronized (lock) {
config.update(props);
@@ -102,10 +102,9 @@ public class ConfigurationEventAdapterTest {
};
String[] topics = new String[] {"org/osgi/service/cm/ConfigurationEvent/*"};
- Dictionary handlerProps = new Hashtable();
-
+ Dictionary<String, Object> handlerProps = new Hashtable<String, Object>();
handlerProps.put(EventConstants.EVENT_TOPIC, topics);
- ServiceRegistration reg = Activator.getBundleContext().registerService(EventHandler.class.getName(), handler, handlerProps);
+ ServiceRegistration<EventHandler> reg = Activator.getBundleContext().registerService(EventHandler.class, handler, handlerProps);
synchronized (lock) {
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 06ff57f39..e263db5a5 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
@@ -22,15 +22,15 @@ import org.osgi.service.cm.*;
public class ConfigurationListenerTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
boolean locked = false;
Object lock = new Object();
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@After
@@ -55,7 +55,7 @@ public class ConfigurationListenerTest {
}
}
};
- ServiceRegistration reg = Activator.getBundleContext().registerService(ConfigurationListener.class.getName(), listener, null);
+ ServiceRegistration<ConfigurationListener> reg = Activator.getBundleContext().registerService(ConfigurationListener.class, listener, null);
synchronized (lock) {
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 008c0d97b..4b5e84f7b 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
@@ -20,7 +20,7 @@ import org.osgi.service.cm.*;
public class ConfigurationPluginTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
boolean locked = false;
Object lock = new Object();
boolean success;
@@ -28,8 +28,8 @@ public class ConfigurationPluginTest {
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@After
@@ -48,14 +48,14 @@ public class ConfigurationPluginTest {
ConfigurationPlugin plugin = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
properties.put("plugin", "plugin1");
}
};
- ServiceRegistration pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin, null);
+ ServiceRegistration<ConfigurationPlugin> pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin, null);
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -64,12 +64,12 @@ public class ConfigurationPluginTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
success = false;
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -92,16 +92,16 @@ public class ConfigurationPluginTest {
ConfigurationPlugin plugin = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
properties.put("plugin", "plugin1");
}
};
- Dictionary pluginDict = new Properties();
+ Dictionary<String, Object> pluginDict = new Hashtable<String, Object>();
pluginDict.put(ConfigurationPlugin.CM_TARGET, new String[] {"test"});
- ServiceRegistration pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin, pluginDict);
+ ServiceRegistration<ConfigurationPlugin> pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin, pluginDict);
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -110,12 +110,12 @@ public class ConfigurationPluginTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
success = false;
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -138,16 +138,16 @@ public class ConfigurationPluginTest {
ConfigurationPlugin plugin = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
properties.put("plugin", "plugin1");
}
};
- Dictionary pluginDict = new Properties();
+ Dictionary<String, Object> pluginDict = new Hashtable<String, Object>();
pluginDict.put(ConfigurationPlugin.CM_TARGET, new String[] {"testXXX"});
- ServiceRegistration pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin, pluginDict);
+ ServiceRegistration<ConfigurationPlugin> pluginReg = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin, pluginDict);
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -156,12 +156,12 @@ public class ConfigurationPluginTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
success = false;
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
assertFalse(success);
@@ -182,25 +182,25 @@ public class ConfigurationPluginTest {
ConfigurationPlugin plugin = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
properties.put("plugin", "plugin1");
}
};
- Dictionary pluginDict = new Properties();
+ Dictionary<String, Object> pluginDict = new Hashtable<String, Object>();
pluginDict.put(ConfigurationPlugin.CM_RANKING, new Integer(1));
- ServiceRegistration pluginReg1 = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin, pluginDict);
+ ServiceRegistration<ConfigurationPlugin> pluginReg1 = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin, pluginDict);
ConfigurationPlugin plugin2 = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
properties.put("plugin", "plugin2");
}
};
- ServiceRegistration pluginReg2 = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin2, null);
+ ServiceRegistration<ConfigurationPlugin> pluginReg2 = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin2, null);
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -209,12 +209,12 @@ public class ConfigurationPluginTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
success = false;
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -235,37 +235,37 @@ public class ConfigurationPluginTest {
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("testkey", "testvalue");
config.update(props);
- final List pluginsCalled = new ArrayList();
+ final List<String> pluginsCalled = new ArrayList<String>();
- Hashtable pluginProps = new Hashtable();
+ Hashtable<String, Object> pluginProps = new Hashtable<String, Object>();
pluginProps.put(Constants.SERVICE_RANKING, new Integer(1));
ConfigurationPlugin plugin1 = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
pluginsCalled.add("plugin1");
}
};
- ServiceRegistration pluginReg1 = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin1, pluginProps);
+ ServiceRegistration<ConfigurationPlugin> pluginReg1 = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin1, pluginProps);
ConfigurationPlugin plugin2 = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
pluginsCalled.add("plugin2");
}
};
pluginProps.put(Constants.SERVICE_RANKING, new Integer(2));
- ServiceRegistration pluginReg2 = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin2, pluginProps);
+ ServiceRegistration<ConfigurationPlugin> pluginReg2 = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin2, pluginProps);
ConfigurationPlugin plugin3 = new ConfigurationPlugin() {
- public void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> serviceReference, Dictionary<String, Object> properties) {
pluginsCalled.add("plugin3");
}
};
pluginProps.put(Constants.SERVICE_RANKING, new Integer(1));
- ServiceRegistration pluginReg3 = Activator.getBundleContext().registerService(ConfigurationPlugin.class.getName(), plugin3, pluginProps);
+ ServiceRegistration<ConfigurationPlugin> pluginReg3 = Activator.getBundleContext().registerService(ConfigurationPlugin.class, plugin3, pluginProps);
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -273,11 +273,11 @@ public class ConfigurationPluginTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
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 a93fd0910..3428d7d69 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
@@ -12,7 +12,8 @@ package org.eclipse.equinox.cm.test;
import static org.junit.Assert.*;
-import java.util.*;
+import java.util.Dictionary;
+import java.util.Hashtable;
import org.junit.*;
import org.osgi.framework.*;
import org.osgi.service.cm.*;
@@ -20,7 +21,7 @@ import org.osgi.service.cm.*;
public class ManagedServiceFactoryTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
int updateCount = 0;
boolean locked = false;
Object lock = new Object();
@@ -28,8 +29,8 @@ public class ManagedServiceFactoryTest {
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@@ -62,7 +63,7 @@ public class ManagedServiceFactoryTest {
return null;
}
- public void updated(String pid, Dictionary properties) throws ConfigurationException {
+ public void updated(String pid, Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -71,11 +72,11 @@ public class ManagedServiceFactoryTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedServiceFactory> reg = null;
synchronized (lock) {
- reg = Activator.getBundleContext().registerService(ManagedServiceFactory.class.getName(), msf, dict);
+ reg = Activator.getBundleContext().registerService(ManagedServiceFactory.class, msf, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -83,9 +84,9 @@ public class ManagedServiceFactoryTest {
assertEquals(1, updateCount);
}
- ServiceRegistration reg2 = null;
+ ServiceRegistration<ManagedServiceFactory> reg2 = null;
synchronized (lock) {
- reg2 = Activator.getBundleContext().registerService(ManagedServiceFactory.class.getName(), msf, dict);
+ reg2 = Activator.getBundleContext().registerService(ManagedServiceFactory.class, msf, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -114,7 +115,7 @@ public class ManagedServiceFactoryTest {
return null;
}
- public void updated(String pid, Dictionary properties) throws ConfigurationException {
+ public void updated(String pid, Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -123,12 +124,12 @@ public class ManagedServiceFactoryTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedServiceFactory> reg = null;
synchronized (lock) {
- reg = Activator.getBundleContext().registerService(ManagedServiceFactory.class.getName(), msf, dict);
+ reg = Activator.getBundleContext().registerService(ManagedServiceFactory.class, msf, dict);
locked = true;
lock.wait(100);
assertTrue(locked);
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 811c5fedf..17f08cbf7 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
@@ -12,7 +12,8 @@ package org.eclipse.equinox.cm.test;
import static org.junit.Assert.*;
-import java.util.*;
+import java.util.Dictionary;
+import java.util.Hashtable;
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.equinox.log.LogFilter;
import org.junit.*;
@@ -23,7 +24,7 @@ import org.osgi.service.log.*;
public class ManagedServiceTest {
private ConfigurationAdmin cm;
- private ServiceReference reference;
+ private ServiceReference<ConfigurationAdmin> reference;
int updateCount = 0;
boolean locked = false;
Object lock = new Object();
@@ -31,8 +32,8 @@ public class ManagedServiceTest {
@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);
+ reference = Activator.getBundleContext().getServiceReference(ConfigurationAdmin.class);
+ cm = Activator.getBundleContext().getService(reference);
}
@After
@@ -52,7 +53,7 @@ public class ManagedServiceTest {
updateCount = 0;
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -62,11 +63,11 @@ public class ManagedServiceTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -74,9 +75,9 @@ public class ManagedServiceTest {
assertEquals(1, updateCount);
}
- ServiceRegistration reg2 = null;
+ ServiceRegistration<ManagedService> reg2 = null;
synchronized (lock) {
- reg2 = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg2 = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)
@@ -93,12 +94,12 @@ public class ManagedServiceTest {
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
// nothing
}
};
- ExtendedLogReaderService reader = (ExtendedLogReaderService) Activator.getBundleContext().getService(Activator.getBundleContext().getServiceReference(ExtendedLogReaderService.class));
+ ExtendedLogReaderService reader = Activator.getBundleContext().getService(Activator.getBundleContext().getServiceReference(ExtendedLogReaderService.class));
synchronized (lock) {
locked = false;
}
@@ -115,10 +116,10 @@ public class ManagedServiceTest {
return logLevel == LogService.LOG_ERROR;
}
});
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg1 = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
- ServiceRegistration reg2 = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ ServiceRegistration<ManagedService> reg1 = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
+ ServiceRegistration<ManagedService> reg2 = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
reg1.unregister();
reg2.unregister();
@@ -135,7 +136,7 @@ public class ManagedServiceTest {
updateCount = 0;
ManagedService ms = new ManagedService() {
- public void updated(Dictionary properties) throws ConfigurationException {
+ public void updated(Dictionary<String, ?> properties) {
synchronized (lock) {
locked = false;
lock.notify();
@@ -145,12 +146,12 @@ public class ManagedServiceTest {
}
};
- Dictionary dict = new Properties();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_PID, "test");
- ServiceRegistration reg = null;
+ ServiceRegistration<ManagedService> reg = null;
synchronized (lock) {
- reg = Activator.getBundleContext().registerService(ManagedService.class.getName(), ms, dict);
+ reg = Activator.getBundleContext().registerService(ManagedService.class, ms, dict);
locked = true;
lock.wait(5000);
if (locked)

Back to the top