incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1073752 - in /sling/trunk/testing: ./ junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/ samples/failing-tests/ samples/failing-tests/src/ samples/failing-tests/src/main/ samples/failing-tests/src/main/java/ samples/faili...
Date Wed, 23 Feb 2011 14:17:59 GMT
Author: bdelacretaz
Date: Wed Feb 23 14:17:58 2011
New Revision: 1073752

URL: http://svn.apache.org/viewvc?rev=1073752&view=rev
Log:
SLING-1963 - use failingtests bundle to verify that server-side test failures are correctly
reported

Added:
    sling/trunk/testing/samples/failing-tests/   (with props)
    sling/trunk/testing/samples/failing-tests/pom.xml   (with props)
    sling/trunk/testing/samples/failing-tests/src/
    sling/trunk/testing/samples/failing-tests/src/main/
    sling/trunk/testing/samples/failing-tests/src/main/java/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/junit/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/junit/samples/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/junit/samples/failingtests/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
  (with props)
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
  (with props)
    sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
  (with props)
    sling/trunk/testing/samples/sample-tests/
      - copied from r1073087, sling/trunk/testing/samples/testbundle/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/junit/sampletests/
      - copied from r1073087, sling/trunk/testing/samples/testbundle/src/main/java/org/apache/sling/junit/testbundle/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/
      - copied from r1073087, sling/trunk/testing/samples/testbundle/src/main/java/org/apache/sling/junit/testbundle/tests/
    sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
  (with props)
Removed:
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/junit/sampletests/tests/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/junit/testbundle/
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/MissingTest.java
    sling/trunk/testing/samples/testbundle/
Modified:
    sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java
    sling/trunk/testing/pom.xml
    sling/trunk/testing/samples/sample-tests/pom.xml
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit3Test.java
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit4Test.java
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java
    sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/SomeOtherClass.java
    sling/trunk/testing/samples/test-tools/pom.xml
    sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/JSONResponseTest.java
    sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/ServerSideTest.java

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=1073752&r1=1073751&r2=1073752&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
Wed Feb 23 14:17:58 2011
@@ -84,7 +84,7 @@ public class SlingRemoteTestRunner exten
         builder = new RequestBuilder(testParameters.getServerBaseUrl());
         
         // POST request executes the tests
-        final Request r = builder.buildPostRequest(testParameters.getJunitServletPath() +
"/.json");
+        final Request r = builder.buildPostRequest(testParameters.getJunitServletPath() +
".json");
         executor.execute(r)
         .assertStatus(200)
         .assertContentType("application/json");

Modified: sling/trunk/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/pom.xml?rev=1073752&r1=1073751&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/pom.xml (original)
+++ sling/trunk/testing/pom.xml Wed Feb 23 14:17:58 2011
@@ -43,10 +43,8 @@
         <module>junit/core</module>
         <module>junit/scriptable</module>
         <module>junit/remote</module>
-        <module>samples/testbundle</module>
-
-        <!-- TODO cannot enable yet, uses unreleased Stanbol snapshots
         <module>samples/test-tools</module>
-        -->
+        <module>samples/sample-tests</module>
+        <module>samples/failing-tests</module>
     </modules>
 </project>

Propchange: sling/trunk/testing/samples/failing-tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb 23 14:17:58 2011
@@ -0,0 +1,14 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
+
+

Added: sling/trunk/testing/samples/failing-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/failing-tests/pom.xml?rev=1073752&view=auto
==============================================================================
--- sling/trunk/testing/samples/failing-tests/pom.xml (added)
+++ sling/trunk/testing/samples/failing-tests/pom.xml Wed Feb 23 14:17:58 2011
@@ -0,0 +1,102 @@
+<?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>10</version>
+    </parent>
+
+    <artifactId>org.apache.sling.testing.samples.failingtests</artifactId>
+    <version>0.1.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Failing Server-Side Tests</name>
+    <description>Bundle that supplies server-side tests that fail, to test the Sling
JUnit extensions</description>
+    
+    <properties>
+        <junit.version>4.8.2</junit.version>
+    </properties>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/samples/failing-tests</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/samples/failing-tests</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/samples/failing-tests</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.apache.sling.extensions.junit.failingtests.*</Export-Package>
+                        <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <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.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.4.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.5.11</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <!-- TODO create separate API package, this is just to get the special Sling
test runner -->
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.junit.core</artifactId>
+            <version>0.1.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        
+    </dependencies>
+</project>

