Author: cziegeler
Date: Thu Oct 20 13:54:37 2016
New Revision: 1765819

URL: http://svn.apache.org/viewvc?rev=1765819&view=rev
Log:
Use system bundle context to have a stable bundle context during tests

Modified:
    
sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java

Modified: 
sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java?rev=1765819&r1=1765818&r2=1765819&view=diff
==============================================================================
--- 
sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
 (original)
+++ 
sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
 Thu Oct 20 13:54:37 2016
@@ -20,27 +20,20 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNull;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 
 import org.apache.sling.installer.api.OsgiInstaller;
-import org.apache.sling.installer.core.impl.tasks.BundleInfo;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.FrameworkPropertyOption;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Version;
 
 @RunWith(PaxExam.class)
 public class BundleInstallBlackListTest extends OsgiInstallerTestBase {
-    
+
     final String symbolicName = "osgi-installer-testbundle";
 
     @org.ops4j.pax.exam.Configuration
@@ -48,12 +41,21 @@ public class BundleInstallBlackListTest
         return defaultConfiguration();
     }
 
+    @Override
     @Before
-    public void setUp() throws BundleException {
+    public void setup() {
+        // switch to system bundle context
+        bundleContext = bundleContext.getBundle(0).getBundleContext();
+        super.setup();
         System.setProperty("sling.launchpad",new 
File("src/test/resources/blacklisttest").getAbsolutePath());
-        updateInstallerBundle();
+        try {
+            updateInstallerBundle();
+        } catch ( BundleException be) {
+            throw new RuntimeException(be);
+        }
     }
 
+    @Override
     @After
     public void tearDown() {
         super.tearDown();
@@ -95,7 +97,7 @@ public class BundleInstallBlackListTest
 
     @Test
     public void testUninstallWithBlacklistedVersions() throws Exception {
-        
+
         // Reroute launchpad home containing empty blacklist for ramp up
         System.setProperty("sling.launchpad",new 
File("src/test/resources/blacklisttestempty").getAbsolutePath());
         updateInstallerBundle();
@@ -131,7 +133,7 @@ public class BundleInstallBlackListTest
         // configure blacklist bundle to ignore older version
         System.setProperty("sling.launchpad",new 
File("src/test/resources/blacklisttest").getAbsolutePath());
         updateInstallerBundle();
-        
+
         // Try to uninstall current version and verify uninstall instead of
         // downgrade to blacklisted version
         {
@@ -149,7 +151,19 @@ public class BundleInstallBlackListTest
     }
 
     private void updateInstallerBundle() throws BundleException {
+        // wait a little bit for updating bundle
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException e) {
+            // ignore
+        }
         
bundleContext.getServiceReference(OsgiInstaller.class).getBundle().update();
+        // wait a little bit after updating bundle
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException e) {
+            // ignore
+        }
         setupInstaller();
     }
 
@@ -219,7 +233,7 @@ public class BundleInstallBlackListTest
         // configure blacklist bundle to ignore older version
         System.setProperty("sling.launchpad",new 
File("src/test/resources/blacklisttest").getAbsolutePath());
         updateInstallerBundle();
- 
+
         // Try to uninstall current version and verify uninstall instead of
         // downgrade to blacklisted version
         {


Reply via email to