You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by tm...@apache.org on 2021/12/17 22:24:24 UTC

[sling-org-apache-sling-distribution-journal] branch SLING-10095-3 created (now 584b95a)

This is an automated email from the ASF dual-hosted git repository.

tmaret pushed a change to branch SLING-10095-3
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git.


      at 584b95a  SLING-10095 - Add negative test case

This branch includes the following new commits:

     new 584b95a  SLING-10095 - Add negative test case

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[sling-org-apache-sling-distribution-journal] 01/01: SLING-10095 - Add negative test case

Posted by tm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tmaret pushed a commit to branch SLING-10095-3
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git

commit 584b95a1702a82c2d44770b8d1654e6aa8be7b41
Author: tmaret <tm...@adobe.com>
AuthorDate: Fri Dec 17 23:24:08 2021 +0100

    SLING-10095 - Add negative test case
---
 .../journal/bookkeeper/ContentPackageExtractorTest.java    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/test/java/org/apache/sling/distribution/journal/bookkeeper/ContentPackageExtractorTest.java b/src/test/java/org/apache/sling/distribution/journal/bookkeeper/ContentPackageExtractorTest.java
index 5f6eaa2..ace5025 100644
--- a/src/test/java/org/apache/sling/distribution/journal/bookkeeper/ContentPackageExtractorTest.java
+++ b/src/test/java/org/apache/sling/distribution/journal/bookkeeper/ContentPackageExtractorTest.java
@@ -19,6 +19,7 @@
 package org.apache.sling.distribution.journal.bookkeeper;
 
 import static java.util.Collections.singletonList;
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -33,10 +34,12 @@ import javax.jcr.nodetype.NodeType;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.JcrPackageManager;
+import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.jackrabbit.vault.packaging.Packaging;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.common.DistributionException;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -135,6 +138,17 @@ public class ContentPackageExtractorTest {
         verify(pkg).install(Mockito.any(ImportOptions.class));
     }
 
+    @Test(expected = DistributionException.class)
+    public void testFailedInstall() throws Exception {
+
+        doThrow(new PackageException()).when(pkg)
+                .install(Mockito.any(ImportOptions.class));
+
+        Resource node = createImportedPackage();
+        ContentPackageExtractor extractor = new ContentPackageExtractor(packaging, PackageHandling.Install);
+        extractor.handle(resourceResolver, singletonList(node.getPath()));
+    }
+
 
     private Resource createImportedPackage() throws PersistenceException {
         Resource packages = createEtcPackages();