incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r809621 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/test/java/org/apache/sling/osgi/installer/impl/ it/src...
Date Mon, 31 Aug 2009 15:14:33 GMT
Author: bdelacretaz
Date: Mon Aug 31 15:14:31 2009
New Revision: 809621

URL: http://svn.apache.org/viewvc?rev=809621&view=rev
Log:
SLING-1078 - improved logging of OSGi tasks, and fix bug in RegisteredResourceComparator

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.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=809621&r1=809620&r2=809621&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
Mon Aug 31 15:14:31 2009
@@ -33,8 +33,6 @@
 /** TaskCreator that processes a list of bundle RegisteredResources */
 class BundleTaskCreator {
 
-    public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
-    
     /** Store the digests of the bundles for which we create update tasks,
      *  keyed by symbolic name, to avoid generating repated updates
      *  for snapshot bundles
@@ -101,7 +99,7 @@
 	                // installed but different version. Can be a later version if 
 			        // the newer version resource was removed, in case we downgrade
 			        toUpdate = toActivate;
-			    } else if(compare == 0 && newVersion.toString().indexOf(MAVEN_SNAPSHOT_MARKER)
>= 0){
+			    } else if(compare == 0 && ctx.isSnapshot(newVersion)){
 			        // installed, same version but SNAPSHOT
                     toUpdate = toActivate;
 			    }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
Mon Aug 31 15:14:31 2009
@@ -20,6 +20,7 @@
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -33,6 +34,7 @@
 	void incrementCounter(int index);
     void setCounter(int index, long value);
     Bundle getMatchingBundle(String bundleSymbolicName);
+    boolean isSnapshot(Version v);
 	
 	/** Schedule a task for execution in the current OsgiController cycle */
 	void addTaskToCurrentCycle(OsgiInstallerTask t);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
Mon Aug 31 15:14:31 2009
@@ -26,6 +26,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -34,6 +35,8 @@
 /** OsgiInstaller service implementation */
 public class OsgiInstallerImpl implements OsgiInstaller, OsgiInstallerContext {
 
+    public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
+    
 	private final BundleContext bundleContext;
     private final PackageAdmin packageAdmin;
     private final ServiceTracker logServiceTracker;
@@ -149,4 +152,8 @@
         }
         return null;
     }
+    
+	public boolean isSnapshot(Version v) {
+		return v.toString().indexOf(MAVEN_SNAPSHOT_MARKER) >= 0;
+	}
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
Mon Aug 31 15:14:31 2009
@@ -22,10 +22,11 @@
 
 /** Base class for tasks that can be executed by the {@link OsgiInstallerImpl} */ 
 public abstract class OsgiInstallerTask implements Comparable<OsgiInstallerTask> {
-	/** Execute this task */
-	public void execute(OsgiInstallerContext ctx) throws Exception {
+    public abstract void execute(OsgiInstallerContext ctx) throws Exception;
+
+	protected void logExecution(OsgiInstallerContext ctx) {
 		if(ctx.getLogService() != null) {
-			ctx.getLogService().log(LogService.LOG_DEBUG, "Executing task " + this);
+			ctx.getLogService().log(LogService.LOG_DEBUG, "OsgiInstallerTask: executing  " + this);
 		}
 	}
 	

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Mon Aug 31 15:14:31 2009
@@ -360,7 +360,7 @@
                 group.remove(r);
                 if(ctx.getLogService() != null) {
                     ctx.getLogService().log(LogService.LOG_DEBUG,
-                            "Resource deleted, not installable and has been processed: "
+ r);
+                            "Removing RegisteredResource from list, not installable and has
been processed: " + r);
                 }
             }
             if(group.isEmpty() && key != null) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
Mon Aug 31 15:14:31 2009
@@ -23,14 +23,25 @@
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
-/** Comparator that defines priorities between RegisteredResources */
+/** Comparator that defines priorities between RegisteredResources.
+ * 	The RegisteredResources are grouped by OSGi "entity" (bundle symbolic
+ * 	name, config PID, etc.) in sorted sets, and this comparator is used
+ *  to sort the resources in the sets.
+ */
 class RegisteredResourceComparator implements Comparator<RegisteredResource >{
 
     public int compare(RegisteredResource a, RegisteredResource b) {
-        if(a.getResourceType() == RegisteredResource.ResourceType.BUNDLE) {
+    	final boolean aBundle = a.getResourceType() == RegisteredResource.ResourceType.BUNDLE;
+    	final boolean bBundle = b.getResourceType() == RegisteredResource.ResourceType.BUNDLE;
+    	
+        if(aBundle && bBundle) {
             return compareBundles(a, b);
-        } else {
+        } else if(!aBundle && !bBundle){
             return compareConfig(a, b);
+        } else if(aBundle) {
+        	return 1;
+        } else {
+        	return -1;
         }
     }
     
@@ -50,7 +61,7 @@
         if(result == 0) {
             final Version va = (Version)a.getAttributes().get(Constants.BUNDLE_VERSION);
             final Version vb = (Version)b.getAttributes().get(Constants.BUNDLE_VERSION);
-            isSnapshot = va!= null && va.toString().contains(BundleTaskCreator.MAVEN_SNAPSHOT_MARKER);
+            isSnapshot = va!= null && va.toString().contains(OsgiInstallerImpl.MAVEN_SNAPSHOT_MARKER);
             if(va != null && vb != null) {
                 // higher version has more priority, must come first so invert comparison
                 result = vb.compareTo(va);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
Mon Aug 31 15:14:31 2009
@@ -39,10 +39,9 @@
     	return getClass().getSimpleName() + ": " + resource;
     }
     
-    @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
         final Bundle b = ctx.getBundleContext().installBundle(resource.getUrl(), resource.getInputStream());
+        logExecution(ctx);
         ctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId()));
         ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
     }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
Mon Aug 31 15:14:31 2009
@@ -44,7 +44,7 @@
     
     @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
+        logExecution(ctx);
         final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
         final Bundle b = ctx.getMatchingBundle(symbolicName);
         if(b == null) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
Mon Aug 31 15:14:31 2009
@@ -56,7 +56,6 @@
 	}
 
 	public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
 		final Bundle b = ctx.getBundleContext().getBundle(bundleId);
 		final LogService log = ctx.getLogService();
 		boolean needToRetry = false;
