You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2019/06/16 16:54:10 UTC

[sling-org-apache-sling-jcr-contentloader] branch master updated (a583f2c -> a68a251)

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

olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git.


    from a583f2c  SLING-7923 Simplify integration tests
     new e64ec79  style
     new a68a251  SLING-7923 Simplify integration tests

The 2 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.


Summary of changes:
 .../contentloader/it/BasicInitialContentIT.java    |  70 ++---
 .../contentloader/it/ContentloaderTestSupport.java | 111 ++++----
 .../jcr/contentloader/it/I18nInitialContentIT.java |  48 ++--
 .../contentloader/it/OrderedInitialContentIT.java  |  49 ++--
 .../it/SLING7268InitialContentIT.java              | 213 ++++++++--------
 .../it/SLING8118InitialContentIT.java              | 283 +++++++++++----------
 6 files changed, 407 insertions(+), 367 deletions(-)


[sling-org-apache-sling-jcr-contentloader] 02/02: SLING-7923 Simplify integration tests

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git

commit a68a251b606067f308af1400334b782d2ced3136
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Jun 16 18:52:20 2019 +0200

    SLING-7923 Simplify integration tests
    
    * Make initial content bundle an option
    * Use resource presence to wait for installed content
    * Move assertProperty to ContentloaderTestSupport
---
 .../contentloader/it/BasicInitialContentIT.java    |  42 +++++---
 .../contentloader/it/ContentloaderTestSupport.java | 111 ++++++++++-----------
 .../jcr/contentloader/it/I18nInitialContentIT.java |  34 ++++---
 .../contentloader/it/OrderedInitialContentIT.java  |  38 +++----
 .../it/SLING7268InitialContentIT.java              |  35 ++++---
 .../it/SLING8118InitialContentIT.java              |  35 ++++---
 6 files changed, 163 insertions(+), 132 deletions(-)

diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
index 03cea41..8e3c281 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
@@ -22,12 +22,15 @@ import java.io.IOException;
 
 import javax.jcr.RepositoryException;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimap;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
 import static org.junit.Assert.assertEquals;
@@ -41,47 +44,54 @@ import static org.junit.Assert.assertTrue;
 @ExamReactorStrategy(PerClass.class)
 public class BasicInitialContentIT extends ContentloaderTestSupport {
 
-    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "basic-content.json");
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "simple-folder/test1.txt");
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "folder-with-descriptor.json");
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "folder-with-descriptor/test2.txt");
-        return b;
+    @Configuration
+    public Option[] configuration() throws IOException {
+        final String header = DEFAULT_PATH_IN_BUNDLE + ";path:=" + CONTENT_ROOT_PATH;
+        final Multimap<String, String> content = ImmutableListMultimap.of(
+            DEFAULT_PATH_IN_BUNDLE, "basic-content.json",
+            DEFAULT_PATH_IN_BUNDLE, "simple-folder/test1.txt",
+            DEFAULT_PATH_IN_BUNDLE, "folder-with-descriptor.json",
+            DEFAULT_PATH_IN_BUNDLE, "folder-with-descriptor/test2.txt"
+        );
+        final Option bundle = buildInitialContentBundle(header, content);
+        return new Option[]{
+            baseConfiguration(),
+            bundle
+        };
     }
 
     @Test
     public void bundleStarted() {
-        final Bundle b = findBundle(bundleSymbolicName);
-        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+        final Bundle b = findBundle(BUNDLE_SYMBOLICNAME);
+        assertNotNull("Expecting bundle to be found:" + BUNDLE_SYMBOLICNAME, b);
+        assertEquals("Expecting bundle to be active:" + BUNDLE_SYMBOLICNAME, Bundle.ACTIVE, b.getState());
     }
 
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        final String testNodePath = contentRootPath + "/basic-content/test-node";
+        final String testNodePath = CONTENT_ROOT_PATH + "/basic-content/test-node";
         assertTrue("Expecting initial content to be installed", session.itemExists(testNodePath));
         assertEquals("Expecting foo=bar", "bar", session.getNode(testNodePath).getProperty("foo").getString());
     }
 
     @Test
     public void folderWithoutDescriptor() throws RepositoryException {
-        final String folderPath = contentRootPath + "/simple-folder";
+        final String folderPath = CONTENT_ROOT_PATH + "/simple-folder";
         assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
         assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
 
-        final String filePath = contentRootPath + "/simple-folder/test1.txt";
+        final String filePath = CONTENT_ROOT_PATH + "/simple-folder/test1.txt";
         assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
         assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName());
     }
 
     @Test
     public void folderWithDescriptor() throws RepositoryException {
-        final String folderPath = contentRootPath + "/folder-with-descriptor";
+        final String folderPath = CONTENT_ROOT_PATH + "/folder-with-descriptor";
         assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
         assertEquals("folder has node type 'sling:OrderedFolder'", "sling:OrderedFolder", session.getNode(folderPath).getPrimaryNodeType().getName());
 
-        final String filePath = contentRootPath + "/folder-with-descriptor/test2.txt";
+        final String filePath = CONTENT_ROOT_PATH + "/folder-with-descriptor/test2.txt";
         assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
         assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName());
     }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
index 830aef6..f8e8196 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
@@ -20,20 +20,22 @@ package org.apache.sling.jcr.contentloader.it;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
+import java.util.Map;
 
 import javax.inject.Inject;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import com.google.common.collect.Multimap;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.resource.presence.ResourcePresence;
 import org.apache.sling.testing.paxexam.SlingOptions;
 import org.apache.sling.testing.paxexam.TestSupport;
 import org.junit.After;
 import org.junit.Before;
-import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.options.ModifiableCompositeOption;
+import org.ops4j.pax.exam.util.Filter;
 import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
 import org.osgi.framework.Bundle;
