You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2009/08/20 15:42:12 UTC

svn commit: r806168 - 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...

Author: bdelacretaz
Date: Thu Aug 20 13:42:10 2009
New Revision: 806168

URL: http://svn.apache.org/viewvc?rev=806168&view=rev
Log:
SLING-1078 - OsgiInstaller.registerResources() implemented and tested

Added:
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java   (with props)
Modified:
    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/OsgiInstallerThread.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.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/RegisteredResourceImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java

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=806168&r1=806167&r2=806168&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 Thu Aug 20 13:42:10 2009
@@ -19,7 +19,9 @@
 package org.apache.sling.osgi.installer.impl;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
@@ -105,19 +107,21 @@
 	}
 
 	public void addResource(InstallableResource r) throws IOException {
-	    // TODO do not add if we already have it, based on digest
-	    installerThread.addNewResource(new RegisteredResourceImpl(bundleContext, r));
+	    synchronized (installerThread) {
+	        installerThread.addNewResource(new RegisteredResourceImpl(bundleContext, r));
+        }
 	}
 
-	public void registerResources(Collection<InstallableResource> data,
-			String urlScheme) throws IOException {
-		// TODO
+	public void registerResources(Collection<InstallableResource> data, String urlScheme) throws IOException {
+        installerThread.addNewResources(data, urlScheme, bundleContext);
 	}
 
 	public void removeResource(InstallableResource r) throws IOException {
 		final RegisteredResource rr = new RegisteredResourceImpl(bundleContext, r);
 		rr.setInstallable(false);
-		installerThread.addNewResource(rr);
+        synchronized (installerThread) {
+            installerThread.addNewResource(rr);
+        }
 	}
 
 	public Storage getStorage() {

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=806168&r1=806167&r2=806168&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 Thu Aug 20 13:42:10 2009
@@ -18,14 +18,20 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 
 /** Worker thread where all OSGi tasks are executed.
@@ -42,6 +48,7 @@
     private final List<RegisteredResource> newResources = new LinkedList<RegisteredResource>();
     private final SortedSet<OsgiInstallerTask> tasks = new TreeSet<OsgiInstallerTask>();
     private final SortedSet<OsgiInstallerTask> tasksForNextCycle = new TreeSet<OsgiInstallerTask>();
+    private final List<SortedSet<RegisteredResource>> newResourcesSets = new ArrayList<SortedSet<RegisteredResource>>();
     
     /** Group our RegisteredResource by OSGi entity */ 
     private Map<String, SortedSet<RegisteredResource>>registeredResources = 
@@ -95,15 +102,64 @@
         }
     }
     
-    /** Register a new resource, will be processed on the next cycle */
+    /** Register a single new resource, will be processed on the next cycle */
     void addNewResource(RegisteredResource r) {
         synchronized (newResources) {
             newResources.add(r);
         }
     }
     
