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/03/28 12:43:53 UTC

svn commit: r1789109 - in /sling/trunk/bundles/scripting/core: ./ src/test/java/org/apache/sling/scripting/core/impl/ src/test/java/org/apache/sling/scripting/core/it/

Author: olli
Date: Tue Mar 28 12:43:53 2017
New Revision: 1789109

URL: http://svn.apache.org/viewvc?rev=1789109&view=rev
Log:
use Pax Exam 4.10.0 and Testing PaxExam 0.0.4

Added:
    sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/
    sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
Modified:
    sling/trunk/bundles/scripting/core/pom.xml
    sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/impl/BindingsValuesProvidersByContextIT.java

Modified: sling/trunk/bundles/scripting/core/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/pom.xml?rev=1789109&r1=1789108&r2=1789109&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/pom.xml (original)
+++ sling/trunk/bundles/scripting/core/pom.xml Tue Mar 28 12:43:53 2017
@@ -37,9 +37,7 @@
     </description>
 
     <properties>
-        <exam.version>3.5.0</exam.version>
-        <url.version>2.1.0</url.version>
-        <bundle.file.name>${basedir}/target/${project.build.finalName}.jar</bundle.file.name>
+        <org.ops4j.pax.exam.version>4.10.0</org.ops4j.pax.exam.version>
     </properties>
 
     <scm>
@@ -67,7 +65,6 @@
             <plugin>
                 <groupId>org.apache.servicemix.tooling</groupId>
                 <artifactId>depends-maven-plugin</artifactId>
-                <version>1.2</version>
                 <executions>
                     <execution>
                         <goals>
@@ -87,10 +84,11 @@
                   </execution>
                 </executions>
                 <configuration>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                     <systemProperties>
                         <property>
-                            <name>bundle.file.name</name>
-                            <value>${bundle.file.name}</value>
+                            <name>bundle.filename</name>
+                            <value>${basedir}/target/${project.build.finalName}.jar</value>
                         </property>
                     </systemProperties>
                 </configuration>
@@ -113,12 +111,20 @@
     </reporting>
 
     <dependencies>
+        <!-- javax -->
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+            <version>1</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
             <version>3.1.0</version>
             <scope>provided</scope>
         </dependency>
+        <!-- Apache Sling -->
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
@@ -156,6 +162,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.paxexam</artifactId>
+            <version>0.0.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>osgi.core</artifactId>
             <scope>provided</scope>
@@ -196,11 +208,7 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
@@ -215,79 +223,75 @@
             <version>2.0.6</version>
             <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-forked</artifactId>
-            <version>${exam.version}</version>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>5.6.2</version>
             <scope>test</scope>
         </dependency>
 
+        
         <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${exam.version}</version>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
+            <version>2.0.2</version>
             <scope>test</scope>
         </dependency>
-
+        
         <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-link-mvn</artifactId>
-            <version>${exam.version}</version>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+            <version>1.6.0</version>
             <scope>test</scope>
         </dependency>
 
         <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-aether</artifactId>
-            <version>${url.version}</version>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>1.9.5</version>
             <scope>test</scope>
         </dependency>
-
+        <!-- testing -->
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.framework</artifactId>
-            <version>5.4.0</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
-            <groupId>javax.inject</groupId>
-            <artifactId>javax.inject</artifactId>
-            <version>1</version>
+            <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.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>2.0.2</version>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
             <scope>test</scope>
         </dependency>
