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:33:23 UTC
[sling-org-apache-sling-distribution-journal] branch master updated: SLING-10095 - Add negative test case (#93)
This is an automated email from the ASF dual-hosted git repository.
tmaret pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git
The following commit(s) were added to refs/heads/master by this push:
new db015df SLING-10095 - Add negative test case (#93)
db015df is described below
commit db015df33c16ab3fcc5de3531f4bb3dff87aa896
Author: Timothee Maret <tm...@apache.org>
AuthorDate: Fri Dec 17 23:33:17 2021 +0100
SLING-10095 - Add negative test case (#93)
---
.../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();