+    /** Register a number of new resources, and mark others having the same scheme as not installable.
+     *  Used with {@link OsgiInstaller.registerResources}
+     */
+    void addNewResources(Collection<InstallableResource> data, String urlScheme, BundleContext bundleContext) throws IOException {
+        // Check scheme, do nothing if at least one of them is wrong
+        final SortedSet<RegisteredResource> toAdd = new TreeSet<RegisteredResource>(new RegisteredResourceComparator());
+        for(InstallableResource r : data) {
+            final RegisteredResource rr = new RegisteredResourceImpl(bundleContext, r);
+            if(!rr.getUrlScheme().equals(urlScheme)) {
+                throw new IllegalArgumentException(
+                        "URL of all supplied InstallableResource must start with supplied scheme"
+                        + ", scheme is not '" + urlScheme + "' for URL " + r.getUrl());
+            }
+            toAdd.add(rr);
+        }
+        
+        if(!toAdd.isEmpty()) {
+            synchronized (newResources) {
+                newResourcesSets.add(toAdd);
+            }
+        }
+    }
+    
     private void mergeNewResources() {
         synchronized (newResources) {
+            // If we have sets of new resources, each of them represents the complete list
+            // of available resources for a given scheme. So, before adding them mark
+            // all resources with the same scheme in newResources, and existing
+            // registeredResources, as not installable
+            for(SortedSet<RegisteredResource> s : newResourcesSets) {
+                final String scheme = s.first().getUrlScheme();
+                debug("Processing set of new resources with scheme " + scheme);
+                for(RegisteredResource r : newResources) {
+                    if(r.getUrlScheme().equals(scheme)) {
+                        r.setInstallable(false);
+                        debug("New resource set to non-installable: " + r); 
+                    }
+                 }
+                for(SortedSet<RegisteredResource> ss : registeredResources.values()) {
+                    for(RegisteredResource r : ss) {
+                        if(r.getUrlScheme().equals(scheme)) {
+                            r.setInstallable(false);
+                            debug("Existing resource set to non-installable: " + r); 
+                        }
+                    }
+                }
+                newResources.addAll(s);
+                debug("Added set of " + s.size() + " new resources with scheme " + scheme);
+            }
+            newResourcesSets.clear();
+            
             for(RegisteredResource r : newResources) {
                 SortedSet<RegisteredResource> t = registeredResources.get(r.getEntityId());
                 if(t == null) {
@@ -176,5 +232,11 @@
     }
     
     protected void cycleDone() {
-    }   
+    }
+    
+    private void debug(String str) {
+        if(ctx.getLogService() != null) {
+            ctx.getLogService().log(LogService.LOG_DEBUG, str);
+        }
+    }
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Thu Aug 20 13:42:10 2009
@@ -49,6 +49,7 @@
 	boolean isInstallable();
 	void setInstallable(boolean installable);
 	ResourceType getResourceType();
+	String getUrlScheme();
 	
 	/** Attributes include the bundle symbolic name, bundle version, etc. */
 	Map<String, Object> getAttributes();

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=806168&r1=806167&r2=806168&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 Thu Aug 20 13:42:10 2009
@@ -37,7 +37,7 @@
     int compareBundles(RegisteredResource a, RegisteredResource b) {
         
         final String nameA = (String)a.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
-        final String nameB = (String)a.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
+        final String nameB = (String)b.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
         int result = nameA.compareTo(nameB);
         
         if(result == 0) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java Thu Aug 20 13:42:10 2009
@@ -57,6 +57,7 @@
  */
 public class RegisteredResourceImpl implements RegisteredResource { 
 	private final String url;
+	private final String urlScheme;
 	private final String digest;
 	private final File dataFile;
 	private final String entity;
@@ -85,6 +86,7 @@
 	    
 	    try {
     		url = input.getUrl();
+    		urlScheme = getUrlScheme(url);
     		resourceType = computeResourceType(input.getExtension());
     		
     		if(resourceType == RegisteredResource.ResourceType.BUNDLE) {
@@ -306,4 +308,16 @@
             		new Version(m.getMainAttributes().getValue(Constants.BUNDLE_VERSION)));
         }
     }
+    
+    static String getUrlScheme(String url) {
+        final int pos = url.indexOf(':');
+        if(pos <= 0) {
+            throw new IllegalArgumentException("URL does not contain (or starts with) scheme separator ':': " + url);
+        }
+        return url.substring(0, pos);
+    }
+    
+    public String getUrlScheme() {
+        return urlScheme;
+    }
 }
\ No newline at end of file

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=806168&r1=806167&r2=806168&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 Thu Aug 20 13:42:10 2009
@@ -55,6 +55,8 @@
             throw new IllegalStateException("Bundle to update (" + symbolicName + ") not found");
         }
         if(b.getState() == Bundle.ACTIVE) {
+            // bundle was active before the update - restart it once updated, but
+            // in sequence, not right now
             ctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId()));
         }
         b.stop();

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java Thu Aug 20 13:42:10 2009
@@ -74,6 +74,10 @@
 	public String getURL() {
 		return null;
 	}
