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

[sling-org-apache-sling-jcr-repoinit] 05/07: SLING-8740 - RepoInitTextIT passes with all tests enabled

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

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

commit 4c5eea1526efa108b33b9dfb496061478d26783f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Oct 31 16:17:27 2019 +0100

    SLING-8740 - RepoInitTextIT passes with all tests enabled
---
 .../sling/jcr/repoinit/it/RepoInitTestSupport.java | 53 ++++++++++++++++++++++
 .../sling/jcr/repoinit/it/RepoInitTextIT.java      | 53 ++++------------------
 2 files changed, 63 insertions(+), 43 deletions(-)

diff --git a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java
new file mode 100644
index 0000000..38f761a
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jcr.repoinit.it;
+
+import org.apache.sling.testing.paxexam.SlingOptions;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+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.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+
+public abstract class RepoInitTestSupport extends TestSupport {
+
+    @Configuration
+    public Option[] configuration() {
+        SlingOptions.versionResolver.setVersionFromProject("org.apache.jackrabbit", "jackrabbit-api");
+        return new Option[]{
+            baseConfiguration(),
+            slingQuickstart(),
+            testBundle("bundle.filename"),
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.repoinit.parser").versionAsInProject(),
+            junitBundles(),
+            newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
+                .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
+                .asOption(),        
+        };
+    }
+    
+    protected Option slingQuickstart() {
+        final String workingDirectory = workingDirectory();
+        final int httpPort = findFreePort();
+        return composite(
+            slingQuickstartOakTar(workingDirectory, httpPort)
+        );
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
index 7ed20db..7127928 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
@@ -29,30 +29,21 @@ import javax.jcr.SimpleCredentials;
 
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.repoinit.JcrRepoInitOpsProcessor;
-import org.apache.sling.junit.rules.TeleporterRule;
 import org.apache.sling.repoinit.parser.RepoInitParser;
-import org.apache.sling.testing.paxexam.TestSupport;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 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 static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
-import static org.ops4j.pax.exam.CoreOptions.composite;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
 
 /** Basic integration test of the repoinit parser and execution
  *  services, reading statements from a text file.
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public class RepoInitTextIT extends TestSupport {
+public class RepoInitTextIT extends RepoInitTestSupport {
 
     private Session session;
     private static final String FRED_WILMA = "fredWilmaService";
@@ -63,27 +54,12 @@ public class RepoInitTextIT extends TestSupport {
     @Inject
     private SlingRepository repository;
 
-    @Configuration
-    public Option[] configuration() {
-        return new Option[]{
-            baseConfiguration(),
-            slingQuickstart(),
-            //testBundle("bundle.filename"),
-            junitBundles(),
-            newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
-                .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
-                .asOption(),        
-        };
-    }
-    
-    protected Option slingQuickstart() {
-        final String workingDirectory = workingDirectory();
-        final int httpPort = findFreePort();
-        return composite(
-            slingQuickstartOakTar(workingDirectory, httpPort)
-        );
-    }
-    
+    @Inject
+    private RepoInitParser parser;
+
+    @Inject
+    private JcrRepoInitOpsProcessor processor;
+
     @Before
     public void setup() throws Exception {
         session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
@@ -92,16 +68,14 @@ public class RepoInitTextIT extends TestSupport {
         final InputStream is = getClass().getResourceAsStream(REPO_INIT_FILE);
         assertNotNull("Expecting " + REPO_INIT_FILE, is);
         try {
-            //final RepoInitParser  parser = teleporter.getService(RepoInitParser.class);
-            //final JcrRepoInitOpsProcessor processor = teleporter.getService(JcrRepoInitOpsProcessor.class);
-            //processor.apply(session, parser.parse(new InputStreamReader(is, "UTF-8")));
-            //session.save();
+            processor.apply(session, parser.parse(new InputStreamReader(is, "UTF-8")));
+            session.save();
         } finally {
             is.close();
         }
 
         // The repoinit file causes those nodes to be created
-        //assertTrue("Expecting test nodes to be created", session.itemExists("/acltest/A/B"));
+        assertTrue("Expecting test nodes to be created", session.itemExists("/acltest/A/B"));
     }
 
     @After
@@ -112,12 +86,6 @@ public class RepoInitTextIT extends TestSupport {
     }
 
     @Test
-    public void TODO() throws Exception {
-        assertNotNull(session);
-    }
-
-    /*
-    @Test
     public void serviceUserCreated() throws Exception {
         new Retry() {
             @Override
@@ -151,5 +119,4 @@ public class RepoInitTextIT extends TestSupport {
             }
         };
     }
-    */
 }
\ No newline at end of file