@@ -44,12 +46,16 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
 import static org.apache.sling.testing.paxexam.SlingOptions.slingResourcePresence;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
 
 public abstract class ContentloaderTestSupport extends TestSupport {
 
@@ -61,77 +67,41 @@ public abstract class ContentloaderTestSupport extends TestSupport {
 
     protected Session session;
 
-    protected String bundleSymbolicName;
-
-    protected String contentRootPath;
-
     protected static final String SLING_INITIAL_CONTENT_HEADER = "Sling-Initial-Content";
 
+    protected static final String BUNDLE_SYMBOLICNAME = "TEST-CONTENT-BUNDLE";
+
     protected static final String DEFAULT_PATH_IN_BUNDLE = "test-initial-content";
 
+    protected static final String CONTENT_ROOT_PATH = "/test-content/" + BUNDLE_SYMBOLICNAME;
+
     private final Logger logger = LoggerFactory.getLogger(ContentloaderTestSupport.class);
 
     ContentloaderTestSupport() {
     }
 
-    @Before
-    public void setup() throws Exception {
-        bundleSymbolicName = "TEST-" + UUID.randomUUID();
-        contentRootPath = "/test-content/" + bundleSymbolicName;
-        session = repository.loginAdministrative(null);
-
-        assertFalse("Expecting no content before test", session.itemExists(contentRootPath));
-
-        // Create, install and start a bundle that has initial content
-        try (InputStream is = getTestBundleStream()) {
-            final Bundle bundle = bundleContext.installBundle(bundleSymbolicName, is);
-            bundle.start();
-        }
-
-        // stabilize the downstream assertions by waiting a moment for the background content loading
-        // to be processed.  Retry the checking a few times (if necessary) since the timing is tricky.
-        String contentLoadedPath = String.format("/var/sling/bundle-content/%s", bundleSymbolicName);
-        long timeoutSeconds = 30;
-        long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutSeconds);
-        boolean retry = true;
-        do {
-            if (session.itemExists(contentLoadedPath)) {
-                //stop looping
-                retry = false;
-            } else {
-                if (System.currentTimeMillis() > timeout) {
-                    fail("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds: "
-                        + "A content loaded node expected at " + contentLoadedPath);
-                } else {
-                    logger.warn("Bundle content not loaded yet, retrying after a short delay, path={}", contentLoadedPath);
-                    Thread.sleep(200);
-                    session.refresh(false);
-                }
-            }
-        } while (retry);
-    }
-
-    @After
-    public void teardown() {
-        session.logout();
-    }
+    @Inject
+    @Filter(value = "(path=" + CONTENT_ROOT_PATH + ")")
+    private ResourcePresence resourcePresence;
 
-    @Configuration
-    public Option[] configuration() {
+    public ModifiableCompositeOption baseConfiguration() {
         final Option contentloader = mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.jcr.contentloader").version(SlingOptions.versionResolver.getVersion("org.apache.sling", "org.apache.sling.jcr.contentloader"));
         final ModifiableCompositeOption quickstart = quickstart().remove(contentloader);
-        return new Option[]{
+        return composite(
             super.baseConfiguration(),
             quickstart,
             // Sling JCR ContentLoader
             testBundle("bundle.filename"),
+            factoryConfiguration("org.apache.sling.resource.presence.internal.ResourcePresenter")
+                .put("path", CONTENT_ROOT_PATH)
+                .asOption(),
             // testing
             newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
                 .put("whitelist.bundles.regexp", "PAXEXAM-PROBE-.*")
                 .asOption(),
             slingResourcePresence(),
             junitBundles()
-        };
+        );
     }
 
     protected ModifiableCompositeOption quickstart() {
@@ -140,24 +110,39 @@ public abstract class ContentloaderTestSupport extends TestSupport {
         return slingQuickstartOakTar(workingDirectory, httpPort);
     }
 
-    private InputStream getTestBundleStream() throws Exception {
-        final TinyBundle bundle = TinyBundles.bundle().set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
-        return setupTestBundle(bundle).build(TinyBundles.withBnd());
+    @Before
+    public void setup() throws Exception {
+        session = repository.loginAdministrative(null);
     }
 
-    abstract protected TinyBundle setupTestBundle(TinyBundle b) throws Exception;
+    @After
+    public void teardown() {
+        session.logout();
+    }
 
     /**
      * Add content to our test bundle
      */
-    protected void addContent(TinyBundle b, String pathInBundle, String resourcePath) throws IOException {
+    protected void addContent(final TinyBundle bundle, String pathInBundle, String resourcePath) throws IOException {
         pathInBundle += "/" + resourcePath;
         resourcePath = "/initial-content/" + resourcePath;
         try (final InputStream is = getClass().getResourceAsStream(resourcePath)) {
             assertNotNull("Expecting resource to be found:" + resourcePath, is);
             logger.info("Adding resource to bundle, path={}, resource={}", pathInBundle, resourcePath);
-            b.add(pathInBundle, is);
+            bundle.add(pathInBundle, is);
+        }
+    }
+
+    protected Option buildInitialContentBundle(final String header, final Multimap<String, String> content) throws IOException {
+        final TinyBundle bundle = TinyBundles.bundle();
+        bundle.set(Constants.BUNDLE_SYMBOLICNAME, BUNDLE_SYMBOLICNAME);
+        bundle.set(SLING_INITIAL_CONTENT_HEADER, header);
+        for (final Map.Entry<String, String> entry : content.entries()) {
+            addContent(bundle, entry.getKey(), entry.getValue());
         }
+        return streamBundle(
+            bundle.build(withBnd())
+        ).start();
     }
 
     protected Bundle findBundle(final String symbolicName) {
@@ -169,4 +154,10 @@ public abstract class ContentloaderTestSupport extends TestSupport {
         return null;
     }
 
+    protected void assertProperty(final Session session, final String path, final String expected) throws RepositoryException {
+        assertTrue("Expecting property " + path, session.itemExists(path));
+        final String actual = session.getProperty(path).getString();
+        assertEquals("Expecting correct value at " + path, expected, actual);
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
index 2470f3f..72a62d2 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
@@ -24,12 +24,15 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimap;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
 import static org.junit.Assert.assertEquals;
@@ -38,29 +41,36 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 /**
- * Basic test of a bundle that provides initial content
+ * Basic test of a bundle that provides I18N initial content
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class I18nInitialContentIT extends ContentloaderTestSupport {
 
-    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";ignoreImportProviders:=json;path:=" + contentRootPath);
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json");
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json.xml");
-        return b;
+    @Configuration
+    public Option[] configuration() throws IOException {
+        final String header = DEFAULT_PATH_IN_BUNDLE + ";ignoreImportProviders:=json;path:=" + CONTENT_ROOT_PATH;
+        final Multimap<String, String> content = ImmutableListMultimap.of(
+            DEFAULT_PATH_IN_BUNDLE, "i18n/en.json",
+            DEFAULT_PATH_IN_BUNDLE, "i18n/en.json.xml"
+        );
+        final Option bundle = buildInitialContentBundle(header, content);
+        return new Option[]{
+            baseConfiguration(),
+            bundle
+        };
     }
 
     @Test
     public void bundleStarted() {
-        final Bundle b = findBundle(bundleSymbolicName);
-        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+        final Bundle b = findBundle(BUNDLE_SYMBOLICNAME);
+        assertNotNull("Expecting bundle to be found:" + BUNDLE_SYMBOLICNAME, b);
+        assertEquals("Expecting bundle to be active:" + BUNDLE_SYMBOLICNAME, Bundle.ACTIVE, b.getState());
     }
 
     @Test
     public void i18nJsonFile() throws RepositoryException {
-        final String filePath = contentRootPath + "/i18n/en.json";
+        final String filePath = CONTENT_ROOT_PATH + "/i18n/en.json";
         assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
         Node node = session.getNode(filePath);
         assertEquals("file has node type 'nt:file'", "nt:file", node.getPrimaryNodeType().getName());
@@ -74,7 +84,7 @@ public class I18nInitialContentIT extends ContentloaderTestSupport {
         assertTrue("file has mixin 'mix:language'", mixLanguageFound);
         assertEquals("file has property 'en'", "en", node.getProperty("jcr:language").getString());
 
-        final String descriptorPath = contentRootPath + "/i18n/en.json.xml";
+        final String descriptorPath = CONTENT_ROOT_PATH + "/i18n/en.json.xml";
         assertFalse("descriptor " + descriptorPath + " does not exists", session.itemExists(descriptorPath));
     }
 
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
index d310f4c..64e2ae7 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
@@ -21,19 +21,20 @@ package org.apache.sling.jcr.contentloader.it;
 import java.io.IOException;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimap;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 /**
  * Test the SLING-5682 ordered content loading
@@ -42,29 +43,30 @@ import static org.junit.Assert.assertTrue;
 @ExamReactorStrategy(PerClass.class)
 public class OrderedInitialContentIT extends ContentloaderTestSupport {
 
-    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "ordered-content.ordered-json");
-        return b;
+    @Configuration
+    public Option[] configuration() throws IOException {
+        final String header = DEFAULT_PATH_IN_BUNDLE + ";path:=" + CONTENT_ROOT_PATH;
+        final Multimap<String, String> content = ImmutableListMultimap.of(
+            DEFAULT_PATH_IN_BUNDLE, "ordered-content.ordered-json"
+        );
+        final Option bundle = buildInitialContentBundle(header, content);
+        return new Option[]{
+            baseConfiguration(),
+            bundle
+        };
     }
 
     @Test
     public void bundleStarted() {
-        final Bundle b = findBundle(bundleSymbolicName);
-        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
-    }
-
-    private void assertProperty(Session session, String path, String expected) throws RepositoryException {
-        assertTrue("Expecting property " + path, session.itemExists(path));
-        final String actual = session.getProperty(path).getString();
-        assertEquals("Expecting correct value at " + path, expected, actual);
+        final Bundle b = findBundle(BUNDLE_SYMBOLICNAME);
+        assertNotNull("Expecting bundle to be found:" + BUNDLE_SYMBOLICNAME, b);
+        assertEquals("Expecting bundle to be active:" + BUNDLE_SYMBOLICNAME, Bundle.ACTIVE, b.getState());
     }
 
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        assertProperty(session, contentRootPath + "/ordered-content/first/title", "This comes first");
-        assertProperty(session, contentRootPath + "/ordered-content/second/title", "This comes second");
+        assertProperty(session, CONTENT_ROOT_PATH + "/ordered-content/first/title", "This comes first");
+        assertProperty(session, CONTENT_ROOT_PATH + "/ordered-content/second/title", "This comes second");
     }
 
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
index fab11f2..ea4ba32 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
@@ -20,6 +20,7 @@ package org.apache.sling.jcr.contentloader.it;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -34,16 +35,19 @@ import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.Privilege;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimap;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.sling.jcr.base.util.AccessControlUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
 import static org.junit.Assert.assertEquals;
@@ -58,22 +62,29 @@ import static org.junit.Assert.assertTrue;
 @ExamReactorStrategy(PerClass.class)
 public class SLING7268InitialContentIT extends ContentloaderTestSupport {
 
-    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-7268.json");
-        return b;
+    @Configuration
+    public Option[] configuration() throws IOException {
+        final String header = DEFAULT_PATH_IN_BUNDLE + ";path:=" + CONTENT_ROOT_PATH;
+        final Multimap<String, String> content = ImmutableListMultimap.of(
+            DEFAULT_PATH_IN_BUNDLE, "SLING-7268.json"
+        );
+        final Option bundle = buildInitialContentBundle(header, content);
+        return new Option[]{
+            baseConfiguration(),
+            bundle
+        };
     }
 
     @Test
     public void bundleStarted() {
-        final Bundle b = findBundle(bundleSymbolicName);
-        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+        final Bundle b = findBundle(BUNDLE_SYMBOLICNAME);
+        assertNotNull("Expecting bundle to be found:" + BUNDLE_SYMBOLICNAME, b);
+        assertEquals("Expecting bundle to be active:" + BUNDLE_SYMBOLICNAME, Bundle.ACTIVE, b.getState());
     }
 
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        final String folderPath = contentRootPath + "/SLING-7268";
+        final String folderPath = CONTENT_ROOT_PATH + "/SLING-7268";
         assertTrue("Expecting initial content to be installed", session.itemExists(folderPath));
         assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
     }
@@ -99,7 +110,7 @@ public class SLING7268InitialContentIT extends ContentloaderTestSupport {
 
     @Test
     public void aceCreated() throws RepositoryException {
-        final String folderPath = contentRootPath + "/SLING-7268";
+        final String folderPath = CONTENT_ROOT_PATH + "/SLING-7268";
         assertTrue("Expecting test folder to exist", session.itemExists(folderPath));
 
         AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
@@ -108,9 +119,7 @@ public class SLING7268InitialContentIT extends ContentloaderTestSupport {
         for (AccessControlPolicy accessControlPolicy : policies) {
             if (accessControlPolicy instanceof AccessControlList) {
                 AccessControlEntry[] accessControlEntries = ((AccessControlList) accessControlPolicy).getAccessControlEntries();
-                for (AccessControlEntry accessControlEntry : accessControlEntries) {
-                    allEntries.add(accessControlEntry);
-                }
+                allEntries.addAll(Arrays.asList(accessControlEntries));
             }
         }
         assertEquals(3, allEntries.size());
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
index 1fe5f4f..12c96db 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
@@ -20,6 +20,7 @@ package org.apache.sling.jcr.contentloader.it;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -35,6 +36,8 @@ import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.Privilege;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Multimap;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
@@ -42,10 +45,11 @@ import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.sling.jcr.base.util.AccessControlUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
 import static org.junit.Assert.assertEquals;
@@ -59,22 +63,29 @@ import static org.junit.Assert.assertTrue;
 @ExamReactorStrategy(PerClass.class)
 public class SLING8118InitialContentIT extends ContentloaderTestSupport {
 
-    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-        addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-8118.json");
-        return b;
+    @Configuration
+    public Option[] configuration() throws IOException {
+        final String header = DEFAULT_PATH_IN_BUNDLE + ";path:=" + CONTENT_ROOT_PATH;
+        final Multimap<String, String> content = ImmutableListMultimap.of(
+            DEFAULT_PATH_IN_BUNDLE, "SLING-8118.json"
+        );
+        final Option bundle = buildInitialContentBundle(header, content);
+        return new Option[]{
+            baseConfiguration(),
+            bundle
+        };
     }
 
     @Test
     public void bundleStarted() {
-        final Bundle b = findBundle(bundleSymbolicName);
-        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+        final Bundle b = findBundle(BUNDLE_SYMBOLICNAME);
+        assertNotNull("Expecting bundle to be found:" + BUNDLE_SYMBOLICNAME, b);
+        assertEquals("Expecting bundle to be active:" + BUNDLE_SYMBOLICNAME, Bundle.ACTIVE, b.getState());
     }
 
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        final String folderPath = contentRootPath + "/SLING-8118";
+        final String folderPath = CONTENT_ROOT_PATH + "/SLING-8118";
         assertTrue("Expecting initial content to be installed", session.itemExists(folderPath));
         assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
     }
@@ -100,7 +111,7 @@ public class SLING8118InitialContentIT extends ContentloaderTestSupport {
 
     @Test
     public void aceWithRestrictionsCreated() throws RepositoryException {
-        final String folderPath = contentRootPath + "/SLING-8118";
+        final String folderPath = CONTENT_ROOT_PATH + "/SLING-8118";
         assertTrue("Expecting test folder to exist", session.itemExists(folderPath));
 
         AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
@@ -109,9 +120,7 @@ public class SLING8118InitialContentIT extends ContentloaderTestSupport {
         for (AccessControlPolicy accessControlPolicy : policies) {
             if (accessControlPolicy instanceof AccessControlList) {
                 AccessControlEntry[] accessControlEntries = ((AccessControlList) accessControlPolicy).getAccessControlEntries();
-                for (AccessControlEntry accessControlEntry : accessControlEntries) {
-                    allEntries.add(accessControlEntry);
-                }
+                allEntries.addAll(Arrays.asList(accessControlEntries));
             }
         }
         assertEquals(3, allEntries.size());


[sling-org-apache-sling-jcr-contentloader] 01/02: style

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git

commit e64ec79d0160038e9811d82f72e31597218e4e04
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Jun 16 18:41:39 2019 +0200

    style
---
 .../contentloader/it/BasicInitialContentIT.java    |  38 +--
 .../contentloader/it/ContentloaderTestSupport.java |  26 +-
 .../jcr/contentloader/it/I18nInitialContentIT.java |  20 +-
 .../contentloader/it/OrderedInitialContentIT.java  |  17 +-
 .../it/SLING7268InitialContentIT.java              | 202 +++++++--------
 .../it/SLING8118InitialContentIT.java              | 272 ++++++++++-----------
 6 files changed, 292 insertions(+), 283 deletions(-)

diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
index 5dbd02c..03cea41 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
@@ -34,7 +34,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-/** Basic test of a bundle that provides initial content */
+/**
+ * Basic test of a bundle that provides initial content
+ */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class BasicInitialContentIT extends ContentloaderTestSupport {
@@ -47,41 +49,41 @@ public class BasicInitialContentIT extends ContentloaderTestSupport {
         addContent(b, DEFAULT_PATH_IN_BUNDLE, "folder-with-descriptor/test2.txt");
         return b;
     }
-    
+
     @Test
     public void bundleStarted() {
         final Bundle b = findBundle(bundleSymbolicName);
         assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
         assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
     }
-    
+
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        final String testNodePath = contentRootPath + "/basic-content/test-node"; 
-        assertTrue("Expecting initial content to be installed", session.itemExists(testNodePath)); 
-        assertEquals("Expecting foo=bar", "bar", session.getNode(testNodePath).getProperty("foo").getString()); 
+        final String testNodePath = contentRootPath + "/basic-content/test-node";
+        assertTrue("Expecting initial content to be installed", session.itemExists(testNodePath));
+        assertEquals("Expecting foo=bar", "bar", session.getNode(testNodePath).getProperty("foo").getString());
     }
 
     @Test
     public void folderWithoutDescriptor() throws RepositoryException {
-        final String folderPath = contentRootPath + "/simple-folder"; 
-        assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath)); 
-        assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName()); 
+        final String folderPath = contentRootPath + "/simple-folder";
+        assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
+        assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
 
-        final String filePath = contentRootPath + "/simple-folder/test1.txt"; 
-        assertTrue("file node " + filePath + " exists", session.itemExists(filePath)); 
-        assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName()); 
+        final String filePath = contentRootPath + "/simple-folder/test1.txt";
+        assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
+        assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName());
     }
 
     @Test
     public void folderWithDescriptor() throws RepositoryException {
-        final String folderPath = contentRootPath + "/folder-with-descriptor"; 
-        assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath)); 
-        assertEquals("folder has node type 'sling:OrderedFolder'", "sling:OrderedFolder", session.getNode(folderPath).getPrimaryNodeType().getName()); 
+        final String folderPath = contentRootPath + "/folder-with-descriptor";
+        assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
+        assertEquals("folder has node type 'sling:OrderedFolder'", "sling:OrderedFolder", session.getNode(folderPath).getPrimaryNodeType().getName());
 
-        final String filePath = contentRootPath + "/folder-with-descriptor/test2.txt"; 
-        assertTrue("file node " + filePath + " exists", session.itemExists(filePath)); 
-        assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName()); 
+        final String filePath = contentRootPath + "/folder-with-descriptor/test2.txt";
+        assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
+        assertEquals("file has node type 'nt:file'", "nt:file", session.getNode(filePath).getPrimaryNodeType().getName());
     }
 
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
index 5ae7659..830aef6 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
@@ -87,28 +87,28 @@ public abstract class ContentloaderTestSupport extends TestSupport {
             final Bundle bundle = bundleContext.installBundle(bundleSymbolicName, is);
             bundle.start();
         }
