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 2016/04/29 16:17:18 UTC
svn commit: r1741636 - in /sling/trunk/testing/samples/bundle-with-it: ./
src/test/java/org/apache/sling/junit/teleporter/customizers/
src/test/java/org/apache/sling/testing/samples/bundlewit/
Author: bdelacretaz
Date: Fri Apr 29 14:17:18 2016
New Revision: 1741636
URL: http://svn.apache.org/viewvc?rev=1741636&view=rev
Log:
SLING-5703 - simplified tests using the new http clients and rules modules. Contributed by Andrei Dulvac, thanks!
Added:
sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/FilterIT.java
Modified:
sling/trunk/testing/samples/bundle-with-it/pom.xml
sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/junit/teleporter/customizers/BWIT_TeleporterCustomizer.java
sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/MimeTypeServletHttpIT.java
sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/OsgiConsoleHttpIT.java
Modified: sling/trunk/testing/samples/bundle-with-it/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/bundle-with-it/pom.xml?rev=1741636&r1=1741635&r2=1741636&view=diff
==============================================================================
--- sling/trunk/testing/samples/bundle-with-it/pom.xml (original)
+++ sling/trunk/testing/samples/bundle-with-it/pom.xml Fri Apr 29 14:17:18 2016
@@ -70,6 +70,9 @@
<!-- Options for the jar to execute. $JAREXEC_SERVER_PORT$ is replaced by the
selected port number -->
<jar.executor.jar.options>-p $JAREXEC_SERVER_PORT$</jar.executor.jar.options>
+
+ <!-- Filter IT -->
+ <sling.it.ignorelist>*.FilterIT#testShouldNotRun:test_filter</sling.it.ignorelist>
</properties>
<scm>
@@ -172,6 +175,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.19.1</version>
<executions>
<execution>
<id>integration-test</id>
@@ -228,6 +232,9 @@
<!-- Install this bundle for integration tests -->
<sling.additional.bundle.2>${project.artifactId}-${project.version}.jar</sling.additional.bundle.2>
+
+ <!-- Test the Filter rule -->
+ <sling.it.ignorelist>${sling.it.ignorelist}</sling.it.ignorelist>
</systemPropertyVariables>
</configuration>
</plugin>
@@ -275,6 +282,22 @@
<artifactId>org.apache.sling.testing.tools</artifactId>
<version>1.0.10</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.rules</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
Modified: sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/junit/teleporter/customizers/BWIT_TeleporterCustomizer.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/junit/teleporter/customizers/BWIT_TeleporterCustomizer.java?rev=1741636&r1=1741635&r2=1741636&view=diff
==============================================================================
--- sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/junit/teleporter/customizers/BWIT_TeleporterCustomizer.java (original)
+++ sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/junit/teleporter/customizers/BWIT_TeleporterCustomizer.java Fri Apr 29 14:17:18 2016
@@ -40,6 +40,7 @@ public class BWIT_TeleporterCustomizer i
// Make sure our bundle API is imported instead of embedded
final String apiPackage = "org.apache.sling.testing.samples.bundlewit.api";
cst.includeDependencyPrefix("org.apache.sling.testing.samples.bundlewit");
+ cst.includeDependencyPrefix("org.apache.http.concurrent");
cst.excludeDependencyPrefix(apiPackage);
cst.getAdditionalBundleHeaders().put(Constants.IMPORT_PACKAGE, apiPackage);
}
Added: sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/FilterIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/FilterIT.java?rev=1741636&view=auto
==============================================================================
--- sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/FilterIT.java (added)
+++ sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/FilterIT.java Fri Apr 29 14:17:18 2016
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.bundlewit;
+
+import org.junit.Assert;
+import org.apache.sling.testing.junit.rules.SlingClassRule;
+import org.apache.sling.testing.junit.rules.SlingRule;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class FilterIT {
+
+ @ClassRule
+ public static SlingClassRule classRule = new SlingClassRule();
+
+ @Rule
+ public SlingRule methodRule = new SlingRule();
+
+ @Test
+ public void testShouldRun() {
+ System.out.println("test should run");
+ }
+
+ @Test
+ // This test should be skipped by the FilterRule inside the SlingRule
+ // The "sling.it.ignorelist" property should be set to "*.FilterIT#testShouldNotRun"
+ public void testShouldNotRun() {
+ System.out.println("ignorelist: " + System.getProperty("sling.it.ignorelist"));
+ Assert.fail("Test should be filtered out by SlingRule");
+ }
+}
Modified: sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/MimeTypeServletHttpIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/MimeTypeServletHttpIT.java?rev=1741636&r1=1741635&r2=1741636&view=diff
==============================================================================
--- sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/MimeTypeServletHttpIT.java (original)
+++ sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/MimeTypeServletHttpIT.java Fri Apr 29 14:17:18 2016
@@ -16,8 +16,13 @@
*/
package org.apache.sling.testing.samples.bundlewit;
+import org.apache.sling.testing.clients.SlingClient;
+import org.apache.sling.testing.clients.SlingHttpResponse;
+import org.apache.sling.testing.junit.rules.SlingInstanceRule;
+import org.apache.sling.testing.junit.rules.SlingRule;
import org.apache.sling.testing.samples.bundlewit.impl.MimeTypeServlet;
-import org.apache.sling.testing.tools.sling.SlingTestBase;
+import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
/** HTTP test of the MimeTypeServlet provided
@@ -25,15 +30,16 @@ import org.junit.Test;
*/
public class MimeTypeServletHttpIT {
- private static final SlingTestBase S = new SlingTestBase();
+ @ClassRule
+ public static SlingInstanceRule slingInstanceRule = new SlingInstanceRule();
+
+ @Rule
+ public SlingRule slingMethodRule = new SlingRule(); // for demo purposes
private void assertMimeType(String path, String expected) throws Exception {
- S.getRequestExecutor().execute(
- S.getRequestBuilder().buildGetRequest(path + ".mimetype.txt")
- .withCredentials(S.getServerUsername(), S.getServerPassword())
- )
- .assertStatus(200)
- .assertContentContains(expected);
+ SlingClient client = slingInstanceRule.getAdminClient();
+ SlingHttpResponse response = client.doGet(path + ".mimetype.txt", 200);
+ response.checkContentContains(expected);
}
@Test
Modified: sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/OsgiConsoleHttpIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/OsgiConsoleHttpIT.java?rev=1741636&r1=1741635&r2=1741636&view=diff
==============================================================================
--- sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/OsgiConsoleHttpIT.java (original)
+++ sling/trunk/testing/samples/bundle-with-it/src/test/java/org/apache/sling/testing/samples/bundlewit/OsgiConsoleHttpIT.java Fri Apr 29 14:17:18 2016
@@ -16,7 +16,8 @@
*/
package org.apache.sling.testing.samples.bundlewit;
-import org.apache.sling.testing.tools.sling.SlingTestBase;
+import org.apache.sling.testing.junit.rules.SlingInstanceRule;
+import org.junit.ClassRule;
import org.junit.Test;
/** Simple HTTP test example, checks the validity of some
@@ -28,13 +29,8 @@ import org.junit.Test;
*/
public class OsgiConsoleHttpIT {
- /** This provides access to the server under test, after
- * setting it up with the required test bundles and
- * waiting for them to be ready. It was designed as
- * a base class for tests but using it in this way is
- * more decoupled.
- */
- private static final SlingTestBase S = new SlingTestBase();
+ @ClassRule
+ public static SlingInstanceRule slingInstanceRule = new SlingInstanceRule();
@Test
public void testSomeConsolePaths() throws Exception {
@@ -51,10 +47,7 @@ public class OsgiConsoleHttpIT {
for(String subpath : subpaths) {
final String path = "/system/console/" + subpath;
- S.getRequestExecutor().execute(
- S.getRequestBuilder().buildGetRequest(path)
- .withCredentials(S.getServerUsername(), S.getServerPassword())
- ).assertStatus(200);
+ slingInstanceRule.getAdminClient().doGet(path, 200);
}
}
}