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 2017/02/26 18:55:30 UTC

svn commit: r1784470 - in /sling/trunk/bundles/extensions/validation: ./ core/ core/src/test/java/org/apache/sling/validation/core/ core/src/test/java/org/apache/sling/validation/core/it/ core/src/test/java/org/apache/sling/validation/core/it/tests/ co...

Author: olli
Date: Sun Feb 26 18:55:29 2017
New Revision: 1784470

URL: http://svn.apache.org/viewvc?rev=1784470&view=rev
Log:
SLING-6568 Merge it-http module into core module

Added:
    sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/
    sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/
    sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/
    sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationServiceIT.java
      - copied, changed from r1784362, sling/trunk/bundles/extensions/validation/it-http/src/test/java/org/apache/sling/validation/testservices/ValidationServiceTest.java
    sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationTestSupport.java
    sling/trunk/bundles/extensions/validation/core/src/test/resources/
      - copied from r1784362, sling/trunk/bundles/extensions/validation/test-services/src/main/resources/
    sling/trunk/bundles/extensions/validation/core/src/test/resources/exam.properties
    sling/trunk/bundles/extensions/validation/core/src/test/resources/logback.xml
Removed:
    sling/trunk/bundles/extensions/validation/it-http/src/test/java/org/apache/sling/validation/testservices/ValidationServiceTest.java
Modified:
    sling/trunk/bundles/extensions/validation/core/pom.xml
    sling/trunk/bundles/extensions/validation/pom.xml

Modified: sling/trunk/bundles/extensions/validation/core/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/pom.xml?rev=1784470&r1=1784469&r2=1784470&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/pom.xml (original)
+++ sling/trunk/bundles/extensions/validation/core/pom.xml Sun Feb 26 18:55:29 2017
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>29</version>
+        <version>30-SNAPSHOT</version>
         <relativePath/>
     </parent>
 
@@ -32,6 +32,7 @@
 
     <properties>
         <sling.java.version>8</sling.java.version>
+        <org.ops4j.pax.exam.version>4.10.0</org.ops4j.pax.exam.version>
     </properties>
 
     <scm>
@@ -58,6 +59,38 @@
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                    <systemProperties>
+                        <property>
+                            <name>bundle.filename</name>
+                            <value>${basedir}/target/${project.build.finalName}.jar</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <dependencies>
@@ -100,11 +133,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.threads</artifactId>
             <version>3.1.0</version>
@@ -131,11 +159,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest-library</artifactId>
             <version>1.3</version>
@@ -167,6 +190,24 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.auth.core</artifactId>
+            <version>1.3.24</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.engine</artifactId>
+            <version>2.6.6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.validation.test-services</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.sling-mock</artifactId>
             <version>1.3.0</version>
             <scope>test</scope>
@@ -176,5 +217,74 @@
             <artifactId>slf4j-simple</artifactId>
              <scope>test</scope>
          </dependency>
