You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2016/05/15 13:38:34 UTC

svn commit: r1743904 - in /sling/trunk/testing: ./ samples/module-with-it/ samples/module-with-it/src/ samples/module-with-it/src/main/ samples/module-with-it/src/main/provisioning/ samples/module-with-it/src/test/ samples/module-with-it/src/test/java/...

Author: kwin
Date: Sun May 15 13:38:34 2016
New Revision: 1743904

URL: http://svn.apache.org/viewvc?rev=1743904&view=rev
Log:
SLING-5677 add new example project leveraging the default property-based customizer

Added:
    sling/trunk/testing/samples/module-with-it/
    sling/trunk/testing/samples/module-with-it/.gitignore
    sling/trunk/testing/samples/module-with-it/pom.xml   (with props)
    sling/trunk/testing/samples/module-with-it/src/
    sling/trunk/testing/samples/module-with-it/src/main/
    sling/trunk/testing/samples/module-with-it/src/main/provisioning/
    sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt   (with props)
    sling/trunk/testing/samples/module-with-it/src/test/
    sling/trunk/testing/samples/module-with-it/src/test/java/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/
    sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java   (with props)
Modified:
    sling/trunk/testing/pom.xml

Modified: sling/trunk/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/pom.xml?rev=1743904&r1=1743903&r2=1743904&view=diff
==============================================================================
--- sling/trunk/testing/pom.xml (original)
+++ sling/trunk/testing/pom.xml Sun May 15 13:38:34 2016
@@ -93,6 +93,7 @@
     <module>mocks</module>
     <module>sling-pax-util</module>
     <module>samples/bundle-with-it</module>
+    <module>samples/module-with-it</module>
   </modules>
 
 </project>

Added: sling/trunk/testing/samples/module-with-it/.gitignore
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/module-with-it/.gitignore?rev=1743904&view=auto
==============================================================================
--- sling/trunk/testing/samples/module-with-it/.gitignore (added)
+++ sling/trunk/testing/samples/module-with-it/.gitignore Sun May 15 13:38:34 2016
@@ -0,0 +1 @@
+/target/

Added: sling/trunk/testing/samples/module-with-it/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/module-with-it/pom.xml?rev=1743904&view=auto
==============================================================================
--- sling/trunk/testing/samples/module-with-it/pom.xml (added)
+++ sling/trunk/testing/samples/module-with-it/pom.xml Sun May 15 13:38:34 2016
@@ -0,0 +1,190 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>26</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>org.apache.sling.testing.samples.module-with-it</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>slingstart</packaging> <!-- means the launchpad is configured in /src/main/provisioning, extends classpath -->
+
+    <name>Apache Sling Testing - sample module with integration tests</name>
+    <description>Sample project that demonstrates a module with integration 
+        tests, running against a Sling instance being started via slingstart-maven-plugin.
+        Uses teleported server-side tests. It is leveraging the DefaultPropertyBasedCustomizer, 
+        i.e. system properties influence the teleporter behaviour instead of code</description>
+
+    <properties>
+        <sling.java.version>7</sling.java.version>
+        <http.host>localhost</http.host>
+        <sling.default.vm.options>-Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true</sling.default.vm.options>
+        <slf4j.version>1.7.6</slf4j.version>
+    </properties>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/samples/module-with-it</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/samples/module-with-it</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/samples/module-with-it</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+             </plugin>
+             <plugin>
+                <!-- Find free ports to run our server -->
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>reserve-server-port</id>
+                        <goals>
+                            <goal>reserve-network-port</goal>
+                        </goals>
+                        <phase>process-resources</phase>
+                        <configuration>
+                            <portNames>
+                                <!-- used port name must be stored in property because it must be used for the base url -->
+                                <portName>http.port</portName>
+                            </portNames>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <!-- the Sling instance is provisioned from the model in src/main/provisioning/model.txt -->
+                <groupId>org.apache.sling</groupId>
+                <artifactId>slingstart-maven-plugin</artifactId>
+                <version>1.4.3-SNAPSHOT</version>
+                <extensions>true</extensions>
+                <executions>
+                    <execution>
+                         <id>start-container-before-IT</id>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                         <id>stop-container-after-IT</id>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <servers>
+                        <server>
+                            <id>singleinstance</id>
+                            <port>${http.port}</port>
+                            <vmOpts>${sling.vm.options}</vmOpts>
+                        </server>
+                    </servers>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-test</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <systemPropertyVariables>
+                        <ClientSideTeleporter.baseUrl>http://${http.host}:${http.port}/</ClientSideTeleporter.baseUrl>
+                        <ClientSideTeleporter.testReadyTimeoutSeconds>5</ClientSideTeleporter.testReadyTimeoutSeconds>
+                    </systemPropertyVariables>
+                </configuration>
+            </plugin>
+         </plugins>
+    </build>
+
+    <dependencies>
+       <!-- the SLF4J version must match the one from the used slingstart model -->
+       <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.4.2</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.junit.core</artifactId>
+            <version>1.0.17-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.junit.teleporter</artifactId>
+            <version>1.0.7-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: sling/trunk/testing/samples/module-with-it/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt?rev=1743904&view=auto
==============================================================================
--- sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt (added)
+++ sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt Sun May 15 13:38:34 2016
@@ -0,0 +1,36 @@
+#
+#  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.
+#
+[feature name=module-with-it]
+# Dependencies
+[artifacts]
+  org.apache.sling/org.apache.sling.launchpad/9-SNAPSHOT/slingstart
+  # this is necessary to execute the tests
+  org.apache.sling/org.apache.sling.junit.core/1.0.17-SNAPSHOT
+
+# additional configuration for testing
+[configurations]
+  integrationTestsConfig
+    message="This test config should be loaded at startup"
+
+  org.apache.sling.servlets.resolver.SlingServletResolver
+    # Set the servlet resolver's cache size to zero for testing
+    servletresolver.cacheSize=I"0"
+
+[settings]
+  org.apache.sling.commons.log.julenabled=true

Propchange: sling/trunk/testing/samples/module-with-it/src/main/provisioning/model.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java?rev=1743904&view=auto
==============================================================================
--- sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java (added)
+++ sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java Sun May 15 13:38:34 2016
@@ -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.testing.samples.modulewit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/** Basic teleported server-side test, demonstrates how
+ *  these work.
+ *  This is a general Sling test, it does not test anything 
+ *  from this bundle.
+ */
+public class BasicTeleportedIT {
+    
+    @Rule
+    public final TeleporterRule teleporter = TeleporterRule.forClass(getClass());
+
+    @Test
+    public void testConfigAdmin() throws IOException {
+        final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();
+
+        // demonstrate that we can access OSGi services from teleported tests
+        final ConfigurationAdmin ca = teleporter.getService(ConfigurationAdmin.class);
+        assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);
+
+        final Configuration cfg = ca.getConfiguration(pid);
+        assertNotNull("Expecting to get a Configuration", cfg);
+        assertEquals("Expecting the correct pid", pid, cfg.getPid());
+    }
+}
\ No newline at end of file

Propchange: sling/trunk/testing/samples/module-with-it/src/test/java/org/apache/sling/testing/samples/modulewit/BasicTeleportedIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain