Make bundless-diag a component
[odlparent.git] / features-test-plugin / src / main / java / org / opendaylight / odlparent / features / test / plugin / TestProbe.java
index 09d42aa89b754e288582dec25548b23d7691ad0a..64b3fa7543b16576891ea43de7b6975d82e3cf86 100644 (file)
@@ -14,14 +14,12 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import javax.inject.Inject;
-import org.apache.karaf.bundle.core.BundleService;
 import org.apache.karaf.features.FeaturesService;
 import org.junit.Test;
 import org.opendaylight.odlparent.bundles.diag.ContainerState;
 import org.opendaylight.odlparent.bundles.diag.Diag;
 import org.opendaylight.odlparent.bundles.diag.DiagBundle;
-import org.opendaylight.odlparent.bundles.diag.spi.DefaultDiagProvider;
-import org.osgi.framework.BundleContext;
+import org.opendaylight.odlparent.bundles.diag.DiagProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,14 +59,11 @@ public final class TestProbe {
         "slf4j.log4j12", ContainerState.INSTALLED,
         "org.apache.karaf.scr.management", ContainerState.WAITING);
 
-    @Inject
-    private BundleContext bundleContext;
-
     @Inject
     private FeaturesService featuresService;
 
     @Inject
-    private BundleService bundleService;
+    private DiagProvider diagProvider;
 
     /**
      * Performs the project feature installation on karaf environment with subsequent state check of deployed bundles.
@@ -89,16 +84,10 @@ public final class TestProbe {
     }
 
     private void validateServices() {
-        if (bundleContext == null) {
-            throw new IllegalStateException("bundleContext is not initialized");
-        }
-        // replace the probe's initial context which expires too fast
-        bundleContext = bundleContext.getBundle(0).getBundleContext();
-
         if (featuresService == null) {
             throw new IllegalStateException("featureService is not initialized");
         }
-        if (bundleService == null) {
+        if (diagProvider == null) {
             throw new IllegalStateException("bundleService is not initialized");
         }
     }
@@ -137,7 +126,6 @@ public final class TestProbe {
         final var intervalNanos = TimeUnit.SECONDS.toNanos(interval);
         final var maxNanos = TimeUnit.SECONDS.toNanos(timeout);
         final var started = System.nanoTime();
-        final var diagProvider = new DefaultDiagProvider(bundleService, bundleContext);
 
         Diag prevDiag = null;
         while (true) {