incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r890825 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
Date Tue, 15 Dec 2009 15:25:29 GMT
Author: bdelacretaz
Date: Tue Dec 15 15:25:29 2009
New Revision: 890825

URL: http://svn.apache.org/viewvc?rev=890825&view=rev
Log:
SLING-1239 - OSGi installer shouldn't remove bundles that it didn't install

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=890825&r1=890824&r2=890825&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
Tue Dec 15 15:25:29 2009
@@ -85,8 +85,17 @@
 		
 		if(toActivate == null) {
 		    // None of our resources are installable, remove corresponding bundle if present
+		    // and if we installed it
 		    if(getBundleInfo(ctx, resources.first()) != null) {
-	            tasks.add(new BundleRemoveTask(resources.first()));
+		        if(ctx.getInstalledBundleVersion(symbolicName) == null) {
+                    if(ctx.getLogService() != null) {
+                        ctx.getLogService().log(LogService.LOG_INFO, 
+                                "Bundle " + symbolicName 
+                                + " was not installed by this module, not removed");
+                    }
+		        } else {
+		            tasks.add(new BundleRemoveTask(resources.first()));
+		        }
 	        }
 			
 		} else {
@@ -117,7 +126,7 @@
                         if(ctx.getLogService() != null) {
                             ctx.getLogService().log(LogService.LOG_INFO, 
                                     "Bundle " + info.symbolicName + " " + installedVersion

-                                    + " was not installed by this module, leaving as is");
+                                    + " was not installed by this module, not downgraded");
                         }
                     }
 			    } else if(compare == 0 && ctx.isSnapshot(newVersion)){

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java?rev=890825&r1=890824&r2=890825&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
Tue Dec 15 15:25:29 2009
@@ -151,8 +151,9 @@
     
     @Test 
     public void testBundleRemoveSingle() throws IOException {
+        final String version = "1.0";
         final RegisteredResource [] r = {
-                new MockBundleResource(SN, "1.0")
+                new MockBundleResource(SN, version)
         };
         r[0].setInstallable(false);
         
@@ -160,7 +161,15 @@
             final MockBundleTaskCreator c = new MockBundleTaskCreator();
             c.addBundleInfo(SN, "1.0", Bundle.ACTIVE);
             final SortedSet<OsgiInstallerTask> s = getTasks(r, c);
-            assertEquals("Expected one task", 1, s.size());
+            assertEquals("Expected no tasks, bundle was not installed by us", 0, s.size());
+        }
+        
+        {
+            ctx.saveInstalledBundleInfo(SN, r[0].getDigest(), version);
+            final MockBundleTaskCreator c = new MockBundleTaskCreator();
+            c.addBundleInfo(SN, "1.0", Bundle.ACTIVE);
+            final SortedSet<OsgiInstallerTask> s = getTasks(r, c);
+            assertEquals("Expected one task, as we installed that bundle", 1, s.size());
             assertTrue("Expected a BundleRemoveTask", s.first() instanceof BundleRemoveTask);
         }
     }
@@ -180,7 +189,15 @@
             final MockBundleTaskCreator c = new MockBundleTaskCreator();
             c.addBundleInfo(SN, "1.1", Bundle.ACTIVE);
             final SortedSet<OsgiInstallerTask> s = getTasks(r, c);
-            assertEquals("Expected one task", 1, s.size());
+            assertEquals("Expected no tasks, bundle was not installed by us", 0, s.size());
+        }
+        
+        {
+            final MockBundleTaskCreator c = new MockBundleTaskCreator();
+            c.addBundleInfo(SN, "1.1", Bundle.ACTIVE);
+            ctx.saveInstalledBundleInfo(SN, r[1].getDigest(), "1.1");
+            final SortedSet<OsgiInstallerTask> s = getTasks(r, c);
+            assertEquals("Expected one task, as we installed that bundle", 1, s.size());
             assertTrue("Expected a BundleRemoveTask", s.first() instanceof BundleRemoveTask);
         }
     }



Mime
View raw message