+	
+    public String getUrlScheme() {
+        return null;
+    }
 
     public boolean isInstallable() {
         return installable;

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Thu Aug 20 13:42:10 2009
@@ -38,6 +38,8 @@
 
 public class RegisteredResourceTest {
 	
+    public static final String TEST_URL = "test:url";
+    
     static File getTestBundle(String name) {
         return new File(System.getProperty("osgi.installer.base.dir"),
                 "org.apache.sling.osgi.installer-" + System.getProperty("osgi.installer.pom.version") + "-" + name);
@@ -62,7 +64,7 @@
 		}
 		
 		final TestInputStream t = new TestInputStream(new ByteArrayInputStream(data.getBytes()));
-		final InstallableResource ir = new InstallableResource(data, t, "somedigest");
+		final InstallableResource ir = new InstallableResource(TEST_URL, t, "somedigest");
 		assertEquals("TestInputStream must not be closed before test", 0, t.closeCount);
 		new LocalFileRegisteredResource(ir);
 		assertEquals("TestInputStream must be closed by RegisteredResource", 1, t.closeCount);
@@ -71,19 +73,19 @@
     @org.junit.Test public void testResourceType() throws Exception {
         {
             final InputStream s = new ByteArrayInputStream("Some data".getBytes());
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("1.jar", s, "some digest"));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, "some digest"));
             assertEquals(".jar URL creates a BUNDLE resource", 
                     RegisteredResource.ResourceType.BUNDLE, r.getResourceType());
             final InputStream rs = r.getInputStream();
             assertNotNull("BUNDLE resource provides an InputStream", rs);
             rs.close();
             assertNull("BUNDLE resource does not provide a Dictionary", r.getDictionary());
-            assertEquals("RegisteredResource entity ID must match", "jar:1.jar", r.getEntityId());
+            assertEquals("RegisteredResource entity ID must match", "jar:test:1.jar", r.getEntityId());
         }
         
         {
             final InputStream s = new ByteArrayInputStream("foo=bar\nother=2".getBytes());
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("1.properties", s, null));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.properties", s, null));
             assertEquals(".properties URL creates a CONFIG resource", 
                     RegisteredResource.ResourceType.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream();
@@ -97,7 +99,7 @@
             final Hashtable<String, Object> data = new Hashtable<String, Object>();
             data.put("foo", "bar");
             data.put("other", 2);
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("1", data));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1", data));
             assertEquals("No-extension URL with Dictionary creates a CONFIG resource", 
                     RegisteredResource.ResourceType.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream();
@@ -111,7 +113,7 @@
 	@org.junit.Test public void testLocalFileCopy() throws Exception {
 		final String data = "This is some data";
 		final InputStream in = new ByteArrayInputStream(data.getBytes());
-		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("1.jar", in, "somedigest"));
+		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, "somedigest"));
 		assertTrue("Local file exists", r.getDataFile(null).exists());
 		assertEquals("Local file length matches our data", data.getBytes().length, r.getDataFile(null).length());
 	}
@@ -121,13 +123,13 @@
         final InputStream in = new ByteArrayInputStream(data.getBytes());
         
         try {
-            new LocalFileRegisteredResource(new InstallableResource("1.jar", in, null));
+            new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, null));
             fail("With jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
         
         try {
-            new LocalFileRegisteredResource(new InstallableResource("1.foo", in, null));
+            new LocalFileRegisteredResource(new InstallableResource("test:1.foo", in, null));
         } catch(IllegalArgumentException asExpected) {
             fail("With non-jar extension, did not expect an IllegalArgumentException if digest is null");
         }
@@ -145,8 +147,8 @@
             d2.put(keys[i], keys[i] + "." + keys[i]);
         }
         