+
+        <!-- Apache Felix -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>5.6.1</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- Apache Sling -->
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.servlets.post</artifactId>
+            <version>2.2.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.paxexam</artifactId>
+            <version>0.0.3-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.tools</artifactId>
+            <version>1.0.14</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
+            <version>1.3_1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-cm</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Copied: sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationServiceIT.java (from r1784362, sling/trunk/bundles/extensions/validation/it-http/src/test/java/org/apache/sling/validation/testservices/ValidationServiceTest.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationServiceIT.java?p2=sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationServiceIT.java&p1=sling/trunk/bundles/extensions/validation/it-http/src/test/java/org/apache/sling/validation/testservices/ValidationServiceTest.java&r1=1784362&r2=1784470&rev=1784470&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/it-http/src/test/java/org/apache/sling/validation/testservices/ValidationServiceTest.java (original)
+++ sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationServiceIT.java Sun Feb 26 18:55:29 2017
@@ -16,18 +16,24 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.validation.testservices;
+package org.apache.sling.validation.core.it.tests;
+
+import java.io.IOException;
 
 import org.apache.http.entity.mime.MultipartEntity;
 import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.servlets.post.SlingPostConstants;
+import org.apache.sling.testing.tools.http.RequestBuilder;
 import org.apache.sling.testing.tools.http.RequestExecutor;
-import org.apache.sling.testing.tools.sling.SlingTestBase;
+import org.junit.Before;
 import org.junit.Test;
-
-import java.io.IOException;
+import org.junit.runner.RunWith;
+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.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -38,16 +44,30 @@ import static org.junit.Assert.assertTru
  * The according validation model enforces the properties "field1" matching regex=^\\\p{Upper}+$ and "field2" (having an arbitrary value).
  *
  */
-public class ValidationServiceTest extends SlingTestBase {
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ValidationServiceIT extends ValidationTestSupport {
+
+    protected DefaultHttpClient defaultHttpClient;
+
+    protected RequestExecutor requestExecutor;
+
+    @Before
+    public void setup() throws IOException {
+        defaultHttpClient = new DefaultHttpClient();
+        requestExecutor = new RequestExecutor(defaultHttpClient);
+    }
 
     @Test
     public void testValidRequestModel1() throws IOException, JSONException {
+        final String url = String.format("http://localhost:%s", httpPort());
+        final RequestBuilder requestBuilder = new RequestBuilder(url);
         MultipartEntity entity = new MultipartEntity();
         entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
         entity.addPart("field1", new StringBody("HELLOWORLD"));
         entity.addPart("field2", new StringBody("30.01.1988"));
         entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
-        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
+        RequestExecutor re = requestExecutor.execute(requestBuilder.buildPostRequest
                 ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
         JSONObject jsonResponse = new JSONObject(re.getContent());
         assertTrue(jsonResponse.getBoolean("valid"));
@@ -59,7 +79,9 @@ public class ValidationServiceTest exten
         entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
         entity.addPart("field1", new StringBody("Hello World"));
         entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
-        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
+        final String url = String.format("http://localhost:%s", httpPort());
+        RequestBuilder requestBuilder = new RequestBuilder(url);
+        RequestExecutor re = requestExecutor.execute(requestBuilder.buildPostRequest
                 ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
         String content = re.getContent();
         JSONObject jsonResponse = new JSONObject(content);

Added: sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationTestSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationTestSupport.java?rev=1784470&view=auto
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationTestSupport.java (added)
+++ sling/trunk/bundles/extensions/validation/core/src/test/java/org/apache/sling/validation/core/it/tests/ValidationTestSupport.java Sun Feb 26 18:55:29 2017
@@ -0,0 +1,110 @@
+/*
+ * 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.validation.core.it.tests;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.servlets.ServletResolver;
+import org.apache.sling.auth.core.AuthenticationSupport;
+import org.apache.sling.engine.SlingRequestProcessor;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.apache.sling.validation.ValidationService;
+import org.apache.sling.validation.testservices.ResourcePresence;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.util.Filter;
+import org.ops4j.pax.exam.util.PathUtils;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.slingExtensionI18n;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingInstallerProviderJcr;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOakTar;
+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.systemProperty;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
+public class ValidationTestSupport extends TestSupport {
+
+    @Inject
+    protected ServletResolver servletResolver;
+
+    @Inject
+    protected SlingRequestProcessor slingRequestProcessor;
+
+    @Inject
+    protected AuthenticationSupport authenticationSupport;
+
+    @Inject
+    protected ValidationService validationService;
+
+    @Inject
+    @Filter(value = "(path=/apps/sling/validation/models/model1)", timeout = 10000)
+    protected ResourcePresence resourcePresence;
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[]{
+            baseConfiguration(),
+            launchpad(),
+            // Sling Validation
+            testBundle("bundle.filename"),
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.validation.api").versionAsInProject(),
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.validation.test-services").versionAsInProject(),
+            // TODO remove whitelist configuration once loginAdministrative is removed
+            factoryConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment")
+                .put("whitelist.bundles", new String[]{"org.apache.sling.validation.core"})
+                .put("whitelist.name", "sling-validation")
+                .asOption(),
+            factoryConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended")
+                .put("user.mapping", new String[]{
+                    "org.apache.sling.validation.core=sling-readall",
+                    "org.apache.sling.validation.test-services=sling-readall"
+                })
+                .asOption(),
+            // testing
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.testing.tools").versionAsInProject(),
+            mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
+            junitBundles(),
+            logging()
+        };
+    }
+
+    protected Option launchpad() {
+        final int httpPort = findFreePort();
+        final String workingDirectory = workingDirectory();
+        return composite(
+            slingLaunchpadOakTar(workingDirectory, httpPort),
+            slingExtensionI18n(),
+            slingInstallerProviderJcr()
+        );
+    }
+
+    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")
+        );
+    }
+
+}

Added: sling/trunk/bundles/extensions/validation/core/src/test/resources/exam.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/test/resources/exam.properties?rev=1784470&view=auto
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/test/resources/exam.properties (added)
+++ sling/trunk/bundles/extensions/validation/core/src/test/resources/exam.properties Sun Feb 26 18:55:29 2017
@@ -0,0 +1,19 @@
+#
+#  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.
+#
+pax.exam.logging=none

Added: sling/trunk/bundles/extensions/validation/core/src/test/resources/logback.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/test/resources/logback.xml?rev=1784470&view=auto
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/test/resources/logback.xml (added)
+++ sling/trunk/bundles/extensions/validation/core/src/test/resources/logback.xml Sun Feb 26 18:55:29 2017
@@ -0,0 +1,30 @@
+<?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>

Modified: sling/trunk/bundles/extensions/validation/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/pom.xml?rev=1784470&r1=1784469&r2=1784470&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/pom.xml (original)
+++ sling/trunk/bundles/extensions/validation/pom.xml Sun Feb 26 18:55:29 2017
@@ -34,7 +34,6 @@
         <module>api</module>
         <module>core</module>
         <module>test-services</module>
-        <module>it-http</module>
         <module>examples</module>
     </modules>