Propchange: sling/trunk/testing/samples/failing-tests/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java?rev=1073752&view=auto
==============================================================================
--- sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
(added)
+++ sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
Wed Feb 23 14:17:58 2011
@@ -0,0 +1,23 @@
+/*
+ * 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.failingtests;
+
+/** JUnit should complain that this class doesn't contain
+ *  any tests.
+ */
+public class EmptyTest {
+}

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/EmptyTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java?rev=1073752&view=auto
==============================================================================
--- sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
(added)
+++ sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
Wed Feb 23 14:17:58 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.failingtests;
+
+import junit.framework.TestCase;
+
+/** Example failing tests using the JUnit3 APIs */
+public class JUnit3FailingTest extends TestCase {
+    public void testFailsEveryTime() {
+        fail("This JUnit3 test fails every time");
+    }
+
+    public void testAssertsEveryTime() {
+        assertTrue("This JUnit3 test asserts every time", false);
+    }
+}

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit3FailingTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java?rev=1073752&view=auto
==============================================================================
--- sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
(added)
+++ sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
Wed Feb 23 14:17:58 2011
@@ -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.
+ */
+package org.apache.sling.testing.samples.failingtests;
+
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import org.junit.Test;
+
+/** Example failing tests using the JUnit3 APIs */
+public class JUnit4FailingTest {
+    
+    @Test
+    public void testFailsEveryTime() {
+        fail("This JUnit4 test fails every time");
+    }
+
+    @Test
+    public void testAssertsEveryTime() {
+        assertTrue("This JUnit4 test asserts every time", false);
+    }
+}

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/samples/failing-tests/src/main/java/org/apache/sling/testing/samples/failingtests/JUnit4FailingTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/testing/samples/sample-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests/pom.xml?rev=1073752&r1=1073087&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/sample-tests/pom.xml (original)
+++ sling/trunk/testing/samples/sample-tests/pom.xml Wed Feb 23 14:17:58 2011
@@ -26,21 +26,21 @@
         <version>10</version>
     </parent>
 
-    <artifactId>org.apache.sling.testing.samples.testbundle</artifactId>
+    <artifactId>org.apache.sling.testing.samples.sampletests</artifactId>
     <version>0.1.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
-    <name>Apache Sling Tests Sample Bundle</name>
-    <description>Provides test classes to test the Sling JUnit extensions</description>
+    <name>Apache Sling Sample Server-Side Tests</name>
+    <description>Bundle that supplies sample server-side test classes for the Sling
JUnit extensions</description>
     
     <properties>
         <junit.version>4.8.2</junit.version>
     </properties>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/samples/testbundle</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/samples/testbundle</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/samples/testbundle</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/samples/sample-tests</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/samples/sample-tests</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests</url>
     </scm>
 
     <build>
@@ -55,7 +55,7 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Export-Package>org.apache.sling.extensions.junit.testbundle.*</Export-Package>
+                        <Export-Package>org.apache.sling.extensions.junit.sampletests.*</Export-Package>
                         <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
                     </instructions>
                 </configuration>

Modified: sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit3Test.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit3Test.java?rev=1073752&r1=1073087&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit3Test.java
(original)
+++ sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit3Test.java
Wed Feb 23 14:17:58 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.testbundle.tests;
+package org.apache.sling.testing.samples.sampletests;
 
 import junit.framework.TestCase;
 
@@ -22,14 +22,4 @@ import junit.framework.TestCase;
 public class JUnit3Test extends TestCase {
     public void testPasses() {
     }
-    
-    public void testFailsEveryTime() {
-        fail("This JUnit3 test fails every time");
-    }
-    
-    public void testFailsSometimes() {
-        if(Math.random() > 0.5) {
-            fail("This JUnit3 test fails 50% of the time");
-        }
-    }
 }