-        final RegisteredResource r1 = new RegisteredResourceImpl(null, new InstallableResource("url1", d1));
-        final RegisteredResource r2 = new RegisteredResourceImpl(null, new InstallableResource("url1", d2));
+        final RegisteredResource r1 = new RegisteredResourceImpl(null, new InstallableResource("test:url1", d1));
+        final RegisteredResource r2 = new RegisteredResourceImpl(null, new InstallableResource("test:url1", d2));
         
         assertEquals(
                 "Two RegisteredResource (Dictionary) with same values but different key orderings must have the same key", 
@@ -162,8 +164,8 @@
         final ByteArrayInputStream s1 = new ByteArrayInputStream(d1.getBytes());
         final ByteArrayInputStream s2 = new ByteArrayInputStream(d2.getBytes());
         
-        final RegisteredResource r1 = new RegisteredResourceImpl(null, new InstallableResource("url1.properties", s1, null));
-        final RegisteredResource r2 = new RegisteredResourceImpl(null, new InstallableResource("url2.properties", s2, null));
+        final RegisteredResource r1 = new RegisteredResourceImpl(null, new InstallableResource("test:url1.properties", s1, null));
+        final RegisteredResource r2 = new RegisteredResourceImpl(null, new InstallableResource("test:url2.properties", s2, null));
         
         assertEquals(
                 "Two RegisteredResource (InputStream) with same values but different key orderings must have the same key", 
@@ -174,16 +176,47 @@
     
     @org.junit.Test public void testBundleManifest() throws Exception {
         final File f = getTestBundle("testbundle-1.0.jar");
-        final InstallableResource i = new InstallableResource(f.getAbsolutePath(), new FileInputStream(f), f.getName());
+        final InstallableResource i = new InstallableResource("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNotNull("RegisteredResource must have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
     }
     
     @org.junit.Test public void testConfigEntity() throws Exception {
-        final InstallableResource i = new InstallableResource("/foo/someconfig", new Hashtable<String, Object>());
+        final InstallableResource i = new InstallableResource("test:/foo/someconfig", new Hashtable<String, Object>());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNull("RegisteredResource must not have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
     }
+    
+    @org.junit.Test public void testUrlScheme() throws Exception {
+        final ByteArrayInputStream s = new ByteArrayInputStream("foo".getBytes());
+        
+
+        final String [] badOnes = {
+                "",
+                ":colonTooEarly",
+                ":colonTooEarlyAgain:",
+                "noColon"
+        };
+        for(String url : badOnes) {
+            try {
+                new RegisteredResourceImpl(null, new InstallableResource(url, s, null));
+                fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
+            } catch(IllegalArgumentException asExpected) {
+            }
+        }
+        
+        final String [] goodOnes = {
+            "foo:bar",
+            "foo:bar:",
+            "foo::bar",
+            "foo://bar",
+        };
+        
+        for(String url : goodOnes) {
+            final RegisteredResource r = new RegisteredResourceImpl(null, new InstallableResource(url, s, null));
+            assertEquals("Expected scheme 'foo' for URL " + url, "foo", r.getUrlScheme());
+        }
+    }
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Thu Aug 20 13:42:10 2009
@@ -65,9 +65,9 @@
 	public void testBasicOrdering() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
-		    new BundleRemoveTask(getRegisteredResource("url")),
-		    new BundleUpdateTask(getRegisteredResource("url")),
-		    new BundleInstallTask(getRegisteredResource("url")),
+		    new BundleRemoveTask(getRegisteredResource("test:url")),
+		    new BundleUpdateTask(getRegisteredResource("test:url")),
+		    new BundleInstallTask(getRegisteredResource("test:url")),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
@@ -113,8 +113,8 @@
 	public void testMultipleConfigAndBundles() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
-			new BundleInstallTask(getRegisteredResource("someURIa.nothing")),
-            new BundleInstallTask(getRegisteredResource("someURIb.nothing")),
+			new BundleInstallTask(getRegisteredResource("test:someURIa.nothing")),
+            new BundleInstallTask(getRegisteredResource("test:someURIb.nothing")),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
@@ -138,7 +138,7 @@
 	public void testMultipleRefreshAndStart() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
-		    new BundleRemoveTask(getRegisteredResource("url")),
+		    new BundleRemoveTask(getRegisteredResource("test:url")),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 			new BundleStartTask(1),

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java Thu Aug 20 13:42:10 2009
@@ -16,10 +16,8 @@
  */
 package org.apache.sling.osgi.installer.it;
 
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.junit.After;
@@ -62,9 +60,7 @@
             resetCounters();
             installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
             waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
-            final Bundle b = findBundle(needsB);
-            assertNotNull(needsB + " must be installed", b);
-            assertFalse(needsB + " must not be started, testB not present", b.getState() == Bundle.ACTIVE);
+            assertBundle(needsB + " must not be started, testB not present", needsB, null, Bundle.INSTALLED);
         }
         
        // now install testB -> needsB must start
@@ -73,9 +69,7 @@
             installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
             waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
             assertNotNull(testB + " must be installed", findBundle(testB));
-            final Bundle b = findBundle(needsB);
-            assertNotNull(needsB + " must still be installed", b);
-            assertTrue(needsB + " must be started now that testB is installed", b.getState() == Bundle.ACTIVE);
+            assertBundle(needsB + " must be started now that testB is installed", needsB, null, Bundle.ACTIVE);
         }
     }
 }
