installer.it: remove unchecked warnings
authorRobert Munteanu <rombert@apache.org>
Thu, 24 Nov 2016 10:45:56 +0000 (10:45 +0000)
committerRobert Munteanu <rombert@apache.org>
Thu, 24 Nov 2016 10:45:56 +0000 (10:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1771109 13f79535-47bb-0310-9956-ffa450edef68

src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java
src/test/java/org/apache/sling/installer/it/EventsDetector.java
src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java

index a7d89b3..6a56db0 100644 (file)
@@ -451,21 +451,21 @@ public class ConfigInstallTest extends OsgiInstallerTestBase implements Configur
     public void testDeferredConfigRemove() throws Exception {
         final AtomicInteger transformerCount = new AtomicInteger();
 
-        final ServiceTracker st = new ServiceTracker(bundleContext,
-                ResourceTransformer.class.getName(), new ServiceTrackerCustomizer() {
+        final ServiceTracker<ResourceTransformer, ResourceTransformer> st = new ServiceTracker<ResourceTransformer, ResourceTransformer>(bundleContext,
+                ResourceTransformer.class, new ServiceTrackerCustomizer<ResourceTransformer, ResourceTransformer>() {
 
             @Override
-            public void removedService(ServiceReference reference, Object service) {
+            public void removedService(ServiceReference<ResourceTransformer> reference, ResourceTransformer service) {
                 bundleContext.ungetService(reference);
                 transformerCount.decrementAndGet();
             }
 
             @Override
-            public void modifiedService(ServiceReference reference, Object service) {
+            public void modifiedService(ServiceReference<ResourceTransformer> reference, ResourceTransformer service) {
             }
 
             @Override
-            public Object addingService(ServiceReference reference) {
+            public ResourceTransformer addingService(ServiceReference<ResourceTransformer> reference) {
                 transformerCount.incrementAndGet();
                 return bundleContext.getService(reference);
             }
index f0b499b..cbbfd71 100644 (file)
@@ -33,7 +33,7 @@ import org.osgi.service.cm.ConfigurationListener;
 class EventsDetector implements FrameworkListener, BundleListener, ConfigurationListener, ServiceListener {
 
     private long lastEvent;
-    private final ServiceRegistration configReg;
+    private final ServiceRegistration<ConfigurationListener> configReg;
     private final BundleContext ctx;
 
     EventsDetector(BundleContext ctx) {
@@ -41,7 +41,7 @@ class EventsDetector implements FrameworkListener, BundleListener, Configuration
         ctx.addBundleListener(this);
         ctx.addFrameworkListener(this);
         ctx.addServiceListener(this);
-        configReg = ctx.registerService(ConfigurationListener.class.getName(), this, null);
+        configReg = ctx.registerService(ConfigurationListener.class, this, null);
     }
 
     void close() {
index ea531ee..bbad6c0 100644 (file)
@@ -74,7 +74,7 @@ public class OsgiInstallerTestBase implements FrameworkListener {
 
        public final static String JAR_EXT = ".jar";
        private volatile int packageRefreshEventsCount;
-       private volatile ServiceTracker configAdminTracker;
+       private volatile ServiceTracker<ConfigurationAdmin, ConfigurationAdmin> configAdminTracker;
 
        protected volatile OsgiInstaller installer;
 
@@ -102,11 +102,10 @@ public class OsgiInstallerTestBase implements FrameworkListener {
     /**
      * Helper method to get a service of the given type
      */
-    @SuppressWarnings("unchecked")
        protected <T> T getService(Class<T> clazz) {
-       final ServiceReference ref = bundleContext.getServiceReference(clazz.getName());
+       final ServiceReference<T> ref = bundleContext.getServiceReference(clazz);
        assertNotNull("getService(" + clazz.getName() + ") must find ServiceReference", ref);
-       final T result = (T)(bundleContext.getService(ref));
+       final T result = bundleContext.getService(ref);
        assertNotNull("getService(" + clazz.getName() + ") must find service", result);
        return result;
     }
@@ -120,7 +119,7 @@ public class OsgiInstallerTestBase implements FrameworkListener {
 
     @Before
     public void setup() {
-        configAdminTracker = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
+        configAdminTracker = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>(bundleContext, ConfigurationAdmin.class, null);
         configAdminTracker.open();
     }
 
@@ -444,7 +443,7 @@ public class OsgiInstallerTestBase implements FrameworkListener {
        final long waitUntil = System.currentTimeMillis() + (timeout * 1000L);
        boolean isPresent;
        do {
-               result = (ConfigurationAdmin)configAdminTracker.getService();
+               result = configAdminTracker.getService();
                isPresent = result != null;
                if ( shouldBePresent == isPresent ) {
                    return result;