incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1080639 - in /sling/trunk/testing: junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/ samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ samples/integration-tests/src/tes...
Date Fri, 11 Mar 2011 16:28:10 GMT
Author: bdelacretaz
Date: Fri Mar 11 16:28:09 2011
New Revision: 1080639

URL: http://svn.apache.org/viewvc?rev=1080639&view=rev
Log:
SLING-2027 - SlingRemoteTestParameters: make tests count check optional

Added:
    sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
  (with props)
Modified:
    sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
    sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/DontCareForTestsCountTest.java
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/SingleServerSideMethodTest.java
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideSingleMethodTest.java
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideTest.java

Modified: sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
(original)
+++ sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestParameters.java
Fri Mar 11 16:28:09 2011
@@ -32,9 +32,4 @@ public interface SlingRemoteTestParamete
      *  for example "someMethodName"
      */
     String getTestMethodSelector();
-    
-    /** Return the expected number of tests - if zero, no check
-     *  is done.
-     */
-    int getExpectedNumberOfTests();
 }

Modified: sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
(original)
+++ sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
Fri Mar 11 16:28:09 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.sling.junit.remote.testrunner;
 
-import static org.junit.Assert.assertEquals;
-
 import java.util.LinkedList;
 import java.util.List;
 
@@ -96,11 +94,9 @@ public class SlingRemoteTestRunner exten
         log.info("Server-side tests executed at {} with path {}", 
                 testParameters.getJunitServletUrl(), testHttpClient.getTestExecutionPath());
         
-        // Check that number of tests is as expected
-        if(testParameters.getExpectedNumberOfTests() >= 0) {
-            assertEquals("Expecting " + testParameters.getExpectedNumberOfTests() + " tests",
-                    testParameters.getExpectedNumberOfTests(),
-                    children.size());
+        // Optionally check that number of tests is as expected
+        if(testParameters instanceof SlingTestsCountChecker) {
+            ((SlingTestsCountChecker)testParameters).checkNumberOfTests(children.size());
         }
     }
     

Added: sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java?rev=1080639&view=auto
==============================================================================
--- sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
(added)
+++ sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
Fri Mar 11 16:28:09 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.junit.remote.testrunner;
+
+/** Tests classes can implement this interface to check the
+ *  number of tests that are executed remotely. This is useful
+ *  when tests are loaded dynamically, to check that all the required
+ *  tests have indeed been executed, for example in continuous
+ *  integration.
+ */
+public interface SlingTestsCountChecker {
+    void checkNumberOfTests(int numberOfTestsExecuted);
+}

Propchange: sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingTestsCountChecker.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/DontCareForTestsCountTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/DontCareForTestsCountTest.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/DontCareForTestsCountTest.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/DontCareForTestsCountTest.java
Fri Mar 11 16:28:09 2011
@@ -16,16 +16,28 @@
  */
 package org.apache.sling.testing.samples.integrationtests.serverside;
 
+import org.apache.sling.junit.remote.testrunner.SlingRemoteTestParameters;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestRunner;
 import org.junit.runner.RunWith;
 
-/** Run server-side tests from the sampletests bundle */
+/** Run server-side tests from the sampletests bundle, without
+ *  checking the number of tests executed (by not implementing
+ *  {@link SlingTestsCountChecker} */
 @RunWith(SlingRemoteTestRunner.class)