\ 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=806168&r1=806167&r2=806168&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 Thu Aug 20 13:42:10 2009
@@ -17,7 +17,6 @@
 package org.apache.sling.osgi.installer.it;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import org.apache.sling.osgi.installer.OsgiInstaller;
@@ -28,7 +27,6 @@
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 
 @RunWith(JUnit4TestRunner.class)
 public class BundleInstallUpgradeDowngradeTest extends OsgiInstallerTestBase {
@@ -51,7 +49,6 @@
 	@Test
     public void testInstallUpgradeDowngradeBundle() throws Exception {
     	final String symbolicName = "osgi-installer-testbundle";
-    	final String BUNDLE_VERSION = "Bundle-Version";
     	int testIndex = 0;
     	
     	assertNull("Test bundle must not be present before test", findBundle(symbolicName));
@@ -65,11 +62,8 @@
     	            getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
     	    // wait for two tasks: install and start
     	    waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
-    	    final Bundle b = findBundle(symbolicName);
-        	assertNotNull("Test bundle 1.1 must be found after waitForInstallerAction", b);
-        	bundleId = b.getBundleId();
-        	assertEquals("Installed bundle must be started", Bundle.ACTIVE, b.getState());
-        	assertEquals("Version must be 1.1", "1.1", b.getHeaders().get(BUNDLE_VERSION));
+    	    final Bundle b = assertBundle("After installing", symbolicName, "1.1", Bundle.ACTIVE);
+    	    bundleId = b.getBundleId();
     	}
     	
     	assertNoOsgiTasks("After test " + testIndex++);
@@ -81,10 +75,7 @@
                     getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
             // wait for two tasks: update (includes stop) and start
             waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
-        	final Bundle b = findBundle(symbolicName);
-        	assertNotNull("Test bundle 1.2 must be found after waitForInstallerAction", b);
-        	assertEquals("Installed bundle must be started", Bundle.ACTIVE, b.getState());
-        	assertEquals("Version must be 1.2 after update", "1.2", b.getHeaders().get(BUNDLE_VERSION));
+        	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());
     	}
 
@@ -98,10 +89,7 @@
             
             // wait for two cycles to make sure no updates happen
             waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
-            final Bundle b = findBundle(symbolicName);
-            assertNotNull("Test bundle 1.2 must still be found after waitForInstallerAction", b);
-            assertEquals("Installed bundle must be started", Bundle.ACTIVE, b.getState());
-            assertEquals("Version must be 1.2 after ignored downgrade", "1.2", b.getHeaders().get(BUNDLE_VERSION));
+            final Bundle b = assertBundle("After ignored downgrade", symbolicName, "1.2", Bundle.ACTIVE);
             assertEquals("Bundle ID must not change after ignored downgrade", bundleId, b.getBundleId());
         }
     	
@@ -135,11 +123,7 @@
                     getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
             // wait for two tasks: install and start
             waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
