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 2018/01/19 12:52:27 UTC

[sling-org-apache-sling-pipes] branch issue/SLING-7251 created (now 1cb5d67)

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

olli pushed a change to branch issue/SLING-7251
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git.


      at 1cb5d67  SLING-7251 Fix pipes plumber servlet IT

This branch includes the following new commits:

     new 1cb5d67  SLING-7251 Fix pipes plumber servlet IT

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.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-pipes] 01/01: SLING-7251 Fix pipes plumber servlet IT

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

olli pushed a commit to branch issue/SLING-7251
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git

commit 1cb5d6700481b19d32b2f7388c32c97deb37222f
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Fri Jan 19 13:32:22 2018 +0100

    SLING-7251 Fix pipes plumber servlet IT
---
 pom.xml                                            | 34 ++++++---
 .../apache/sling/pipes/it/PipesTestSupport.java    | 80 +++++++++++-----------
 .../apache/sling/pipes/it/PlumberServletIT.java    | 38 +++++-----
 src/test/resources/logback.xml                     | 30 --------
 4 files changed, 81 insertions(+), 101 deletions(-)

diff --git a/pom.xml b/pom.xml
index 26a41d4..30384cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.sling</groupId>
     <artifactId>sling</artifactId>
-    <version>32</version>
+    <version>33-SNAPSHOT</version>
     <relativePath />
   </parent>
 
@@ -71,13 +71,10 @@
       <plugin>
         <groupId>org.apache.servicemix.tooling</groupId>
         <artifactId>depends-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>generate-depends-file</goal>
-            </goals>
-          </execution>
-        </executions>
+        <!-- see SLING-7351, switch to bnd-maven-plugin and remove configuration -->
+        <configuration>
+          <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.rat</groupId>
@@ -142,6 +139,11 @@
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.annotation.versioning</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
       <artifactId>osgi.core</artifactId>
       <scope>provided</scope>
     </dependency>
@@ -257,6 +259,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.resource.presence</artifactId>
+      <version>0.0.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
       <artifactId>pax-exam</artifactId>
       <version>${org.ops4j.pax.exam.version}</version>
@@ -289,7 +297,7 @@
     <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.testing.paxexam</artifactId>
-      <version>0.0.4</version>
+      <version>1.0.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
     <!-- jsoup -->
@@ -314,7 +322,13 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
-      <version>5.6.6</version>
+      <version>5.6.10</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.2</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java b/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
index a29e63b..5b69c5d 100644
--- a/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
+++ b/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
@@ -20,37 +20,39 @@ package org.apache.sling.pipes.it;
 
 import javax.inject.Inject;
 
+import org.apache.commons.codec.binary.Base64;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.auth.core.AuthenticationSupport;
 import org.apache.sling.pipes.Plumber;
-import org.apache.sling.testing.paxexam.SlingOptions;
+import org.apache.sling.resource.presence.ResourcePresence;
 import org.apache.sling.testing.paxexam.TestSupport;
-import org.apache.sling.auth.core.AuthenticationSupport;
-
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.ProbeBuilder;
 import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.util.PathUtils;