-public class DontCareForTestsCountTest extends ServerSideSampleTest {
+public class DontCareForTestsCountTest extends ServerSideTestsBase 
+implements SlingRemoteTestParameters {
+
+    public static final String TEST_SELECTOR = "org.apache.sling.testing.samples.sampletests";
     
-    public int getExpectedNumberOfTests() {
-        // Negative value here means "don't care", check that
-        // this test passes with this value 
-        return -1;
+    public String getJunitServletUrl() {
+        return getServerBaseUrl() + JUNIT_SERVLET_PATH;
+    }
+
+    public String getTestClassesSelector() {
+        return TEST_SELECTOR;
+    }
+
+    public String getTestMethodSelector() {
+        return null;
     }
 }
\ No newline at end of file

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java
Fri Mar 11 16:28:09 2011
@@ -16,17 +16,24 @@
  */
 package org.apache.sling.testing.samples.integrationtests.serverside;
 
+import static org.junit.Assert.assertEquals;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestParameters;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestRunner;
+import org.apache.sling.junit.remote.testrunner.SlingTestsCountChecker;
 import org.junit.runner.RunWith;
 
 /** Run some server-side tests */
 @RunWith(SlingRemoteTestRunner.class)
-public class ServerSideSampleTest extends ServerSideTestsBase implements SlingRemoteTestParameters
{
+public class ServerSideSampleTest extends ServerSideTestsBase 
+implements SlingRemoteTestParameters, SlingTestsCountChecker {
     
     public static final String TEST_SELECTOR = "org.apache.sling.testing.samples.sampletests";
     public static final int TESTS_AT_THIS_PATH = 5;
     
+    public void checkNumberOfTests(int numberOfTestsExecuted) {
+        assertEquals(TESTS_AT_THIS_PATH, numberOfTestsExecuted);
+    }
+
     public int getExpectedNumberOfTests() {
         return TESTS_AT_THIS_PATH;
     }

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/SingleServerSideMethodTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/SingleServerSideMethodTest.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/SingleServerSideMethodTest.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/SingleServerSideMethodTest.java
Fri Mar 11 16:28:09 2011
@@ -16,20 +16,24 @@
  */
 package org.apache.sling.testing.samples.integrationtests.serverside;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestParameters;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestRunner;
+import org.apache.sling.junit.remote.testrunner.SlingTestsCountChecker;
 import org.junit.runner.RunWith;
 
 /** Run a single test method from a servet-side test */ 
 @RunWith(SlingRemoteTestRunner.class)
-public class SingleServerSideMethodTest extends ServerSideTestsBase implements SlingRemoteTestParameters
{
+public class SingleServerSideMethodTest extends ServerSideTestsBase 
+implements SlingRemoteTestParameters, SlingTestsCountChecker {
     
     public static final String TEST_CLASS = "org.apache.sling.testing.samples.sampletests.JUnit4Test";
     public static final String TEST_METHOD = "testRequiresBefore";
     public static final int TESTS_AT_THIS_PATH = 1;
 
-    public int getExpectedNumberOfTests() {
-        return TESTS_AT_THIS_PATH;
+    public void checkNumberOfTests(int numberOfTestsExecuted) {
+        assertEquals(TESTS_AT_THIS_PATH, numberOfTestsExecuted);
     }
 
     public String getJunitServletUrl() {

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideSingleMethodTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideSingleMethodTest.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideSingleMethodTest.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideSingleMethodTest.java
Fri Mar 11 16:28:09 2011
@@ -16,19 +16,23 @@
  */
 package org.apache.sling.testing.samples.integrationtests.serverside.sling;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestParameters;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestRunner;
+import org.apache.sling.junit.remote.testrunner.SlingTestsCountChecker;
 import org.junit.runner.RunWith;
 
 /** Run a single server-side test method using the Sling JUnit servlet */
 @RunWith(SlingRemoteTestRunner.class)
-public class SlingServerSideSingleMethodTest extends SlingServerSideTestsBase implements
SlingRemoteTestParameters{
+public class SlingServerSideSingleMethodTest extends SlingServerSideTestsBase 
+implements SlingRemoteTestParameters, SlingTestsCountChecker {
     public static final String TEST_CLASS = "org.apache.sling.testing.samples.sampletests.JUnit4Test";
     public static final String TEST_METHOD = "testRequiresBefore";
     public static final int TESTS_AT_THIS_PATH = 1;
 
-    public int getExpectedNumberOfTests() {
-        return TESTS_AT_THIS_PATH;
+    public void checkNumberOfTests(int numberOfTestsExecuted) {
+        assertEquals(TESTS_AT_THIS_PATH, numberOfTestsExecuted);
     }
 
     public String getJunitServletUrl() {

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideTest.java?rev=1080639&r1=1080638&r2=1080639&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideTest.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/sling/SlingServerSideTest.java
Fri Mar 11 16:28:09 2011
@@ -16,19 +16,23 @@
  */
 package org.apache.sling.testing.samples.integrationtests.serverside.sling;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestParameters;
 import org.apache.sling.junit.remote.testrunner.SlingRemoteTestRunner;
+import org.apache.sling.junit.remote.testrunner.SlingTestsCountChecker;
 import org.junit.runner.RunWith;
 
 /** Run some server-side tests using the Sling JUnit servlet */
 @RunWith(SlingRemoteTestRunner.class)
-public class SlingServerSideTest extends SlingServerSideTestsBase implements SlingRemoteTestParameters
{
+public class SlingServerSideTest extends SlingServerSideTestsBase 
+implements SlingRemoteTestParameters, SlingTestsCountChecker {
     
     public static final String TEST_SELECTOR = "org.apache.sling.testing.samples.sampletests";
     public static final int TESTS_AT_THIS_PATH = 5;
     
-    public int getExpectedNumberOfTests() {
-        return TESTS_AT_THIS_PATH;
+    public void checkNumberOfTests(int numberOfTestsExecuted) {
+        assertEquals(TESTS_AT_THIS_PATH, numberOfTestsExecuted);
     }
     
     public String getJunitServletUrl() {



Mime
View raw message