Modified: sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit4Test.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit4Test.java?rev=1073752&r1=1073087&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit4Test.java
(original)
+++ sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/JUnit4Test.java
Wed Feb 23 14:17:58 2011
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.testbundle.tests;
+package org.apache.sling.testing.samples.sampletests;
 
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import org.junit.After;
 import org.junit.Before;
@@ -45,16 +44,4 @@ public class JUnit4Test {
     public void testRequiresBefore() {
         assertNotNull(title);
     }
-    
-    @Test
-    public void testFailsEveryTime() {
-        fail("This JUnit4 test fails every time");
-    }
-    
-    @Test
-    public void testFailsSometimes() {
-        if(Math.random() > 0.5) {
-            fail("This JUnit4 test fails 50% of the time");
-        }
-    }
 }
\ No newline at end of file

Modified: sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java?rev=1073752&r1=1073087&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java
(original)
+++ sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java
Wed Feb 23 14:17:58 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.testbundle.tests;
+package org.apache.sling.testing.samples.sampletests;
 
 import static org.junit.Assert.assertNotNull;
 
@@ -22,6 +22,7 @@ import org.apache.sling.junit.annotation
 import org.apache.sling.junit.annotations.TestReference;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
 
@@ -36,10 +37,14 @@ public class OsgiAwareTest {
     private BundleContext bundleContext;
     
     @Test
-    public void testConfigAdmin() {
+    public void testConfigAdmin() throws Exception {
         assertNotNull(
                 "Expecting ConfigurationAdmin to be injected by Sling test runner", 
                 configAdmin);
+        
+        final String name = "TEST_" + getClass().getName() + System.currentTimeMillis();
+        assertNotNull("Expecting config " + name + " to be created",
+                configAdmin.getConfiguration(name));
     }
     
     @Test
@@ -47,5 +52,16 @@ public class OsgiAwareTest {
         assertNotNull(
                 "Expecting BundleContext to be injected by Sling test runner", 
                 bundleContext);
+        
+        final String mySymbolicName = "org.apache.sling.testing.samples.sampletests";
+        Bundle thisBundle = null;
+        for(Bundle b : bundleContext.getBundles()) {
+            if(mySymbolicName.equals(b.getSymbolicName())) {
+                thisBundle = b;
+                break;
+            }
+        }
+        
+        assertNotNull("Expecting to find Bundle " + mySymbolicName, thisBundle);
     }
 }

Modified: sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/SomeOtherClass.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/SomeOtherClass.java?rev=1073752&r1=1073087&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/SomeOtherClass.java
(original)
+++ sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/SomeOtherClass.java
Wed Feb 23 14:17:58 2011
@@ -14,10 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.junit.testbundle.tests;
+package org.apache.sling.testing.samples.sampletests;
 
-/** Verify that this class is not included in the list
- *  of tests (due to the Sling-Test-Regexp bundle header.
+/** This class should not be included in the list
+ *  of tests, due to our Sling-Test-Regexp bundle header.
  */
 public class SomeOtherClass {
 

Modified: sling/trunk/testing/samples/test-tools/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/test-tools/pom.xml?rev=1073752&r1=1073751&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/test-tools/pom.xml (original)
+++ sling/trunk/testing/samples/test-tools/pom.xml Wed Feb 23 14:17:58 2011
@@ -106,7 +106,7 @@
                         <configuration>
                             <outputDirectory>${project.build.directory}/sling/additional-bundles</outputDirectory>
                             <includeArtifactIds>
-                                org.apache.sling.junit.core,org.apache.sling.testing.samples.testbundle,org.apache.sling.junit.scriptable
+                                org.apache.sling.junit.core,org.apache.sling.testing.samples.sampletests,org.apache.sling.junit.core,org.apache.sling.testing.samples.failingtests,org.apache.sling.junit.scriptable
                             </includeArtifactIds>
                             <excludeTransitive>true</excludeTransitive>
                             <overWriteReleases>false</overWriteReleases>
@@ -173,7 +173,13 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.samples.testbundle</artifactId>
+            <artifactId>org.apache.sling.testing.samples.sampletests</artifactId>
+            <version>0.1.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.samples.failingtests</artifactId>
             <version>0.1.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>

Added: sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java?rev=1073752&view=auto
==============================================================================
--- sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
(added)
+++ sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
Wed Feb 23 14:17:58 2011
@@ -0,0 +1,92 @@
+/*
+ * 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.testtools.serverside;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.commons.json.JSONTokener;
+import org.apache.stanbol.commons.testing.http.Request;
+import org.junit.Test;
+
+/** Verify that failures are correctly reported, using
+ *  tests from the failingtests bundle.
+ */
+public class FailingTestsTest extends ServerSideTestsBase {
+    
+    public static final String FAILURE_FIELD = "failure";
+    public static final String DESCRIPTION_FIELD = "description";
+    
+    /** Extract the "failure" field of given test in JSON
+     *  response data. 
+     */
+    private String getFailure(JSONArray json, String testName) throws JSONException {
+        String result = null;
+        
+        for(int i = 0 ; i < json.length(); i++) {
+            final JSONObject obj = json.getJSONObject(i);
+            if("test".equals(obj.getString("INFO_TYPE"))) {
+                if(obj.getString(DESCRIPTION_FIELD).contains(testName)) {
+                    if(obj.has(FAILURE_FIELD)) {
+                        result = obj.getString(FAILURE_FIELD);
+                        break;
+                    }
+                }
+            }
+        }
+        
+        return result;
+    }
+    
+    @Test
+    public void testFailures() throws Exception{
+        
+        // Execute tests from the failingtests bundle and verify response
+        final Request r = builder.buildPostRequest(JUNIT_SERVLET_PATH 
+                + "/org.apache.sling.testing.samples.failingtests.json");
+        executor.execute(r).assertStatus(200);
+        
+        final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));
+        
+        assertEquals(
+                "initializationError(org.apache.sling.testing.samples.failingtests.EmptyTest):
No runnable methods",
+                getFailure(json, "org.apache.sling.testing.samples.failingtests.EmptyTest")
+        );
+        
+        assertEquals(
+                "testFailsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit3FailingTest):
This JUnit3 test fails every time",
+                getFailure(json, "testFailsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit3FailingTest")
+        );
+        
+        assertEquals(
+                "testAssertsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit3FailingTest):
This JUnit3 test asserts every time",
+                getFailure(json, "testAssertsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit3FailingTest")
+        );
+        
+        assertEquals(
+                "testFailsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit4FailingTest):
This JUnit4 test fails every time",
+                getFailure(json, "org.apache.sling.testing.samples.failingtests.JUnit4FailingTest")
+        );
+        
+        assertEquals(
+                "testAssertsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit4FailingTest):
This JUnit4 test asserts every time",
+                getFailure(json, "testAssertsEveryTime(org.apache.sling.testing.samples.failingtests.JUnit4FailingTest")
+        );
+    }
+}
\ No newline at end of file

