incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r857264 - in /websites/staging/sling/trunk/content: ./ documentation/development/sling-testing-tools.html
Date Thu, 04 Apr 2013 12:39:10 GMT
Author: buildbot
Date: Thu Apr  4 12:39:10 2013
New Revision: 857264

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/development/sling-testing-tools.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Apr  4 12:39:10 2013
@@ -1 +1 @@
-1464501
+1464504

Modified: websites/staging/sling/trunk/content/documentation/development/sling-testing-tools.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/sling-testing-tools.html
(original)
+++ websites/staging/sling/trunk/content/documentation/development/sling-testing-tools.html
Thu Apr  4 12:39:10 2013
@@ -93,11 +93,11 @@
 <li>Run integration tests via HTTP against a Sling instance that is started during
the Maven build cycle, or independently.</li>
 </ul>
 <p>This page describes those tools, and points to the bundles that implement them.</p>
-<p>The <a href="">testing/samples/integration-tests</a> module demonstrates
these tools, and is also meant as a sample project to show how to run integration tests for
Sling-based applications.</p>
-<p>The main Sling integration tests at <a href="">launchpad/integration-tests</a>
were created before this testing framework, and do not use it yet (as of March 2011). The
new testing tools are simpler to use, but the "old" tests (all 400 of them as I write this)
fulfill their validation role for testing Sling itself, there's no real need to modify them
to use the new tools.</p>
+<p>The <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests">testing/samples/integration-tests</a>
module demonstrates these tools, and is also meant as a sample project to show how to run
integration tests for Sling-based applications.</p>
+<p>The main Sling integration tests at <a href="https://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests">launchpad/integration-tests</a>
were created before this testing framework, and do not use it yet (as of March 2011). The
new testing tools are simpler to use, but the "old" tests (all 400 of them as I write this)
fulfill their validation role for testing Sling itself, there's no real need to modify them
to use the new tools.</p>
 <p>See also <a href="/documentation/tutorials-how-tos/testing-sling-based-applications.html">Testing
Sling-based applications</a> which discusses testing in general.</p>
 <h1 id="server-side-junit-tests-contributed-by-bundles">Server-side JUnit tests contributed
by bundles</h1>
-<p>The services provided by the <a href="">org.apache.sling.junit.core</a>
bundle allow bundles to register JUnit tests, which are executed server-side by the JUnitServlet
registered by default at <code>/system/sling/junit</code>. This bundle is not
dependent on Sling, it should work in other OSGi environments.</p>
+<p>The services provided by the <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/junit/core">org.apache.sling.junit.core</a>
bundle allow bundles to register JUnit tests, which are executed server-side by the JUnitServlet
registered by default at <code>/system/sling/junit</code>. This bundle is not
dependent on Sling, it should work in other OSGi environments.</p>
 <div class="warning">
 Note that the JUnitServlet does not require authentication, so it would allow any client
to run tests. The servlet can be disabled by configuration if needed, but in general the `/system`
path should not be accessible to website visitors anyway.
 </div>
@@ -106,13 +106,13 @@ Note that the JUnitServlet does not requ
 For tighter integration with Sling, the alternate `SlingJUnitServlet` is registered with
the `sling/junit/testing` resource type and `.junit` selector, if the bundle is running in
a Sling system. Using this servlet instead of the plain JUnitServlet also allows Sling authentication
to be used for running the tests, and the standard Sling request processing is used, including
servlet filters for example.
 </div>
 
-<p>To try the JUnitServlet interactively, install the <a href="">org.apache.sling.testing.samples.sampletests</a>
bundle.</p>
+<p>To try the JUnitServlet interactively, install the <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/sample-tests">org.apache.sling.testing.samples.sampletests</a>
bundle.</p>
 <p>This bundle contains a number of test classes, which are registered with the <code>org.apache.sling.junit.core</code>
services by way of the <code>Sling-Test-Regexp=.*Test</code> bundle header, defined
in the bundle's <code>pom.xml</code>. The JUnit core services use this regular
expression to select which classes of the test bundle should be executed as JUnit tests.</p>
 <p>To list the available tests, open http://localhost:8080/system/sling/junit/ . The
servlet shows available tests, and allows you to execute them via a POST request.</p>
 <p>Adding a path allows you to select a specific subset of tests, as in http://localhost:8080/system/sling/junit/org.apache.sling.junit.remote.html
