incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r695435 - in /incubator/sling/trunk/extensions/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
Date Mon, 15 Sep 2008 11:24:49 GMT
Author: bdelacretaz
Date: Mon Sep 15 04:24:48 2008
New Revision: 695435

URL: http://svn.apache.org/viewvc?rev=695435&view=rev
Log:
SLING-655 - failing to install a resource must not prevent other resources from being installed

Modified:
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java?rev=695435&r1=695434&r2=695435&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
Mon Sep 15 04:24:48 2008
@@ -157,7 +157,12 @@
                     log.debug("Node " + n.getPath() + " with name " + n.getName() + " ignored
due to " + filenameFilter);
         	    }
         	} else {
-        	    installOrUpdate(n.getPath(), dp.getInputStream(), dp.getLastModified());
+        		// a single failure must not block the whole thing (SLING-655)
+        		try {
+        			installOrUpdate(n.getPath(), dp.getInputStream(), dp.getLastModified());
+        		} catch(JcrInstallException jie) {
+        			log.warn("Failed to install bundle " + n.getPath(), jie);
+        		}
         	}
         }
     }

Modified: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java?rev=695435&r1=695434&r2=695435&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
Mon Sep 15 04:24:48 2008
@@ -27,6 +27,7 @@
 
 import org.apache.sling.commons.testing.jcr.RepositoryTestBase;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.jcrinstall.osgi.JcrInstallException;
 import org.apache.sling.jcr.jcrinstall.osgi.OsgiController;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -147,7 +148,6 @@
         final OsgiController c = mockery.mock(OsgiController.class);
         
         // Define the whole sequence of calls to OsgiController,
-        // Using getLastModified calls to mark the test phases
         mockery.checking(new Expectations() {{
             allowing(c).getInstalledUris(); will(returnValue(installedUri));
             allowing(c).getLastModified(with(any(String.class))); will(returnValue(-1L));

@@ -159,7 +159,7 @@
         final RepositoryObserver ro = new MockRepositoryObserver(repo, c);
         ro.activate(null);
         
-        // Add two files, run one cycle must install the bundles
+        // Add files, run one cycle must install the bundles
         for(String file : resources) {
             contentHelper.createOrUpdateFile(file, data, lastModifiedA);
         }
@@ -234,4 +234,40 @@
         ro.activate(null);
         mockery.assertIsSatisfied();
     }
+    
+    public void testMultipleResourcesWithException() throws Exception {
+        contentHelper.setupContent();
+        
+        final String [] resources = {
+                "/libs/foo/bar/install/dummy.jar",
+                "/libs/foo/bar/install/dummy.cfg",
+                "/libs/foo/bar/install/dummy.dp"
+        };
+        final InputStream data = new ByteArrayInputStream("hello".getBytes());
+        final long lastModifiedA = System.currentTimeMillis();
+        final Set<String> installedUri = new HashSet<String>();
+        final OsgiController c = mockery.mock(OsgiController.class);
+        
+        // Define the whole sequence of calls to OsgiController,
+        mockery.checking(new Expectations() {{
+            allowing(c).getInstalledUris(); will(returnValue(installedUri));
+            allowing(c).getLastModified(with(any(String.class))); will(returnValue(-1L));

+            one(c).installOrUpdate(with(equal(resources[0])), with(equal(lastModifiedA)),
with(any(InputStream.class)));
+            one(c).installOrUpdate(with(equal(resources[1])), with(equal(lastModifiedA)),
with(any(InputStream.class)));
+            will(throwException(new JcrInstallException("Fake BundleException for testing")));
+            one(c).installOrUpdate(with(equal(resources[2])), with(equal(lastModifiedA)),
with(any(InputStream.class)));
+        }});
+        
+        final RepositoryObserver ro = new MockRepositoryObserver(repo, c);
+        ro.activate(null);
+        
+        // Add files, run one cycle must install the bundles
+        for(String file : resources) {
+            contentHelper.createOrUpdateFile(file, data, lastModifiedA);
+        }
+        eventHelper.waitForEvents(5000L);
+        ro.runOneCycle();
+        
+        mockery.assertIsSatisfied();
+    }
 }
\ No newline at end of file



Mime
View raw message