Propchange: sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/FailingTestsTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/JSONResponseTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/JSONResponseTest.java?rev=1073752&r1=1073751&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/JSONResponseTest.java
(original)
+++ sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/JSONResponseTest.java
Wed Feb 23 14:17:58 2011
@@ -16,13 +16,13 @@
  */
 package org.apache.sling.testing.samples.testtools.serverside;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
 import java.util.List;
 
 import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.commons.json.JSONTokener;
 import org.apache.stanbol.commons.testing.http.Request;
@@ -63,6 +63,22 @@ public class JSONResponseTest extends Se
         log.info("{} (timeout={} seconds)", c.getDescription(), TEST_LIST_TIMEOUT_SECONDS);
         new RetryLoop(c, TEST_LIST_TIMEOUT_SECONDS, 500);
     }
+    
+    private boolean findTestName(JSONArray json, String name) throws JSONException {
+        for(int i = 0 ; i < json.length(); i++) {
+            final JSONObject obj = json.getJSONObject(i);
+            if("list".equals(obj.getString("INFO_TYPE")) && "testNames".equals(obj.getString("INFO_SUBTYPE")))
{
+                final JSONArray data = obj.getJSONArray("data");
+                for(int j=0; j < data.length(); j++) {
+                    if(name.equals(data.getString(j))) {
+                        return true;
+                    }
+                }
+            }
+        }
+        log.info("Test name not found in JSON response: {}", name);
+        return false;
+    }
 
     private void testJsonListOfTests() throws Exception {
         Request r = builder.buildGetRequest(JUNIT_SERVLET_PATH + "/.json");
@@ -75,38 +91,21 @@ public class JSONResponseTest extends Se
         // Parse JSON response for more precise testing
         final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));
         