- the example integration tests described below use this to selectively execute server-side
tests. The JUnitServlet provides various output formats, including in particular JSON, see
http://localhost:8080/system/sling/junit/.json for example.</p>
 <p>To supply tests from your own bundles, simply export the tests classes and add the
<code>Sling-Test-Regexp</code> header to the bundle so that the Sling JUnit core
services register them as tests.</p>
 <h3 id="injection-of-osgi-services">Injection of OSGi services</h3>
-<p>The <code>@TestReference</code> annotation is used to inject OSGi services
in tests that are executed server side.The <code>BundleContext</code> can also
be injected in this way, see the <a href="">OsgiAwareTest</a> for an example.</p>
+<p>The <code>@TestReference</code> annotation is used to inject OSGi services
in tests that are executed server side.The <code>BundleContext</code> can also
be injected in this way, see the <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/sample-tests/src/main/java/org/apache/sling/testing/samples/sampletests/OsgiAwareTest.java">OsgiAwareTest</a>
for an example.</p>
 <h2 id="curl-examples">Curl examples</h2>
 <p>Here's an example executing a few tests using curl:</p>
 <div class="codehilite"><pre><span class="nv">$</span> <span class="nv">curl</span>
<span class="o">-</span><span class="n">X</span> <span class="n">POST</span>
<span class="n">http:</span><span class="sr">//</span><span class="n">localhost:8080</span><span
class="sr">/system/s</span><span class="n">ling</span><span class="sr">/junit/o</span><span
class="n">rg</span><span class="o">.</span><span class="n">apache</span><span
class="o">.</span><span class="n">sling</span><span class="o">.</span><span
class="n">testing</span><span class="o">.</span><span class="n">samples</span><span
class="o">.</span><span class="n">sampletests</span><span class="o">.</span><span
class="n">JUnit</span><span class="o">.</span><span class="n">json</span>
@@ -133,22 +133,22 @@ For tighter integration with Sling, the 
 <p>And another example with a test that fails:
     $ curl -X POST http://localhost:8080/system/sling/junit/org.apache.sling.testing.samples.failingtests.JUnit4FailingTest.json</p>
 <h1 id="scriptable-server-side-tests">Scriptable server-side tests</h1>
-<p>If the <a href="">org.apache.sling.junit.scriptable</a> bundle is active
in a Sling system, (in addition to the <code>org.apache.sling.junit.core</code>
bundle), scriptable tests can be executed by the <code>JUnitServlet</code> according
to the following rules:</p>
+<p>If the <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/junit/scriptable">org.apache.sling.junit.scriptable</a>
bundle is active in a Sling system, (in addition to the <code>org.apache.sling.junit.core</code>
bundle), scriptable tests can be executed by the <code>JUnitServlet</code> according
to the following rules:</p>
 <ul>
 <li>A node that has the <code>sling:Test</code> mixin is a scriptable test
node.</li>
 <li>For security reasons, scriptable test nodes are only executed as tests if they
are found under <code>/libs</code> or <code>/apps</code>, or more
precisely under a path that's part of Sling's <code>ResourceResolver</code> search
path.</li>
 <li>To execute a test, the scriptable tests provider makes an HTTP requests to the