-        
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.sling-mock</artifactId>
-            <version>1.6.0</version>
+            <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.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>1.9.5</version>
+            <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.apache.felix</groupId>
-            <artifactId>org.apache.felix.eventadmin</artifactId>
-            <version>1.4.6</version>
+            <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.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr</artifactId>
-            <version>2.0.2</version>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${org.ops4j.pax.exam.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

Modified: sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/impl/BindingsValuesProvidersByContextIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/impl/BindingsValuesProvidersByContextIT.java?rev=1789109&r1=1789108&r2=1789109&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/impl/BindingsValuesProvidersByContextIT.java (original)
+++ sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/impl/BindingsValuesProvidersByContextIT.java Tue Mar 28 12:43:53 2017
@@ -45,23 +45,23 @@ import javax.script.ScriptEngineFactory;
 
 import org.apache.sling.scripting.api.BindingsValuesProvider;
 import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.apache.sling.scripting.core.it.ScriptingCoreTestSupport;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 
 @RunWith(PaxExam.class)
-public class BindingsValuesProvidersByContextIT {
-
-    private static final String FELIX_GID = "org.apache.felix";
-    private static final String SLING_GID = "org.apache.sling";
+public class BindingsValuesProvidersByContextIT  extends ScriptingCoreTestSupport{
 
     @Inject
+    @Filter(timeout = 300000)
     private BindingsValuesProvidersByContext bvpProvider;
 
     @Inject
@@ -69,52 +69,6 @@ public class BindingsValuesProvidersByCo
 
     private final List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>();
 
-    @org.ops4j.pax.exam.Configuration
-    public Option[] config() {
-        final String localRepo = System.getProperty("maven.repo.local", "");
-
-        final String bundleFileName = System.getProperty("bundle.file.name", "BUNDLE_FILE_NOT_SET");
-        final File bundleFile = new File(bundleFileName);
-        if (!bundleFile.canRead()) {
-            throw new IllegalArgumentException("Cannot read from bundle file " + bundleFile.getAbsolutePath());
-        }
-
-        return options(
-                when(localRepo.length() > 0).useOptions(
-                        systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)
-                ),
-                systemProperty("pax.exam.logging").value("none"),
-                provision(
-                        bundle(bundleFile.toURI().toString()),
-
-                        mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"),
-                        mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"),
-                        mavenBundle("org.slf4j", "slf4j-api", "1.7.13"),
-                        mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.13"),
-                        mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.13"),
-
-                        mavenBundle().groupId(FELIX_GID).artifactId("org.apache.felix.scr").versionAsInProject(),
-                        mavenBundle().groupId(FELIX_GID).artifactId("org.apache.felix.eventadmin").versionAsInProject(),
-                        mavenBundle().groupId(FELIX_GID).artifactId("org.apache.felix.webconsole").versionAsInProject(),
-
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.scripting.api").versionAsInProject(),
-
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.commons.threads").versionAsInProject(),
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.api").versionAsInProject(),
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.commons.mime").versionAsInProject(),
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.commons.osgi").versionAsInProject(),
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.serviceusermapper").versionAsInProject(),
-
-                        mavenBundle().groupId("javax.servlet").artifactId("javax.servlet-api").versionAsInProject(),
-                        mavenBundle().groupId("commons-io").artifactId("commons-io").versionAsInProject(),
-                        mavenBundle().groupId("commons-lang").artifactId("commons-lang").versionAsInProject(),
-                        mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject(),
-                        mavenBundle().groupId(SLING_GID).artifactId("org.apache.sling.commons.log").version("4.0.0")
-                ),
-                junitBundles()
-        );
-    }
-
     @Before
     public void setup() {
         regs.clear();

Added: sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java?rev=1789109&view=auto
==============================================================================
--- sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java (added)
+++ sling/trunk/bundles/scripting/core/src/test/java/org/apache/sling/scripting/core/it/ScriptingCoreTestSupport.java Tue Mar 28 12:43:53 2017
@@ -0,0 +1,69 @@
+/*
+ * 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.scripting.core.it;
+
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.sling;
+import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
+import static org.apache.sling.testing.paxexam.SlingOptions.webconsole;
+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.cm.ConfigurationAdminOptions.factoryConfiguration;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
+public class ScriptingCoreTestSupport extends TestSupport {
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[]{
+            baseConfiguration(),
+            launchpad(),
+            // Sling Scripting Core
+            testBundle("bundle.filename"),
+            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.api").versionAsInProject(),
+            factoryConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended")
+                .put("user.mapping", new String[]{
+                    "org.apache.sling.scripting.core=sling-scripting"
+                })
+                .asOption(),
+            // debugging
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.inventory").version(versionResolver),
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version(versionResolver),
+            // testing
+            junitBundles()
+        };
+    }
+
+    protected Option launchpad() {
+        final int httpPort = findFreePort();
+        System.out.println("http port " + httpPort);
+        return composite(
+            sling(),
+            webconsole(),
+            newConfiguration("org.apache.felix.http")
+                .put("org.osgi.service.http.port", httpPort)
+                .asOption()
+        );
+    }
+
+}