-        // Verify that all our test names are in the response
+        // Verify that some test names are present in the response
         final List<String> expectedTestNames = Arrays.asList(new String []{
-                "org.apache.sling.junit.scriptable.ScriptableTestsProvider",
-                "org.apache.sling.junit.testbundle.tests.JUnit3Test",
-                "org.apache.sling.junit.testbundle.tests.JUnit4Test",
-                "org.apache.sling.junit.testbundle.tests.MissingTest",
-                "org.apache.sling.junit.testbundle.tests.OsgiAwareTest"
+                "org.apache.sling.testing.samples.failingtests.EmptyTest",
+                "org.apache.sling.testing.samples.failingtests.JUnit3FailingTest",
+                "org.apache.sling.testing.samples.failingtests.JUnit4FailingTest",
+                "org.apache.sling.testing.samples.sampletests.JUnit3Test",
+                "org.apache.sling.testing.samples.sampletests.JUnit4Test",
+                "org.apache.sling.testing.samples.sampletests.OsgiAwareTest",
+                "org.apache.sling.junit.scriptable.ScriptableTestsProvider"
         });
-
-        // Response contains an array of objects identified by 
-        // their INFO_TYPE and INFO_SUBTYPE: check the one
-        // that has type=list and subtype=testNames
-        boolean dataFound = false;
-        for(int i = 0 ; i < json.length(); i++) {
-            final JSONObject obj = json.getJSONObject(i);
-            if("list".equals(obj.getString("INFO_TYPE")) && "testNames".equals(obj.getString("INFO_SUBTYPE")))
{
-                dataFound = true;
-                final JSONArray data = obj.getJSONArray("data");
-                assertEquals("Expecting correct number of tests", expectedTestNames.size(),
data.length());
-                
-                int matched = 0;
-                for(int j=0; j < data.length(); j++) {
-                    if(expectedTestNames.contains(data.getString(j))) {
-                        matched++;
-                    }
-                }
-                assertEquals("Expecting to find all test names in data array", expectedTestNames.size(),
matched);
-            }
-        }
         
-        if(!dataFound) {
-            fail("Test names object not found in response");
+        for(String name : expectedTestNames) {
+            assertTrue(
+                    "Expecting test name " + name + " in json response", 
+                    findTestName(json, name));
         }
     }
 }
\ No newline at end of file

Modified: sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/ServerSideTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/ServerSideTest.java?rev=1073752&r1=1073751&r2=1073752&view=diff
==============================================================================
--- sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/ServerSideTest.java
(original)
+++ sling/trunk/testing/samples/test-tools/src/test/java/org/apache/sling/testing/samples/testtools/serverside/ServerSideTest.java
Wed Feb 23 14:17:58 2011
@@ -25,12 +25,15 @@ import org.junit.runner.RunWith;
 @RunWith(SlingRemoteTestRunner.class)
 public class ServerSideTest extends ServerSideTestsBase implements SlingRemoteTestParameters
{
     
+    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 11;
+        return TESTS_AT_THIS_PATH;
     }
 
     public String getJunitServletPath() {
-        return JUNIT_SERVLET_PATH;
+        return JUNIT_SERVLET_PATH + "/" + TEST_SELECTOR;
     }
 
     public String getServerBaseUrl() {



Mime
View raw message