-        
-		// stabilize the downstream assertions by waiting a moment for the background content loading 
+
+        // stabilize the downstream assertions by waiting a moment for the background content loading
         // to be processed.  Retry the checking a few times (if necessary) since the timing is tricky.
         String contentLoadedPath = String.format("/var/sling/bundle-content/%s", bundleSymbolicName);
         long timeoutSeconds = 30;
         long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutSeconds);
         boolean retry = true;
         do {
-        	if (session.itemExists(contentLoadedPath)) {
-        		//stop looping
-        		retry = false;
-        	} else {
-        		if (System.currentTimeMillis() > timeout) {
-			        fail("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds: " 
-			                + "A content loaded node expected at " + contentLoadedPath);
-        		} else {
+            if (session.itemExists(contentLoadedPath)) {
+                //stop looping
+                retry = false;
+            } else {
+                if (System.currentTimeMillis() > timeout) {
+                    fail("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds: "
+                        + "A content loaded node expected at " + contentLoadedPath);
+                } else {
                     logger.warn("Bundle content not loaded yet, retrying after a short delay, path={}", contentLoadedPath);
                     Thread.sleep(200);
                     session.refresh(false);
-        		}        		
-        	}
-        } while (retry);        
+                }
+            }
+        } while (retry);
     }
 
     @After
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
index 2d8238c..2470f3f 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
@@ -37,7 +37,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-/** Basic test of a bundle that provides initial content */
+/**
+ * Basic test of a bundle that provides initial content
+ */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class I18nInitialContentIT extends ContentloaderTestSupport {
@@ -48,32 +50,32 @@ public class I18nInitialContentIT extends ContentloaderTestSupport {
         addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json.xml");
         return b;
     }
-    
+
     @Test
     public void bundleStarted() {
         final Bundle b = findBundle(bundleSymbolicName);
         assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
         assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
     }
-    
+
     @Test
     public void i18nJsonFile() throws RepositoryException {
-        final String filePath = contentRootPath + "/i18n/en.json"; 
-        assertTrue("file node " + filePath + " exists", session.itemExists(filePath)); 
+        final String filePath = contentRootPath + "/i18n/en.json";
+        assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
         Node node = session.getNode(filePath);
         assertEquals("file has node type 'nt:file'", "nt:file", node.getPrimaryNodeType().getName());
-        
+
         boolean mixLanguageFound = false;
         for (NodeType mixin : node.getMixinNodeTypes()) {
             if ("mix:language".equals(mixin.getName())) {
                 mixLanguageFound = true;
             }
         }
-        assertTrue("file has mixin 'mix:language'", mixLanguageFound); 
+        assertTrue("file has mixin 'mix:language'", mixLanguageFound);
         assertEquals("file has property 'en'", "en", node.getProperty("jcr:language").getString());
 
-        final String descriptorPath = contentRootPath + "/i18n/en.json.xml"; 
-        assertFalse("descriptor " + descriptorPath + " does not exists", session.itemExists(descriptorPath)); 
+        final String descriptorPath = contentRootPath + "/i18n/en.json.xml";
+        assertFalse("descriptor " + descriptorPath + " does not exists", session.itemExists(descriptorPath));
     }
 
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
index 268fc74..d310f4c 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
@@ -35,7 +35,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-/** Test the SLING-5682 ordered content loading */
+/**
+ * Test the SLING-5682 ordered content loading
+ */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class OrderedInitialContentIT extends ContentloaderTestSupport {
@@ -45,23 +47,24 @@ public class OrderedInitialContentIT extends ContentloaderTestSupport {
         addContent(b, DEFAULT_PATH_IN_BUNDLE, "ordered-content.ordered-json");
         return b;
     }
-    
+
     @Test
     public void bundleStarted() {
         final Bundle b = findBundle(bundleSymbolicName);
         assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
         assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
     }
-    
+
     private void assertProperty(Session session, String path, String expected) throws RepositoryException {
         assertTrue("Expecting property " + path, session.itemExists(path));
         final String actual = session.getProperty(path).getString();
         assertEquals("Expecting correct value at " + path, expected, actual);
     }
-    
+
     @Test
     public void initialContentInstalled() throws RepositoryException {
-        assertProperty(session, contentRootPath + "/ordered-content/first/title", "This comes first"); 
-        assertProperty(session, contentRootPath + "/ordered-content/second/title", "This comes second"); 
+        assertProperty(session, contentRootPath + "/ordered-content/first/title", "This comes first");
+        assertProperty(session, contentRootPath + "/ordered-content/second/title", "This comes second");
     }
-}
\ No newline at end of file
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
index 164c3af..fab11f2 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
@@ -50,109 +50,111 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-/** test of a bundle that provides initial content that creates a user/group and defines an ace 
- *  for those principals within the same transaction 
+/**
+ * test of a bundle that provides initial content that creates a user/group and defines an ace
+ * for those principals within the same transaction
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class SLING7268InitialContentIT extends ContentloaderTestSupport {
 
-	protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-		b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-		addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-7268.json");
-		return b;
-	}
-
-	@Test
-	public void bundleStarted() {
-		final Bundle b = findBundle(bundleSymbolicName);
-		assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-		assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
-	}
-
-	@Test
-	public void initialContentInstalled() throws RepositoryException {
-		final String folderPath = contentRootPath + "/SLING-7268"; 
-		assertTrue("Expecting initial content to be installed", session.itemExists(folderPath)); 
-		assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName()); 
-	}
-
-	@Test
-	public void userCreated() throws RepositoryException {
-		UserManager userManager = AccessControlUtil.getUserManager(session);
-		Authorizable authorizable = userManager.getAuthorizable("sling7268_user");
-		assertNotNull("Expecting test user to exist", authorizable);
-	}
-
-	@Test
-	public void groupCreated() throws RepositoryException {
-		UserManager userManager = AccessControlUtil.getUserManager(session);
-		Authorizable authorizable = userManager.getAuthorizable("sling7268_group");
-		assertNotNull("Expecting test group to exist", authorizable);
-		assertTrue(authorizable instanceof Group);
-		Iterator<Authorizable> members = ((Group)authorizable).getMembers();
-		assertTrue(members.hasNext());
-		Authorizable firstMember = members.next();
-		assertEquals("sling7268_user", firstMember.getID());
-	}
-
-	@Test
-	public void aceCreated() throws RepositoryException {
-		final String folderPath = contentRootPath + "/SLING-7268"; 
-		assertTrue("Expecting test folder to exist", session.itemExists(folderPath)); 
-
-		AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
-		AccessControlPolicy[] policies = accessControlManager.getPolicies(folderPath);
-		List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>(); 
-		for (AccessControlPolicy accessControlPolicy : policies) {
-			if (accessControlPolicy instanceof AccessControlList) {
-				AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
-				for (AccessControlEntry accessControlEntry : accessControlEntries) {
-					allEntries.add(accessControlEntry);
-				}
-			}
-		}
-		assertEquals(3, allEntries.size());
-		Map<String, AccessControlEntry> aceMap = new HashMap<>();
-		for (AccessControlEntry accessControlEntry : allEntries) {
-			aceMap.put(accessControlEntry.getPrincipal().getName(), accessControlEntry);
-		}
-
-		//check ACE for sling7268_user
-		AccessControlEntry testUserAce = aceMap.get("sling7268_user");
-		assertNotNull("Expected ACE for test user", testUserAce);
-		assertEquals("sling7268_user", testUserAce.getPrincipal().getName());
-		Privilege[] privileges = testUserAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(2, privileges.length);
-		Set<String> privilegeNames = new HashSet<>();
-		for (Privilege privilege : privileges) {
-			privilegeNames.add(privilege.getName());
-		}
-		assertTrue("Expecting granted read privilege", privilegeNames.contains("jcr:read"));
-		assertTrue("Expecting granted write privilege", privilegeNames.contains("jcr:write"));
-
-		//check ACE for sling7268_group
-		AccessControlEntry testGroupAce = aceMap.get("sling7268_group");
-		assertNotNull("Expected ACE for test user", testGroupAce);
-		assertEquals("sling7268_group", testGroupAce.getPrincipal().getName());
-		privileges = testGroupAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(1, privileges.length);
-		privilegeNames = new HashSet<>();
-		for (Privilege privilege : privileges) {
-			privilegeNames.add(privilege.getName());
-		}
-		assertTrue("Expecting granted modifyAccessControl privilege", privilegeNames.contains("jcr:modifyAccessControl"));
-
-		//check ACE for everyone group
-		AccessControlEntry everyoneAce = aceMap.get("everyone");
-		assertNotNull("Expected ACE for everyone", everyoneAce);
-		assertEquals("everyone", everyoneAce.getPrincipal().getName());
-		privileges = everyoneAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(1, privileges.length);
-
-		assertEquals("Expecting granted read privilege", "jcr:read", privileges[0].getName());
-	}
+    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
+        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
+        addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-7268.json");
+        return b;
+    }
+
+    @Test
+    public void bundleStarted() {
+        final Bundle b = findBundle(bundleSymbolicName);
+        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
+        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+    }
+
+    @Test
+    public void initialContentInstalled() throws RepositoryException {
+        final String folderPath = contentRootPath + "/SLING-7268";
+        assertTrue("Expecting initial content to be installed", session.itemExists(folderPath));
+        assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
+    }
+
+    @Test
+    public void userCreated() throws RepositoryException {
+        UserManager userManager = AccessControlUtil.getUserManager(session);
+        Authorizable authorizable = userManager.getAuthorizable("sling7268_user");
+        assertNotNull("Expecting test user to exist", authorizable);
+    }
+
+    @Test
+    public void groupCreated() throws RepositoryException {
+        UserManager userManager = AccessControlUtil.getUserManager(session);
+        Authorizable authorizable = userManager.getAuthorizable("sling7268_group");
+        assertNotNull("Expecting test group to exist", authorizable);
+        assertTrue(authorizable instanceof Group);
+        Iterator<Authorizable> members = ((Group) authorizable).getMembers();
+        assertTrue(members.hasNext());
+        Authorizable firstMember = members.next();
+        assertEquals("sling7268_user", firstMember.getID());
+    }
+
+    @Test
+    public void aceCreated() throws RepositoryException {
+        final String folderPath = contentRootPath + "/SLING-7268";
+        assertTrue("Expecting test folder to exist", session.itemExists(folderPath));
+
+        AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
+        AccessControlPolicy[] policies = accessControlManager.getPolicies(folderPath);
+        List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>();
+        for (AccessControlPolicy accessControlPolicy : policies) {
+            if (accessControlPolicy instanceof AccessControlList) {
+                AccessControlEntry[] accessControlEntries = ((AccessControlList) accessControlPolicy).getAccessControlEntries();
+                for (AccessControlEntry accessControlEntry : accessControlEntries) {
+                    allEntries.add(accessControlEntry);
+                }
+            }
+        }
+        assertEquals(3, allEntries.size());
+        Map<String, AccessControlEntry> aceMap = new HashMap<>();
+        for (AccessControlEntry accessControlEntry : allEntries) {
+            aceMap.put(accessControlEntry.getPrincipal().getName(), accessControlEntry);
+        }
+
+        //check ACE for sling7268_user
+        AccessControlEntry testUserAce = aceMap.get("sling7268_user");
+        assertNotNull("Expected ACE for test user", testUserAce);
+        assertEquals("sling7268_user", testUserAce.getPrincipal().getName());
+        Privilege[] privileges = testUserAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(2, privileges.length);
+        Set<String> privilegeNames = new HashSet<>();
+        for (Privilege privilege : privileges) {
+            privilegeNames.add(privilege.getName());
+        }
+        assertTrue("Expecting granted read privilege", privilegeNames.contains("jcr:read"));
+        assertTrue("Expecting granted write privilege", privilegeNames.contains("jcr:write"));
+
+        //check ACE for sling7268_group
+        AccessControlEntry testGroupAce = aceMap.get("sling7268_group");
+        assertNotNull("Expected ACE for test user", testGroupAce);
+        assertEquals("sling7268_group", testGroupAce.getPrincipal().getName());
+        privileges = testGroupAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(1, privileges.length);
+        privilegeNames = new HashSet<>();
+        for (Privilege privilege : privileges) {
+            privilegeNames.add(privilege.getName());
+        }
+        assertTrue("Expecting granted modifyAccessControl privilege", privilegeNames.contains("jcr:modifyAccessControl"));
+
+        //check ACE for everyone group
+        AccessControlEntry everyoneAce = aceMap.get("everyone");
+        assertNotNull("Expected ACE for everyone", everyoneAce);
+        assertEquals("everyone", everyoneAce.getPrincipal().getName());
+        privileges = everyoneAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(1, privileges.length);
+
+        assertEquals("Expecting granted read privilege", "jcr:read", privileges[0].getName());
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
index dd08ec4..1fe5f4f 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING8118InitialContentIT.java
@@ -18,10 +18,6 @@
  */
 package org.apache.sling.jcr.contentloader.it;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -52,142 +48,146 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.framework.Bundle;
 
-/** 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
  * test of a bundle that provides initial content that defines an ace with restrictions
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class SLING8118InitialContentIT extends ContentloaderTestSupport {
 
-	protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
-		b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
-		addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-8118.json");
-		return b;
-	}
-
-	@Test
-	public void bundleStarted() {
-		final Bundle b = findBundle(bundleSymbolicName);
-		assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
-		assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
-	}
-
-	@Test
-	public void initialContentInstalled() throws RepositoryException {
-		final String folderPath = contentRootPath + "/SLING-8118"; 
-		assertTrue("Expecting initial content to be installed", session.itemExists(folderPath)); 
-		assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName()); 
-	}
-
-	@Test
-	public void userCreated() throws RepositoryException {
-		UserManager userManager = AccessControlUtil.getUserManager(session);
-		Authorizable authorizable = userManager.getAuthorizable("sling8118_user");
-		assertNotNull("Expecting test user to exist", authorizable);
-	}
-
-	@Test
-	public void groupCreated() throws RepositoryException {
-		UserManager userManager = AccessControlUtil.getUserManager(session);
-		Authorizable authorizable = userManager.getAuthorizable("sling8118_group");
-		assertNotNull("Expecting test group to exist", authorizable);
-		assertTrue(authorizable instanceof Group);
-		Iterator<Authorizable> members = ((Group)authorizable).getMembers();
-		assertTrue(members.hasNext());
-		Authorizable firstMember = members.next();
-		assertEquals("sling8118_user", firstMember.getID());
-	}
-
-	@Test
-	public void aceWithRestrictionsCreated() throws RepositoryException {
-		final String folderPath = contentRootPath + "/SLING-8118"; 
-		assertTrue("Expecting test folder to exist", session.itemExists(folderPath)); 
-
-		AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
-		AccessControlPolicy[] policies = accessControlManager.getPolicies(folderPath);
-		List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>(); 
-		for (AccessControlPolicy accessControlPolicy : policies) {
-			if (accessControlPolicy instanceof AccessControlList) {
-				AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
-				for (AccessControlEntry accessControlEntry : accessControlEntries) {
-					allEntries.add(accessControlEntry);
-				}
-			}
-		}
-		assertEquals(3, allEntries.size());
-		Map<String, AccessControlEntry> aceMap = new HashMap<>();
-		for (AccessControlEntry accessControlEntry : allEntries) {
-			aceMap.put(accessControlEntry.getPrincipal().getName(), accessControlEntry);
-		}
-
-		//check ACE for sling8118_user
-		AccessControlEntry testUserAce = aceMap.get("sling8118_user");
-		assertNotNull("Expected ACE for test user", testUserAce);
-		assertEquals("sling8118_user", testUserAce.getPrincipal().getName());
-		Privilege[] privileges = testUserAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(2, privileges.length);
-		Set<String> privilegeNames = new HashSet<>();
-		for (Privilege privilege : privileges) {
-			privilegeNames.add(privilege.getName());
-		}
-		assertTrue("Expecting granted read privilege", privilegeNames.contains("jcr:read"));
-		assertTrue("Expecting granted write privilege", privilegeNames.contains("jcr:write"));
-
-		//check restrictions
-		assertTrue(testUserAce instanceof JackrabbitAccessControlEntry);
-		JackrabbitAccessControlEntry testUserJAce = (JackrabbitAccessControlEntry)testUserAce;
-		String[] testUserRestrictionNames = testUserJAce.getRestrictionNames();
-		assertNotNull(testUserRestrictionNames);
-		assertEquals(1, testUserRestrictionNames.length);
-		assertEquals("rep:glob", testUserRestrictionNames[0]);
-		Value globRestriction = testUserJAce.getRestriction("rep:glob");
-		assertNotNull(globRestriction);
-		assertEquals("glob1", globRestriction.getString());
-		
-		//check ACE for sling8118_group
-		AccessControlEntry testGroupAce = aceMap.get("sling8118_group");
-		assertNotNull("Expected ACE for test user", testGroupAce);
-		assertEquals("sling8118_group", testGroupAce.getPrincipal().getName());
-		privileges = testGroupAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(1, privileges.length);
-		privilegeNames = new HashSet<>();
-		for (Privilege privilege : privileges) {
-			privilegeNames.add(privilege.getName());
-		}
-		assertTrue("Expecting granted modifyAccessControl privilege", privilegeNames.contains("jcr:modifyAccessControl"));
-
-		//check restrictions
-		assertTrue(testGroupAce instanceof JackrabbitAccessControlEntry);
-		JackrabbitAccessControlEntry testGroupJAce = (JackrabbitAccessControlEntry)testGroupAce;
-		String[] testGroupRestrictionNames = testGroupJAce.getRestrictionNames();
-		assertNotNull(testGroupRestrictionNames);
-		assertEquals(1, testGroupRestrictionNames.length);
-		assertEquals("rep:itemNames", testGroupRestrictionNames[0]);
-		Value[] restrictions = testGroupJAce.getRestrictions("rep:itemNames");
-		assertNotNull(restrictions);
-		assertEquals(2, restrictions.length);
-		assertEquals("name1", restrictions[0].getString());
-		assertEquals("name2", restrictions[1].getString());
-		
-		
-		
-		//check ACE for everyone group
-		AccessControlEntry everyoneAce = aceMap.get("everyone");
-		assertNotNull("Expected ACE for everyone", everyoneAce);
-		assertEquals("everyone", everyoneAce.getPrincipal().getName());
-		privileges = everyoneAce.getPrivileges();
-		assertNotNull(privileges);
-		assertEquals(1, privileges.length);
-
-		assertEquals("Expecting granted read privilege", "jcr:read", privileges[0].getName());
-
-		//check restrictions
-		assertTrue(everyoneAce instanceof JackrabbitAccessControlEntry);
-		JackrabbitAccessControlEntry everyoneJAce = (JackrabbitAccessControlEntry)everyoneAce;
-		String[] everyoneRestrictionNames = everyoneJAce.getRestrictionNames();
-		assertNotNull(everyoneRestrictionNames);
-		assertEquals(0, everyoneRestrictionNames.length);
-	}
+    protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
+        b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
+        addContent(b, DEFAULT_PATH_IN_BUNDLE, "SLING-8118.json");
+        return b;
+    }
+
+    @Test
+    public void bundleStarted() {
+        final Bundle b = findBundle(bundleSymbolicName);
+        assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
+        assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
+    }
+
+    @Test
+    public void initialContentInstalled() throws RepositoryException {
+        final String folderPath = contentRootPath + "/SLING-8118";
+        assertTrue("Expecting initial content to be installed", session.itemExists(folderPath));
+        assertEquals("folder has node type 'sling:Folder'", "sling:Folder", session.getNode(folderPath).getPrimaryNodeType().getName());
+    }
+
+    @Test
+    public void userCreated() throws RepositoryException {
+        UserManager userManager = AccessControlUtil.getUserManager(session);
+        Authorizable authorizable = userManager.getAuthorizable("sling8118_user");
+        assertNotNull("Expecting test user to exist", authorizable);
+    }
+
+    @Test
+    public void groupCreated() throws RepositoryException {
+        UserManager userManager = AccessControlUtil.getUserManager(session);
+        Authorizable authorizable = userManager.getAuthorizable("sling8118_group");
+        assertNotNull("Expecting test group to exist", authorizable);
+        assertTrue(authorizable instanceof Group);
+        Iterator<Authorizable> members = ((Group) authorizable).getMembers();
+        assertTrue(members.hasNext());
+        Authorizable firstMember = members.next();
+        assertEquals("sling8118_user", firstMember.getID());
+    }
+
+    @Test
+    public void aceWithRestrictionsCreated() throws RepositoryException {
+        final String folderPath = contentRootPath + "/SLING-8118";
+        assertTrue("Expecting test folder to exist", session.itemExists(folderPath));
+
+        AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
+        AccessControlPolicy[] policies = accessControlManager.getPolicies(folderPath);
+        List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>();
+        for (AccessControlPolicy accessControlPolicy : policies) {
+            if (accessControlPolicy instanceof AccessControlList) {
+                AccessControlEntry[] accessControlEntries = ((AccessControlList) accessControlPolicy).getAccessControlEntries();
+                for (AccessControlEntry accessControlEntry : accessControlEntries) {
+                    allEntries.add(accessControlEntry);
+                }
+            }
+        }
+        assertEquals(3, allEntries.size());
+        Map<String, AccessControlEntry> aceMap = new HashMap<>();
+        for (AccessControlEntry accessControlEntry : allEntries) {
+            aceMap.put(accessControlEntry.getPrincipal().getName(), accessControlEntry);
+        }
+
+        //check ACE for sling8118_user
+        AccessControlEntry testUserAce = aceMap.get("sling8118_user");
+        assertNotNull("Expected ACE for test user", testUserAce);
+        assertEquals("sling8118_user", testUserAce.getPrincipal().getName());
+        Privilege[] privileges = testUserAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(2, privileges.length);
+        Set<String> privilegeNames = new HashSet<>();
+        for (Privilege privilege : privileges) {
+            privilegeNames.add(privilege.getName());
+        }
+        assertTrue("Expecting granted read privilege", privilegeNames.contains("jcr:read"));
+        assertTrue("Expecting granted write privilege", privilegeNames.contains("jcr:write"));
+
+        //check restrictions
+        assertTrue(testUserAce instanceof JackrabbitAccessControlEntry);
+        JackrabbitAccessControlEntry testUserJAce = (JackrabbitAccessControlEntry) testUserAce;
+        String[] testUserRestrictionNames = testUserJAce.getRestrictionNames();
+        assertNotNull(testUserRestrictionNames);
+        assertEquals(1, testUserRestrictionNames.length);
+        assertEquals("rep:glob", testUserRestrictionNames[0]);
+        Value globRestriction = testUserJAce.getRestriction("rep:glob");
+        assertNotNull(globRestriction);
+        assertEquals("glob1", globRestriction.getString());
+
+        //check ACE for sling8118_group
+        AccessControlEntry testGroupAce = aceMap.get("sling8118_group");
+        assertNotNull("Expected ACE for test user", testGroupAce);
+        assertEquals("sling8118_group", testGroupAce.getPrincipal().getName());
+        privileges = testGroupAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(1, privileges.length);
+        privilegeNames = new HashSet<>();
+        for (Privilege privilege : privileges) {
+            privilegeNames.add(privilege.getName());
+        }
+        assertTrue("Expecting granted modifyAccessControl privilege", privilegeNames.contains("jcr:modifyAccessControl"));
+
+        //check restrictions
+        assertTrue(testGroupAce instanceof JackrabbitAccessControlEntry);
+        JackrabbitAccessControlEntry testGroupJAce = (JackrabbitAccessControlEntry) testGroupAce;
+        String[] testGroupRestrictionNames = testGroupJAce.getRestrictionNames();
+        assertNotNull(testGroupRestrictionNames);
+        assertEquals(1, testGroupRestrictionNames.length);
+        assertEquals("rep:itemNames", testGroupRestrictionNames[0]);
+        Value[] restrictions = testGroupJAce.getRestrictions("rep:itemNames");
+        assertNotNull(restrictions);
+        assertEquals(2, restrictions.length);
+        assertEquals("name1", restrictions[0].getString());
+        assertEquals("name2", restrictions[1].getString());
+
+
+        //check ACE for everyone group
+        AccessControlEntry everyoneAce = aceMap.get("everyone");
+        assertNotNull("Expected ACE for everyone", everyoneAce);
+        assertEquals("everyone", everyoneAce.getPrincipal().getName());
+        privileges = everyoneAce.getPrivileges();
+        assertNotNull(privileges);
+        assertEquals(1, privileges.length);
+
+        assertEquals("Expecting granted read privilege", "jcr:read", privileges[0].getName());
+
+        //check restrictions
+        assertTrue(everyoneAce instanceof JackrabbitAccessControlEntry);
+        JackrabbitAccessControlEntry everyoneJAce = (JackrabbitAccessControlEntry) everyoneAce;
+        String[] everyoneRestrictionNames = everyoneJAce.getRestrictionNames();
+        assertNotNull(everyoneRestrictionNames);
+        assertEquals(0, everyoneRestrictionNames.length);
+    }
+
 }