sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-junit-healthcheck] 06/45: SLING-1981 - support running single tests methods using JUnit servlet paths like /system/sling/junit/TEST_CLASS_NAME.json/TEST_METHOD_NAME
Date Tue, 07 Nov 2017 09:51:22 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.junit.healthcheck-1.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-healthcheck.git

commit 1614589e36be2bcf5d3f89bf90672d40b914fcc8
Author: Bertrand Delacretaz <bdelacretaz@apache.org>
AuthorDate: Thu Feb 24 16:54:59 2011 +0000

    SLING-1981 - support running single tests methods using JUnit servlet paths like /system/sling/junit/TEST_CLASS_NAME.json/TEST_METHOD_NAME
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/junit/remote@1074212
13f79535-47bb-0310-9956-ffa450edef68
---
 .../remote/testrunner/SlingRemoteTestParameters.java  | 18 ++++++++++++++++--
 .../remote/testrunner/SlingRemoteTestRunner.java      | 19 ++++++++++++++-----
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
b/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
index 84e32af..69d83ea 100644
--- a/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
+++ b/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
@@ -20,7 +20,21 @@ package org.apache.sling.junit.remote.testrunner;
  *  run the tests.
  */
 public interface SlingRemoteTestParameters {
+    /** Return the URL of the JUnit servlet */
+    String getJunitServletUrl();
+    
+    /** Return the optional selector for the test classes to run,
+     *  for example "org.apache.sling.testing.samples.sampletests.JUnit4Test"
+     */
+    String getTestClassesSelector();
+    
+    /** Return the optional selector for the test methods to run,
+     *  for example "someMethodName"
+     */
+    String getTestMethodSelector();
+    
+    /** Return the expected number of tests - if zero, no check
+     *  is done.
+     */
     int getExpectedNumberOfTests();
-    String getServerBaseUrl();
-    String getJunitServletPath();
 }
diff --git a/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
b/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
index ba3428e..428f090 100644
--- a/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
+++ b/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
@@ -78,13 +78,22 @@ public class SlingRemoteTestRunner extends ParentRunner<SlingRemoteTest>
{
         
         // Setup request execution
         executor = new RequestExecutor(new DefaultHttpClient());
-        if(testParameters.getServerBaseUrl() == null) {
+        if(testParameters.getJunitServletUrl() == null) {
             throw new IllegalStateException("Server base URL is null, cannot run tests");
         }
-        builder = new RequestBuilder(testParameters.getServerBaseUrl());
+        builder = new RequestBuilder(testParameters.getJunitServletUrl());
         
         // POST request executes the tests
-        final Request r = builder.buildPostRequest(testParameters.getJunitServletPath() +
".json");
+        final StringBuilder subpath = new StringBuilder();
+        subpath.append("/");
+        subpath.append(testParameters.getTestClassesSelector());
+        subpath.append(".json");
+        final String testMethodSelector = testParameters.getTestMethodSelector();
+        if(testMethodSelector != null && testMethodSelector.length() > 0) {
+            subpath.append("/");
+            subpath.append(testMethodSelector);
+        }
+        final Request r = builder.buildPostRequest(subpath.toString());
         executor.execute(r)
         .assertStatus(200)
         .assertContentType("application/json");
@@ -101,8 +110,8 @@ public class SlingRemoteTestRunner extends ParentRunner<SlingRemoteTest>
{
             }
         }
         
-        log.info("{} server-side tests executed at {}", 
-                children.size(), testParameters.getJunitServletPath());
+        log.info("Server-side tests executed at {} with path {}", 
+                testParameters.getJunitServletUrl(), subpath);
         
         // Check that number of tests is as expected
         assertEquals("Expecting " + testParameters.getExpectedNumberOfTests() + " tests",

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

Mime
View raw message