+import org.ops4j.pax.exam.util.Filter;
 
 import static org.apache.sling.testing.paxexam.SlingOptions.slingCommonsHtml;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingExtensionDistribution;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingExtensionEvent;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingExtensionQuery;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOakTar;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingDistribution;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingEvent;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuery;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingResourcePresence;
 import static org.apache.sling.testing.paxexam.SlingOptions.slingScriptingSightly;
 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.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
 public abstract class PipesTestSupport extends TestSupport {
 
     protected static final String NN_TEST = "test";
 
+    protected static final String ADMIN_CREDENTIALS = "admin:admin";
+
     @Inject
     protected Plumber plumber;
 
@@ -62,6 +64,10 @@ public abstract class PipesTestSupport extends TestSupport {
 
     final protected int httpPort = findFreePort();
 
+    @Inject
+    @Filter(value = "(path=/etc/pipes-it)")
+    private ResourcePresence resourcePresence;
+
     @Configuration
     public Option[] configuration() {
         return new Option[]{
@@ -69,65 +75,57 @@ public abstract class PipesTestSupport extends TestSupport {
             launchpad(),
             // Sling Pipes
             testBundle("bundle.filename"),
+            factoryConfiguration("org.apache.sling.resource.presence.internal.ResourcePresenter")
+                .put("path", "/etc/pipes-it")
+                .asOption(),
+            factoryConfiguration("org.apache.sling.jcr.repoinit.RepositoryInitializer")
+                .put("scripts", new String[]{"create service user sling-pipes\n\n  set ACL for sling-pipes\n\n    allow   jcr:all     on /\n\n  end"})
+                .asOption(),
+            factoryConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended")
+                .put("user.mapping", new String[]{"org.apache.sling.pipes=sling-pipes"})
+                .asOption(),
             // testing
+            slingResourcePresence(),
             newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
                 .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
                 .asOption(),
+            mavenBundle().groupId("com.google.code.gson").artifactId("gson").versionAsInProject(),
+            mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
+            mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
             junitBundles()
         };
     }
 
+    protected String basicAuthorizationHeader(final String credentials) {
+        return "Basic ".concat(new String(Base64.encodeBase64(credentials.getBytes())));
+    }
+
     protected void mkdir(ResourceResolver resolver, String path) throws Exception {
         plumber.newPipe(resolver).mkdir(path).run();
     }
 
     protected Option launchpad() {
         final String workingDirectory = workingDirectory();
-        SlingOptions.versionResolver.setVersion("org.apache.sling", "org.apache.sling.xss", "1.0.18");
         return composite(
-            slingLaunchpadOakTar(workingDirectory, httpPort),
-            slingExtensionEvent(),
-            slingExtensionDistribution(),
-            slingExtensionQuery(),
+            slingQuickstartOakTar(workingDirectory, httpPort),
+            slingEvent(),
+            slingDistribution(),
+            slingQuery(),
             slingCommonsHtml(),
-            mavenBundle().groupId("javax.mail").artifactId("mail").version("1.5.0-b01"),
-            slingScriptingSightly(),
-            // TODO remove johnzon bundle (should be part of sling in upcoming release of org.apache.sling.testing.paxexam)
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.johnzon").versionAsInProject(),
-            // TODO required by Jackrabbit Vault (Sling Distribution)
-            mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
-            mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
-            systemPackages(
-                "org.w3c.dom.css",
-                "org.w3c.dom.html",
-                "org.w3c.dom.ranges",
-                "org.w3c.dom.traversal"
-            ),
-            logging()
+            slingScriptingSightly()
         );
     }
 
     @ProbeBuilder
     public TestProbeBuilder probeConfiguration(final TestProbeBuilder testProbeBuilder) {
         testProbeBuilder.setHeader("Sling-Initial-Content",
-                "SLING-INF/jcr_root/apps/pipes-it;path:=/apps/pipes-it;overwrite:=true," +
+            "SLING-INF/jcr_root/apps/pipes-it;path:=/apps/pipes-it;overwrite:=true," +
                 "SLING-INF/jcr_root/etc/pipes-it;path:=/etc/pipes-it;overwrite:=true," +
                 "SLING-INF/jcr_root/content;path:=/content;overwrite:=true"
         );
         return testProbeBuilder;
     }
 
-    protected Option logging() {
-        final String filename = String.format("file:%s/src/test/resources/logback.xml", PathUtils.getBaseDir());
-        return composite(
-                systemProperty("logback.configurationFile").value(filename),
-                mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").version("1.7.21"),
-                mavenBundle().groupId("org.slf4j").artifactId("jcl-over-slf4j").version("1.7.21"),
-                mavenBundle().groupId("ch.qos.logback").artifactId("logback-core").version("1.1.7"),
-                mavenBundle().groupId("ch.qos.logback").artifactId("logback-classic").version("1.1.7")
-        );
-    }
-
     ResourceResolver resolver() throws LoginException {
         return resourceResolverFactory.getAdministrativeResourceResolver(null);
     }
diff --git a/src/test/java/org/apache/sling/pipes/it/PlumberServletIT.java b/src/test/java/org/apache/sling/pipes/it/PlumberServletIT.java
index 20c08ee..9fc8e83 100644
--- a/src/test/java/org/apache/sling/pipes/it/PlumberServletIT.java
+++ b/src/test/java/org/apache/sling/pipes/it/PlumberServletIT.java
@@ -16,9 +16,12 @@
  */
 package org.apache.sling.pipes.it;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.sling.pipes.internal.JsonWriter;
-import org.apache.sling.pipes.internal.JsonUtil;
+import java.io.IOException;
+import java.util.HashMap;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.jsoup.Jsoup;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -27,33 +30,28 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.json.JsonObject;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.net.URL;
-import java.nio.charset.Charset;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class PlumberServletIT extends PipesTestSupport {
-    private static final Logger LOGGER = LoggerFactory.getLogger(PipeModelIT.class);
+
+    private final GsonBuilder gsonBuilder = new GsonBuilder();
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(PlumberServletIT.class);
 
     @Test
     public void testListComponentJson() throws IOException {
-        final String urlString = String.format("http://localhost:%s/etc/pipes-it/another-list.json", httpPort());
-        LOGGER.info("fetching {}", urlString);
-        URL url = new URL(urlString);
-        StringWriter writer = new StringWriter();
-        IOUtils.copy(url.openStream(), writer, Charset.defaultCharset());
-        String response = writer.toString();
+        final String url = String.format("http://localhost:%s/etc/pipes-it/another-list.json", httpPort());
+        LOGGER.info("fetching {}", url);
+        final String response = Jsoup.connect(url).header("Authorization", basicAuthorizationHeader(ADMIN_CREDENTIALS)).ignoreContentType(true).execute().body();
         LOGGER.info("retrieved following response {}", response);
-        JsonObject main = JsonUtil.parseObject(response);
-        assertTrue("there should be an items key", main.containsKey(JsonWriter.KEY_ITEMS));
-        assertTrue("there should be a size key", main.containsKey(JsonWriter.KEY_SIZE));
-        assertEquals("there should be 2 elements", 2, main.getInt(JsonWriter.KEY_SIZE));
+        final Gson gson = gsonBuilder.create();
+        final HashMap main = gson.fromJson(response, HashMap.class);
+        assertTrue("there should be an items key", main.containsKey("items"));
+        assertTrue("there should be a size key", main.containsKey("size"));
+        assertEquals("there should be 2 elements", 2, ((Double) main.get("size")).intValue());
     }
 
 }
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
deleted file mode 100644
index d46a4ae..0000000
--- a/src/test/resources/logback.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<configuration>
-  <appender name="file" class="ch.qos.logback.core.FileAppender">
-    <file>target/testing.log</file>
-    <encoder>
-      <pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern>
-    </encoder>
-  </appender>
-  <root level="debug">
-    <appender-ref ref="file"/>
-  </root>
-</configuration>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.