-            final Bundle b = findBundle(symbolicName);
-            assertNotNull("Reinstalled test bundle 1.1 must be found after waitForInstallerAction", b);
-            bundleId = b.getBundleId();
-            assertEquals("Reinstalled bundle must be started", Bundle.ACTIVE, b.getState());
-            assertEquals("Reinstalled bundle version must be 1.1", "1.1", b.getHeaders().get(Constants.BUNDLE_VERSION));
+            assertBundle("After reinstalling 1.1", symbolicName, "1.1", Bundle.ACTIVE);
         }
 
         assertNoOsgiTasks("After test " + testIndex++);

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java Thu Aug 20 13:42:10 2009
@@ -112,7 +112,8 @@
         resetCounters();
         installer.addResource(getInstallableResource(
                 getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest2"));
-        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
+        // update also generates a start task, as the bundle was started before
+        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
         
         // And no more OSGi tasks after that
         assertNoOsgiTasks("At end of test");

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java Thu Aug 20 13:42:10 2009
@@ -1,8 +1,6 @@
 package org.apache.sling.osgi.installer.it;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import org.apache.sling.osgi.installer.OsgiInstaller;
@@ -44,9 +42,7 @@
         final long nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
         installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
         waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
-        Bundle b = findBundle(needsB);
-        assertNotNull(needsB + " must be installed", b);
-        assertFalse(needsB + " must not be started, testB not present", b.getState() == Bundle.ACTIVE);
+        assertBundle(needsB + " must not be started, testB not present", needsB, null, Bundle.INSTALLED);
         
         // the bundle start task must be retried immediately
         // (== 3 tasks since last counters reset)

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java Thu Aug 20 13:42:10 2009
@@ -67,8 +67,8 @@
             b.stop();
         }
     	
-    	assertEquals("Bundle A must be started", Bundle.ACTIVE, findBundle("osgi-installer-testA").getState());
-    	assertEquals("Bundle B must be stopped", Bundle.RESOLVED, findBundle("osgi-installer-testB").getState());
+        assertBundle("Bundle A must be started", "osgi-installer-testA", null, Bundle.ACTIVE);
+        assertBundle("Bundle B must be stopped", "osgi-installer-testB", null, Bundle.RESOLVED);
     	
     	// Execute some OsgiController operations
         installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
@@ -91,7 +91,7 @@
         assertNull("testbundle must be gone at end of test", findBundle(symbolicName));
         
     	// Now check that bundles A and B have kept their states
-    	assertEquals("Bundle A must be started", Bundle.ACTIVE, findBundle("osgi-installer-testA").getState());
-    	assertEquals("Bundle B must be stopped", Bundle.RESOLVED, findBundle("osgi-installer-testB").getState());
+        assertBundle("Bundle A must still be started", "osgi-installer-testA", null, Bundle.ACTIVE);
+        assertBundle("Bundle B must still be stopped", "osgi-installer-testB", null, Bundle.RESOLVED);
     }
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java?rev=806168&r1=806167&r2=806168&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Thu Aug 20 13:42:10 2009
@@ -16,17 +16,17 @@
  */
 package org.apache.sling.osgi.installer.it;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import static org.ops4j.pax.exam.CoreOptions.felix;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.logProfile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -39,6 +39,7 @@
 import org.ops4j.pax.exam.Option;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceReference;
@@ -61,7 +62,7 @@
     @Inject
     protected BundleContext bundleContext;
     
-    public static final String URL_SCHEME = "OsgiInstallerTestBase://";
+    public static final String URL_SCHEME = "OsgiInstallerTest";
     
     @SuppressWarnings("unchecked")
 	protected <T> T getService(Class<T> clazz) {
@@ -163,6 +164,25 @@
     	return null;
     }
     
+    protected Bundle assertBundle(String info, String symbolicName, String version, int state) {
+        final Bundle b = findBundle(symbolicName);
+        if(info == null) {
+            info = "";
+        } else {
+            info += ": ";
+        }
+        assertNotNull(info + "Expected bundle " + symbolicName + " to be installed", b);
+        if(version != null) {
+            assertEquals(info + "Expected bundle " + symbolicName + " to be version " + version,
+                    version, b.getHeaders().get(Constants.BUNDLE_VERSION));
+        }
+        if(state >= 0) {
+            assertEquals(info + "Expected bundle " + symbolicName + " to be in state " + state,
+                    state, b.getState());
+        }
+        return b;
+    }
+    
     protected File getTestBundle(String bundleName) {
     	return new File(System.getProperty("osgi.installer.base.dir"), bundleName);
     }
