You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/12/16 07:52:01 UTC
[sling-org-apache-sling-jcr-contentloader] branch master updated: SLING-11001 for single file source path replace the target node (#11)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
The following commit(s) were added to refs/heads/master by this push:
new a34481e SLING-11001 for single file source path replace the target node (#11)
a34481e is described below
commit a34481e7b9cc55b4b680c0eed4d5ff7629d37b1b
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Dec 16 08:51:55 2021 +0100
SLING-11001 for single file source path replace the target node (#11)
Update mocking libraries to latest versions
---
pom.xml | 52 +++++++++++++---------
.../internal/BundleContentLoader.java | 10 +----
.../internal/BundleContentLoaderTest.java | 23 +++++++---
3 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/pom.xml b/pom.xml
index af14a2d..1c50016 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,14 @@
</reporting>
<dependencies>
+ <!-- this dependency must come first to make sure Oak 1.40.0 is used for testing and not older versions being provided by other dependencies (oak-api, oak-security-spi) -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
+ <version>3.1.2-1.40.0</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- OSGi -->
<dependency>
<groupId>org.osgi</groupId>
@@ -144,7 +152,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
- <version>2.3.0</version>
+ <version>2.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -167,9 +175,23 @@
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-api</artifactId>
+ <version>1.8.0</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-security-spi</artifactId>
<version>1.8.0</version>
+ <scope>provided</scope>
<optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -180,7 +202,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.osgi</artifactId>
- <version>2.3.0</version>
+ <version>2.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -192,13 +214,13 @@
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
- <version>2.12.1</version>
+ <version>2.16.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
- <version>2.12.1</version>
+ <version>2.16.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -245,7 +267,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.11.0</version>
+ <version>2.16.4</version>
<scope>provided</scope>
</dependency>
<!-- Apache Felix -->
@@ -282,20 +304,14 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <version>2.3.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
- <version>1.3.0</version>
+ <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
+ <version>3.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>2.2.12</version>
+ <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
+ <version>3.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -311,12 +327,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
- <version>2.1.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java
index 9881e52..71bd020 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java
@@ -367,14 +367,8 @@ public class BundleContentLoader extends BaseImportLoader {
log.info("install: No initial content entries at {} in bundle {}", path, bundle.getSymbolicName());
return;
}
- // we have a single file content, let's check if this has an content reader
- // extension
- for (String ext : contentCreator.getContentReaders().keySet()) {
- if (path.endsWith(ext)) {
-
- }
- }
- handleFile(path, bundle, processedEntries, configuration, parent, createdNodes, contentCreator);
+ // we have a single file content -> this should replace the target node fully, i.e. parent is one level above
+ handleFile(path, bundle, processedEntries, configuration, parent.getParent(), createdNodes, contentCreator);
return;
}
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoaderTest.java b/src/test/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoaderTest.java
index 4c8a58e..40b5a41 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoaderTest.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoaderTest.java
@@ -22,10 +22,9 @@ import static java.util.Collections.singletonMap;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.lang.annotation.Annotation;
@@ -52,11 +51,9 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.jcr.contentloader.internal.readers.JsonReader;
import org.apache.sling.jcr.contentloader.internal.readers.XmlReader;
import org.apache.sling.jcr.contentloader.internal.readers.ZipReader;
-import org.apache.sling.jcr.resource.internal.helper.JcrResourceUtil;
import org.apache.sling.testing.mock.osgi.MockBundle;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
-import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Ignore;
@@ -132,7 +129,7 @@ public class BundleContentLoaderTest {
AccessControlManager acMgr = session.getAccessControlManager();
AccessControlList acl = (AccessControlList)acMgr.getPolicies(path)[0];
AccessControlEntry[] aces = acl.getAccessControlEntries();
- MatcherAssert.assertThat(aces, Matchers.arrayContaining(expectedAces));
+ assertThat(aces, Matchers.arrayContaining(expectedAces));
}
@Test
@@ -186,6 +183,22 @@ public class BundleContentLoaderTest {
}
@Test
+ public void loadContentFromFilePathEntry() throws Exception {
+
+ BundleContentLoader contentLoader = new BundleContentLoader(bundleHelper, whiteboard, null);
+
+ Bundle mockBundle = newBundleWithInitialContent(context, "initial-content/i18n/en.json;path:=/apps/i18n/en");
+
+ contentLoader.registerBundle(context.resourceResolver().adaptTo(Session.class), mockBundle, false);
+
+ Resource imported = context.resourceResolver().getResource("/apps/i18n/en");
+
+ assertThat("Resource was not imported", imported, notNullValue());
+ assertEquals("i18n-message", imported.getValueMap().get("i18n-key"));
+ assertThat("sling:resourceType was not properly set", imported.getResourceType(), equalTo("sling:Folder"));
+ }
+
+ @Test
public void loadContentWithExcludes() throws Exception {
BundleContentLoader contentLoader = new BundleContentLoader(bundleHelper, whiteboard,