sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1689827 - in /sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup: AsyncInstaller.java IncrementalStartupIT.java P.java SlowActivator.java StartLevelReport.java StartLevelReportImpl.java
Date Wed, 08 Jul 2015 09:32:32 GMT
Author: bdelacretaz
Date: Wed Jul  8 09:32:31 2015
New Revision: 1689827

URL: http://svn.apache.org/r1689827
Log:
SLING-4851 - tests now expose the issue: activators of bundles installed via the OSGi installer
finish outside of their bundle's start level

Removed:
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/StartLevelReport.java
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/StartLevelReportImpl.java
Modified:
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/AsyncInstaller.java
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/IncrementalStartupIT.java
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/P.java
    sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/SlowActivator.java

Modified: sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/AsyncInstaller.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/AsyncInstaller.java?rev=1689827&r1=1689826&r2=1689827&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/AsyncInstaller.java
(original)
+++ sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/AsyncInstaller.java
Wed Jul  8 09:32:31 2015
@@ -95,13 +95,11 @@ class AsyncInstaller implements Framewor
     private InputStream getTestBundleStream(String bundleSymbolicName) throws Exception {
         final EmbeddedClass activator = new EmbeddedClass(SlowActivator.class);
         final EmbeddedClass waitFor = new EmbeddedClass(WaitFor.class);
-        final EmbeddedClass report = new EmbeddedClass(StartLevelReport.class);
         return TinyBundles.bundle()
             .set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName)
             .set(Constants.BUNDLE_ACTIVATOR, SlowActivator.class.getName())
             .add(activator.getPath(), activator.getStream())
             .add(waitFor.getPath(), waitFor.getStream())
-            .add(report.getPath(), report.getStream())
             .build(TinyBundles.withBnd());
     }
     
@@ -160,8 +158,7 @@ class AsyncInstaller implements Framewor
     }
     
     /** Check that the test bundle activators finished at the right start level */
-    Collection<String> getActivatorIssues(StartLevelReport reports) {
-        final Map<String, Integer> levels = reports.getBsnToStartLevelMap();
+    Collection<String> getActivatorIssues(Map<String, Integer> levels) {
         final Set<String> issues = new HashSet<String>(installedBundles);
         assertTrue("Expecting some activator reports", levels.size() > 0);
         for(String bsn : levels.keySet()) {

Modified: sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/IncrementalStartupIT.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/IncrementalStartupIT.java?rev=1689827&r1=1689826&r2=1689827&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/IncrementalStartupIT.java
(original)
+++ sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/IncrementalStartupIT.java
Wed Jul  8 09:32:31 2015
@@ -19,6 +19,8 @@
 package org.apache.sling.launchpad.it.startup;
 
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.inject.Inject;
 
@@ -39,7 +41,7 @@ public class IncrementalStartupIT {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
     public static final int DEFAULT_TIMEOUT = 5;
-    private StartLevelReport startLevelReport;
+    private Map<String, Integer> startLevelMap;
     private ServiceRegistration startLevelReportReg;
     
     @Inject
@@ -72,12 +74,14 @@ public class IncrementalStartupIT {
     }
     
     private void setupReports() {
-        startLevelReport = new StartLevelReportImpl(startLevel);
-        startLevelReportReg = bundleContext.registerService(StartLevelReport.class.getName(),
startLevelReport, null);
+        startLevelMap = new HashMap<String, Integer>();
+        log.info("Registering StartLevelReport service");
+        startLevelReportReg = bundleContext.registerService(Map.class.getName(), startLevelMap,
null);
     }
     
     private void cleanup() {
         if(startLevelReportReg != null) {
+            log.info("Unregistering StartLevelReport service");
             startLevelReportReg.unregister();
             startLevelReportReg = null;
         }
@@ -117,7 +121,7 @@ public class IncrementalStartupIT {
             // are started
             new WaitFor(DEFAULT_TIMEOUT) {
                 protected boolean condition() {
-                    final Collection<String> issues = ai.getActivatorIssues(startLevelReport);
+                    final Collection<String> issues = ai.getActivatorIssues(startLevelMap);
                     if(issues.isEmpty()) {
                         return true;
                     }

Modified: sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/P.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/P.java?rev=1689827&r1=1689826&r2=1689827&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/P.java
(original)
+++ sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/P.java
Wed Jul  8 09:32:31 2015
@@ -31,7 +31,7 @@ import org.ops4j.pax.exam.options.Defaul
 /** Test parameters and configuration */
 public class P {
     
-    public static final int START_LEVEL_CHANGE = 3; 
+    public static final int START_LEVEL_CHANGE = 5; 
     public static final int MAX_BUNDLES_PER_LEVEL = 3;
     
     public static Option[] paxConfig() {

Modified: sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/SlowActivator.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/SlowActivator.java?rev=1689827&r1=1689826&r2=1689827&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/SlowActivator.java
(original)
+++ sling/whiteboard/bdelacretaz/it-startup/src/test/java/org/apache/sling/launchpad/it/startup/SlowActivator.java
Wed Jul  8 09:32:31 2015
@@ -18,9 +18,12 @@
  */
 package org.apache.sling.launchpad.it.startup;
 
+import java.util.Map;
+
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,18 +42,28 @@ public class SlowActivator implements Bu
         log.info("Activating with a delay of {} msec: {}", msec, bsn);
         WaitFor.sleep(msec);
 
-        /* does not work yet
-        final ServiceReference ref = context.getServiceReference(StartLevelReport.class.getName());
-        if(ref == null) {
-            throw new IllegalStateException("StartLevelReport service not found - already
gone?");
+        
+        int level = -1;
+        {
+            final ServiceReference ref = context.getServiceReference(StartLevel.class.getName());
+            try {
+                final StartLevel svc = (StartLevel)context.getService(ref); 
+                level = svc.getStartLevel();
+            } finally {
+                context.ungetService(ref);
+            }
         }
-        final StartLevelReport slr = (StartLevelReport)context.getService(ref);
-        try {
-            slr.activationDone(bsn);
-        } finally {
-            context.ungetService(ref);
+        
+        {
+            final ServiceReference ref = context.getServiceReference(Map.class.getName());
+            try {
+                @SuppressWarnings("unchecked")
+                final Map<String, Integer >levelMap = (Map<String, Integer>)context.getService(ref);
+                levelMap.put(bsn, level);
+            } finally {
+                context.ungetService(ref);
+            }
         }
-        */
     }
 
     @Override



Mime
View raw message