Reworks test stubs to work more nicely with generics
diff --git a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/FindEntriesDelegate.java b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/FindEntriesDelegate.java
index 6fdfcd9..3e36053 100644
--- a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/FindEntriesDelegate.java
+++ b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/FindEntriesDelegate.java
@@ -11,6 +11,7 @@
 
 package org.eclipse.virgo.test.stubs.framework;
 
+import java.net.URL;
 import java.util.Enumeration;
 
 import org.osgi.framework.Bundle;
@@ -34,5 +35,5 @@
      * @return An enumeration of the files found
      * @see Bundle#findEntries(String, String, boolean)
      */
-    Enumeration findEntries(String path, String filePattern, boolean recurse);
+    Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);
 }
diff --git a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundle.java b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundle.java
index fe7b195..e677321 100644
--- a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundle.java
+++ b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundle.java
@@ -167,7 +167,6 @@
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
     public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
         synchronized (this.findEntriesMonitor) {
             if (this.findEntriesDelegate != null) {
diff --git a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
index e787494..237e0c9 100644
--- a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
+++ b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
@@ -384,10 +384,9 @@
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
     public ServiceRegistration<?> registerService(String[] clazzes, Object service, Dictionary<String, ?> properties) {
-        StubServiceRegistration serviceRegistration = createServiceRegistration(clazzes, properties);
-        StubServiceReference serviceReference = createServiceReference(clazzes, service, serviceRegistration);
+        StubServiceRegistration<Object> serviceRegistration = createServiceRegistration(clazzes, properties);
+        StubServiceReference<Object> serviceReference = createServiceReference(clazzes, service, serviceRegistration);
 
         synchronized (this.servicesMonitor) {
             this.serviceRegistrations.add(serviceRegistration);
@@ -437,7 +436,7 @@
     public StubBundleContext removeRegisteredService(ServiceRegistration<?>... serviceRegistrations) {
         synchronized (this.servicesMonitor) {
             this.serviceRegistrations.removeAll(Arrays.asList(serviceRegistrations));
-            for (ServiceRegistration registration: serviceRegistrations) {
+            for (ServiceRegistration<?> registration: serviceRegistrations) {
                 this.services.remove(registration.getReference());
             }
             return this;
diff --git a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubServiceReference.java b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubServiceReference.java
index 479c585..6fc1887 100644
--- a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubServiceReference.java
+++ b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubServiceReference.java
@@ -176,7 +176,7 @@
      */
     public String[] getPropertyKeys() {
         List<String> properties = new ArrayList<String>();
-        Enumeration keys = this.serviceRegistration.getProperties().keys();
+        Enumeration<String> keys = this.serviceRegistration.getProperties().keys();
         while (keys.hasMoreElements()) {
             properties.add((String) keys.nextElement());
         }
diff --git a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/service/cm/StubConfiguration.java b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/service/cm/StubConfiguration.java
index 2772ef0..18c00fb 100644
--- a/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/service/cm/StubConfiguration.java
+++ b/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/service/cm/StubConfiguration.java
@@ -42,7 +42,7 @@
 
     private volatile boolean deleted = false;
 
-    private volatile Dictionary properties;
+    private volatile Dictionary<String, Object> properties;
 
     private final Object propertiesMonitor = new Object();
 
@@ -113,8 +113,7 @@
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
-    public Dictionary getProperties() {
+    public Dictionary<String, Object> getProperties() {
         synchronized (this.propertiesMonitor) {
             return this.properties == null ? null : shallowCopy(this.properties);
         }
@@ -127,11 +126,10 @@
      * @param value The value to map to
      * @return <code>this</code> instance of the {@link StubConfiguration}
      */
-    @SuppressWarnings("unchecked")
     public StubConfiguration addProperty(String key, Object value) {
         synchronized (this.propertiesMonitor) {
             if (this.properties == null) {
-                this.properties = new Hashtable();
+                this.properties = new Hashtable<String, Object>();
                 updateSystemProperties(this.properties);
             }
 
@@ -158,11 +156,12 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     @SuppressWarnings("unchecked")
-    public void update(Dictionary properties) throws IOException {
+    public void update(Dictionary<String, ?> properties) throws IOException {
         assertNotNull(properties, "properties");
         synchronized (this.propertiesMonitor) {
-            Dictionary copy = shallowCopy(properties);
+            Dictionary<String, Object> copy = (Dictionary<String, Object>) shallowCopy(properties);
             updateSystemProperties(copy);
             this.properties = copy;
         }
@@ -214,8 +213,7 @@
         return this.deleted;
     }
 
-    @SuppressWarnings("unchecked")
-    private void updateSystemProperties(Dictionary properties) {
+    private void updateSystemProperties(Dictionary<String, Object> properties) {
         properties.put(Constants.SERVICE_PID, this.pid);
         if (this.factoryPid == null) {
             properties.remove(ConfigurationAdmin.SERVICE_FACTORYPID);
diff --git a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleTests.java b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleTests.java
index 10b5736..6655fc4 100644
--- a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleTests.java
+++ b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleTests.java
@@ -499,8 +499,8 @@
 
     private static final class TestFindEntriesDelegate implements FindEntriesDelegate {
 
-        public Enumeration<Object> findEntries(String path, String filePattern, boolean recurse) {
-            return new TestEnumeration<Object>();
+        public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
+            return new TestEnumeration<URL>();
         }
     }
 
diff --git a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationAdminTests.java b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationAdminTests.java
index 16290c2..b7d920d 100644
--- a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationAdminTests.java
+++ b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationAdminTests.java
@@ -72,11 +72,10 @@
         configAdmin.getConfiguration(null, null);
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void getConfigWithLocationExists() throws IOException {
         Configuration config = configAdmin.getConfiguration("test", null);
-        config.update(new Hashtable());
+        config.update(new Hashtable<String, Object>());
 
         Configuration config1 = configAdmin.getConfiguration("test", null);
         assertNotNull(config1.getProperties());
diff --git a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationTests.java b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationTests.java
index 9335dd8..0dcd2d1 100644
--- a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationTests.java
+++ b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/service/cm/StubConfigurationTests.java
@@ -116,13 +116,12 @@
         assertEquals("test2", this.config.getProperties().get("test1"));
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void getProperties() throws IOException {
         this.config.update(new Hashtable<String, String>());
 
-        Dictionary<String, String> properties1 = this.config.getProperties();
-        Dictionary<String, String> properties2 = this.config.getProperties();
+        Dictionary<String, Object> properties1 = this.config.getProperties();
+        Dictionary<String, Object> properties2 = this.config.getProperties();
         assertNotSame(properties1, properties2);
         properties2.put("test3", "test4");
         assertFalse(properties2.equals(this.config.getProperties()));
@@ -145,27 +144,25 @@
         this.config.update(null);
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void updateAddProperties() throws IOException {
         assertNull(this.config.getProperties());
-        this.config.update(new Hashtable());
+        this.config.update(new Hashtable<String, Object>());
         assertEquals(1, this.config.getProperties().size());
         assertEquals("test", this.config.getProperties().get(Constants.SERVICE_PID));
 
         Configuration config1 = new StubConfiguration("test1", "test2");
-        config1.update(new Hashtable());
+        config1.update(new Hashtable<String, Object>());
         assertEquals(2, config1.getProperties().size());
         assertEquals("test1", config1.getProperties().get(Constants.SERVICE_PID));
         assertEquals("test2", config1.getProperties().get(ConfigurationAdmin.SERVICE_FACTORYPID));
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void updateOverwriteProperties() throws IOException {
         assertNull(this.config.getProperties());
 
-        Hashtable properties = new Hashtable();
+        Hashtable<String, String> properties = new Hashtable<>();
         properties.put(Constants.SERVICE_PID, "test2");
         properties.put(ConfigurationAdmin.SERVICE_FACTORYPID, "test3");
 
@@ -183,7 +180,7 @@
     @Test(expected = IllegalStateException.class)
     public void updatePropertiesAfterDelete() throws IOException {
         this.config.delete();
-        this.config.update(new Hashtable());
+        this.config.update(new Hashtable<String, Object>());
     }
 
     @Test
diff --git a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/ObjectClassFilterTests.java b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/ObjectClassFilterTests.java
index a8cf37f..a18c9db 100644
--- a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/ObjectClassFilterTests.java
+++ b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/ObjectClassFilterTests.java
@@ -28,7 +28,7 @@
 public class ObjectClassFilterTests {
 
     private final ObjectClassFilter classFilter = new ObjectClassFilter(Object.class);
-    
+
     private final ObjectClassFilter classNameFilter = new ObjectClassFilter(Object.class.getName());
 
     @Test
@@ -44,7 +44,7 @@
             }
 
             public Object getProperty(String key) {
-                return new String[] {Object.class.getName()};
+                return new String[] { Object.class.getName() };
             }
 
             public String[] getPropertyKeys() {
@@ -59,7 +59,7 @@
                 throw new UnsupportedOperationException();
             }
         };
-        
+
         assertTrue(this.classFilter.match(objectServiceReference));
         assertTrue(this.classNameFilter.match(objectServiceReference));
 
@@ -74,7 +74,7 @@
             }
 
             public Object getProperty(String key) {
-                return new String[] {Exception.class.getName()};
+                return new String[] { Exception.class.getName() };
             }
 
             public String[] getPropertyKeys() {
@@ -97,7 +97,7 @@
     @Test
     public void matches() {
         Map<String, String[]> classNameMap = new HashMap<String, String[]>();
-        classNameMap.put(Constants.OBJECTCLASS, new String[]{Object.class.getName(), Object.class.getName()});
+        classNameMap.put(Constants.OBJECTCLASS, new String[] { Object.class.getName(), Object.class.getName() });
 
         assertTrue(this.classFilter.matches(classNameMap));
     }
@@ -107,26 +107,24 @@
         this.classFilter.matches(new HashMap<String, Object>());
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void matchDictionaryTrue() {
-        Dictionary d1 = new Hashtable();
-        d1.put(Constants.OBJECTCLASS, new String[] {Object.class.getName()});
+        Dictionary<String, Object> d1 = new Hashtable<>();
+        d1.put(Constants.OBJECTCLASS, new String[] { Object.class.getName() });
         assertTrue(this.classFilter.match(d1));
         assertTrue(this.classFilter.matchCase(d1));
-        
+
         assertTrue(this.classNameFilter.match(d1));
         assertTrue(this.classNameFilter.matchCase(d1));
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void matchDictionaryFalse() {
-        Dictionary d1 = new Hashtable();
-        d1.put(Constants.OBJECTCLASS, new String[] {Exception.class.getName()});
+        Dictionary<String, Object> d1 = new Hashtable<>();
+        d1.put(Constants.OBJECTCLASS, new String[] { Exception.class.getName() });
         assertFalse(this.classFilter.match(d1));
         assertFalse(this.classFilter.matchCase(d1));
-        
+
         assertFalse(this.classNameFilter.match(d1));
         assertFalse(this.classNameFilter.matchCase(d1));
     }
@@ -136,9 +134,9 @@
         assertEquals("(objectClass=java.lang.Object)", this.classFilter.toString());
         assertEquals("(objectClass=java.lang.Object)", this.classNameFilter.toString());
     }
-    
+
     @Test
-    public void hashCodeEqualsToStringsHashCode() {     
+    public void hashCodeEqualsToStringsHashCode() {
         assertEquals(this.classFilter.hashCode(), this.classFilter.toString().hashCode());
         assertEquals(this.classFilter.hashCode(), this.classNameFilter.toString().hashCode());
     }
diff --git a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/PropertiesFilterTests.java b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/PropertiesFilterTests.java
index dbe5eca..3f8f471 100644
--- a/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/PropertiesFilterTests.java
+++ b/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/support/PropertiesFilterTests.java
@@ -44,7 +44,6 @@
             }
 
             public Object getProperty(String key) {
-                // TODO Auto-generated method stub
                 return null;
             }
 
@@ -157,23 +156,22 @@
         filter.matches(null);
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void matchDictionary() {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put("testKey", "testValue");
         PropertiesFilter filter = new PropertiesFilter(properties);
 
-        Dictionary d1 = new Hashtable();
+        Dictionary<String, Object> d1 = new Hashtable<>();
         assertFalse(filter.match(d1));
         assertFalse(filter.matchCase(d1));
 
-        Dictionary d2 = new Hashtable();
+        Dictionary<String, Object> d2 = new Hashtable<>();
         d2.put("testKey", "badValue");
         assertFalse(filter.match(d2));
         assertFalse(filter.matchCase(d2));
 
-        Dictionary d3 = new Hashtable();
+        Dictionary<String, Object> d3 = new Hashtable<>();
         d3.put("testKey", "testValue");
         assertTrue(filter.match(d3));
         assertTrue(filter.matchCase(d3));