test node's path, with a <code>.test.txt</code> selector and extension, and expects
the output to contain only the string <code>TEST_PASSED</code>. Empty lines and
comment lines starting with a hash sign (#) are ignored in the output, and other lines are
reported as failures.</li>
 </ul>
-<p>The <a href="">ScriptableTestsTest</a> class, from the integration test
samples module described below, sets up such a test node and its accompanying script, and
calls the JUnitServlet to execute the test. It can be used as a detailed example of how this
works.</p>
+<p>The <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/scriptable/ScriptableTestsTest.java">ScriptableTestsTest</a>
class, from the integration test samples module described below, sets up such a test node
and its accompanying script, and calls the JUnitServlet to execute the test. It can be used
as a detailed example of how this works.</p>
 <h1 id="integration-tests-example">Integration tests example</h1>
-<p>The <a href="">testing/samples/integration-tests</a> module runs some
simple integration tests against a Sling Launchpad instance that's setup from scratch before
running the tests.</p>
+<p>The <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests">testing/samples/integration-tests</a>
module runs some simple integration tests against a Sling Launchpad instance that's setup
from scratch before running the tests.</p>
 <p>This module's pom and Java code can be used as examples to setup your own integration
testing modules for Sling-based apps - or for any other runnable jar that provides an http
service.</p>
 <p>Besides serving as examples, some of the tests in this module are used to validate
the testing tools. They run as part of the full Sling <a href="/project-information.html">continuous
integration</a> build, so they're guaranteed to be correct examples if that build is
successful.</p>
-<p>The sample uses the <a href="">testing/tools</a> to make the test code
simpler. See the [OsgiConsoleTest|https://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/http/OsgiConsoleTest.java]
class for an example of a test that's very readable and requires no test setup or boilerplate
code.</p>
+<p>The sample uses the <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/tools">testing/tools</a>
to make the test code simpler. See the [OsgiConsoleTest|https://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/http/OsgiConsoleTest.java]
class for an example of a test that's very readable and requires no test setup or boilerplate
code.</p>
 <p>The following steps are executed in the <code>integration-test</code>
phase of this module's Maven  build:
 1. A random port number for the Sling server is selected by the Maven build helper plugin,
unless explicitely set (see pom.xml for such options).
 1. Additional bundles, defined in the module's pom, are downloaded from the Maven repository
in the <code>target/sling/additional-bundles</code> folder.
-1. The first test that inherits from the <a href="">SlingTestBase</a> class causes
the Sling runnable jar (defined as a dependency in the module's pom) to be started. 
+1. The first test that inherits from the <a href="https://svn.apache.org/repos/asf/sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/sling/SlingTestBase.java">SlingTestBase</a>
class causes the Sling runnable jar (defined as a dependency in the module's pom) to be started.

 1. # The <code>SlingTestBase</code> class waits for the Sling server to be ready,
based on URLs and expected responses defined in the pom.
 1. # The <code>SlingTestBase</code> class installs and starts the bundles found
in the <code>target/sling/additional-bundles</code> folder.
 1. The test can now either test Sling directly via its http interface, or use the JUnitServlet
to execute server-side tests contributed by bundles or scripts, as described above.
@@ -158,13 +158,13 @@ For tighter integration with Sling, the 
 <h1 id="remote-test-execution">Remote test execution</h1>
 <p>The testing tools support two types of remote test execution.</p>
 <h2 id="slingremotetestrunner">SlingRemoteTestRunner</h2>
-<p>The <a href="">SlingRemoteTestRunner</a> is used to run tests using
the <code>JUnitServlet</code> described above. In this case, the client-side JUnit
test only defines which tests to run and some optional assertions. Checking the number of
tests executed, for example, can be useful to make sure all test bundles have been activated
as expected, to avoid ignoring missing test bundles.</p>
-<p>See the <a href="">ServerSideSampleTest</a> class for an example.</p>
+<p>The <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java">SlingRemoteTestRunner</a>
is used to run tests using the <code>JUnitServlet</code> described above. In this
case, the client-side JUnit test only defines which tests to run and some optional assertions.
Checking the number of tests executed, for example, can be useful to make sure all test bundles
have been activated as expected, to avoid ignoring missing test bundles.</p>
+<p>See the <a href="https://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/integrationtests/serverside/ServerSideSampleTest.java">ServerSideSampleTest</a>
class for an example.</p>
 <h2 id="slingremoteexecutionrule">SlingRemoteExecutionRule</h2>
-<p>The <a href="">SlingRemoteExecutionRule</a> is a JUnit Rule that allows
tests to be executed remotely in a Sling instance from an IDE, assuming the test is available
on both sides.</p>
-<p>The <a href="">ExampleRemoteTest</a> class demonstrates this. To run
it from your IDE, set the <code>sling.remote.test.url</code> in the IDE to the
URL of the JUnitServlet, like http://localhost:8080/system/sling/junit for example.</p>
+<p>The <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/ide/SlingRemoteExecutionRule.java">SlingRemoteExecutionRule</a>
is a JUnit Rule that allows tests to be executed remotely in a Sling instance from an IDE,
assuming the test is available on both sides.</p>
+<p>The <a href="https://svn.apache.org/repos/asf/sling/trunk/testing/junit/remote/src/main/java/org/apache/sling/junit/remote/exported/ExampleRemoteTest.java">ExampleRemoteTest</a>
class demonstrates this. To run it from your IDE, set the <code>sling.remote.test.url</code>
in the IDE to the URL of the JUnitServlet, like http://localhost:8080/system/sling/junit for
example.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1464501 by bdelacretaz on Thu, 4 Apr 2013 12:33:04 +0000
+        Rev. 1464504 by bdelacretaz on Thu, 4 Apr 2013 12:39:04 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message