@@ -75,6 +74,7 @@
 	            }
 	        } else {
 	            // Try to start bundle, and if that doesn't work we'll need to retry
+	            logExecution(ctx);
 	            try {
 	                b.start();
 	                if(log != null) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
Mon Aug 31 15:14:31 2009
@@ -24,6 +24,7 @@
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
 import org.osgi.service.log.LogService;
 
 /** Update a bundle from a RegisteredResource. Creates
@@ -49,12 +50,27 @@
     
     @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
         final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
         final Bundle b = ctx.getMatchingBundle(symbolicName);
         if(b == null) {
             throw new IllegalStateException("Bundle to update (" + symbolicName + ") not
found");
         }
+        
+        // Do not update if same version, unless snapshot
+        if(b != null) {
+        	final Version currentVersion = new Version((String)b.getHeaders().get(Constants.BUNDLE_VERSION));
+        	final Version newVersion = (Version)resource.getAttributes().get(Constants.BUNDLE_VERSION);
+        	if(currentVersion.equals(newVersion) && !ctx.isSnapshot(newVersion)) {
+        		if(ctx.getLogService() != null) {
+            		ctx.getLogService().log(
+            				LogService.LOG_DEBUG, 
+            				"Same version is already installed, and not a snapshot, ignoring update:"
+ resource);
+        		}
+        		return;
+        	}
+        }
+        
+        logExecution(ctx);
         if(b.getState() == Bundle.ACTIVE) {
             // bundle was active before the update - restart it once updated, but
             // in sequence, not right now

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
Mon Aug 31 15:14:31 2009
@@ -44,7 +44,6 @@
     
     @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
         
         final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
         if(ca == null) {
@@ -56,6 +55,8 @@
             return;
         }
         
+        logExecution(ctx);
+        
         // Convert data to a configuration Dictionary
         Dictionary<String, Object> dict = resource.getDictionary();
 

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
Mon Aug 31 15:14:31 2009
@@ -40,9 +40,7 @@
         return TaskOrder.CONFIG_REMOVE_ORDER + pid.getCompositePid();
     }
     
-    @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
         
         final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
         if(ca == null) {
@@ -54,6 +52,7 @@
             return;
         }
         
+        logExecution(ctx);
         final Configuration cfg = getConfiguration(ca, pid, false, ctx);
         if(cfg == null) {
             if(ctx.getLogService() != null) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
Mon Aug 31 15:14:31 2009
@@ -62,7 +62,7 @@
 	}
 
 	public void execute(OsgiInstallerContext ctx) throws Exception {
-        super.execute(ctx);
+        logExecution(ctx);
 		this.ctx = ctx;
         final int targetEventCount = packageRefreshEventsCount + 1;
         final long start = System.currentTimeMillis();

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
Mon Aug 31 15:14:31 2009
@@ -20,6 +20,7 @@
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -57,4 +58,8 @@
     public Bundle getMatchingBundle(String bundleSymbolicName) {
         return null;
     }
+    
+	public boolean isSnapshot(Version v) {
+		return v.toString().indexOf(OsgiInstallerImpl.MAVEN_SNAPSHOT_MARKER) >= 0;
+	}
 }

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
Mon Aug 31 15:14:31 2009
@@ -171,4 +171,13 @@
         inOrder[3] = getConfig("pidB", null, 0); 
         assertOrder(inOrder);
     }
+    
+    @Test
+    public void testConfigAndBundle() throws IOException {
+    	final RegisteredResource cfg = getConfig("pid", null, InstallableResource.DEFAULT_PRIORITY);
+    	final RegisteredResource b = new MockBundleResource("a", "1.0");
+    	final RegisteredResourceComparator c = new RegisteredResourceComparator();
+    	assertEquals("bundle is > config when compared", 1, c.compare(b, cfg));
+    	assertEquals("config is < bundle when compared", -1, c.compare(cfg, b));
+    }
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java?rev=809621&r1=809620&r2=809621&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java
(original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java
Mon Aug 31 15:14:31 2009
@@ -71,19 +71,19 @@
     	{
     	    resetCounters();
             installer.addResource(getInstallableResource(
-                    getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+                    getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"));
             waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
         	final Bundle b = assertBundle("After updating to 1.2", symbolicName, "1.2", Bundle.ACTIVE);
         	assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
     	}
 
     	assertNoOsgiTasks("After test " + testIndex++);
-    	
+
     	// Downgrade to lower version, installed bundle must not change
         {
             resetCounters();
             installer.addResource(getInstallableResource(
-                    getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
+                    getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar"), "digestA"));
             
             // make sure no updates happen
             waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
@@ -97,6 +97,14 @@
         assertCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, 3);
         assertCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, 1);
         
+    	// Update to same version with different digest must be ignored
+    	{
+    	    resetCounters();
+            installer.addResource(getInstallableResource(
+                    getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar"), "digestB"));
+        	assertNoOsgiTasks("Update to same version should generate no OSGi tasks");
+    	}
+    	
     	// Uninstall
     	{
             resetCounters();



Mime
View raw message