@@ -172,7 +192,7 @@
     }
     
     protected InstallableResource getInstallableResource(File testBundle, String digest) throws IOException {
-        final String url = URL_SCHEME + testBundle.getAbsolutePath();
+        final String url = URL_SCHEME + ":" + testBundle.getAbsolutePath();
         if(digest == null) {
             digest = testBundle.getAbsolutePath() + testBundle.lastModified();
         }

Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java?rev=806168&view=auto
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java (added)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Thu Aug 20 13:42:10 2009
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.osgi.installer.it;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.OsgiInstaller;
+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.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+
+@RunWith(JUnit4TestRunner.class)
+/** Test the {@link OsgiInstaller.registerResources} method, which lets a client
+ *  supply a new list of resources.
+ */
+public class RegisterResourcesTest extends OsgiInstallerTestBase {
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        return defaultConfiguration();
+    }
+    
+    @Before
+    public void setUp() {
+        setupInstaller();
+    }
+    
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+    
+    @Test
+    public void initialRegistrationTest() throws IOException {
+        final List<InstallableResource> r = new ArrayList<InstallableResource>();
+        r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
+        r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
+        r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
+        r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+        
+        installer.registerResources(r, URL_SCHEME);
+        waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
+        
+        final String info = "After initial registration";
+        assertBundle(info, "osgi-installer-testB", "1.0", Bundle.ACTIVE);
+        assertBundle(info, "osgi-installer-needsB", "1.0", Bundle.ACTIVE);
+        assertBundle(info, "osgi-installer-testbundle", "1.2", Bundle.ACTIVE);
+    }
+    
+    @Test
+    public void removeAndReaddBundlesTest() throws IOException {
+        {
+            final List<InstallableResource> r = new ArrayList<InstallableResource>();
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
+            
+            installer.registerResources(r, URL_SCHEME);
+            waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
+            
+            final String info = "After initial registration";
+            assertBundle(info, "osgi-installer-testB", "1.0", Bundle.ACTIVE);
+            assertBundle(info, "osgi-installer-needsB", "1.0", Bundle.ACTIVE);
+            assertBundle(info, "osgi-installer-testbundle", "1.1", Bundle.ACTIVE);
+        }
+        
+        {
+            // Add test 1.2 in between, to make sure it disappears in next registerResources call
+            installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+            waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
+            assertBundle("After adding testbundle V1.2", "osgi-installer-testbundle", "1.2", Bundle.ACTIVE);
+        }
+        
+        {
+            // Simulate later registration where some bundles have disappeared
+            // the installer must mark them "not installable" and act accordingly
+            final List<InstallableResource> r = new ArrayList<InstallableResource>();
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
+            r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest1"));
+            
+            installer.registerResources(r, URL_SCHEME);
+            waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
+            
+            assertBundle("Snapshot bundle must be started", 
+                    "osgi-installer-snapshot-test", "1.0.0.SNAPSHOT", Bundle.ACTIVE);
+            assertNull("Bundle testB must be gone", findBundle("osgi-installer-testB"));
+            final Bundle b = assertBundle("Bundle needsB must still be present", 
+                    "osgi-installer-needsB", "1.0", -1);
+            final int state = b.getState();
+            assertFalse("Bundle needsB must be stopped as testB is gone (" + state + ")", Bundle.ACTIVE == state);
+            assertBundle("Testbundle must be back to 1.0 as 1.1 and 1.2 is gone", 
+                    "osgi-installer-testbundle", "1.0", Bundle.ACTIVE);
+        }
+        
+        {
+            // Re-add the missing bundles and recheck
+            installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
+            installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+            
+            waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 2);
+            
+            final String info = "After re-adding missing bundles";
+            assertBundle(info, "osgi-installer-testB", "1.0", Bundle.ACTIVE);
+            assertBundle(info, "osgi-installer-needsB", "1.0", Bundle.ACTIVE);
+            assertBundle(info, "osgi-installer-testbundle", "1.2", Bundle.ACTIVE);
+            assertBundle(info, "osgi-installer-snapshot-test", "1.0.0.SNAPSHOT", Bundle.ACTIVE);
+        }
+    }
+}

Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL