sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r966325 - in /websites/staging/sling/trunk/content: ./ documentation/bundles/org-apache-sling-junit-bundles.html
Date Tue, 22 Sep 2015 10:07:45 GMT
Author: buildbot
Date: Tue Sep 22 10:07:42 2015
New Revision: 966325

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/bundles/org-apache-sling-junit-bundles.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Sep 22 10:07:42 2015
@@ -1 +1 @@
-1704503
+1704509

Modified: websites/staging/sling/trunk/content/documentation/bundles/org-apache-sling-junit-bundles.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/org-apache-sling-junit-bundles.html
(original)
+++ websites/staging/sling/trunk/content/documentation/bundles/org-apache-sling-junit-bundles.html
Tue Sep 22 10:07:42 2015
@@ -115,13 +115,6 @@ h2:hover > .headerlink, h3:hover > .head
 <p>This is an overview of the Sling bundles that provide support for server-side JUnit
tests. </p>
 <h2 id="orgapacheslingjunitcore-server-side-junit-tests-support">org.apache.sling.junit.core:
server-side JUnit tests support<a class="headerlink" href="#orgapacheslingjunitcore-server-side-junit-tests-support"
title="Permanent link">&para;</a></h2>
 <p>This bundle provides a <code>JUnitServlet</code> that runs JUnit tests
found in bundles. </p>
-<p>To make tests available to that servlet, the bundle that contains them must point
to them
-with a <code>Sling-Test-Regexp</code> bundle header that defines a regular expression
that matches
-the test class names, like for example:</p>
-<div class="codehilite"><pre><span class="n">Sling</span><span
class="o">-</span><span class="n">Test</span><span class="o">-</span><span
class="n">Regexp</span><span class="p">=</span><span class="n">com</span><span
class="p">.</span><span class="n">example</span><span class="o">.*</span><span
class="n">ServerSideTest</span>
-</pre></div>
-
-
 <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>
@@ -130,9 +123,18 @@ 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>The <code>TeleporterRule</code> supplied by this bundle makes it easy
to write such tests, using this
-rule they can be mixed with other tests in the source code if that's convenient. Here's a
basic example of such a
-"teleported" test that accesses OSGi services:</p>
+<p>To make tests available to that servlet, the bundle that contains them must point
to them
+with a <code>Sling-Test-Regexp</code> bundle header that defines a regular expression
that matches
+the test class names, like for example:</p>
+<div class="codehilite"><pre><span class="n">Sling</span><span
class="o">-</span><span class="n">Test</span><span class="o">-</span><span
class="n">Regexp</span><span class="p">=</span><span class="n">com</span><span
class="p">.</span><span class="n">example</span><span class="o">.*</span><span
class="n">ServerSideTest</span>
+</pre></div>
+
+
+<p>The <code>TeleporterRule</code> supplied by this bundle makes it easy
to write such tests, as it takes care of
+all the mechanics of creating the test bundle, adding the above header, installing it etc.</p>
+<p>Using this rule the server-side tests can be mixed with other tests in the source
code if that's convenient, it just
+requires the <code>junit.core</code>and <code>junit.teleporter</code>
modules described on this page to create such tests. </p>
+<p>Here's a basic example of a server-side test that accesses OSGi services:</p>
 <div class="codehilite"><pre><span class="n">public</span> <span
class="n">class</span> <span class="n">BasicTeleporterTest</span> <span
class="p">{</span>
 
     <span class="p">@</span><span class="n">Rule</span>
@@ -153,6 +155,7 @@ rule they can be mixed with other tests
 </pre></div>
 
 
+<p>That's all there is to it, the <code>TeleporterRule</code> takes care
of the rest.     </p>
 <p>Using the teleporter module described below, the <code>TeleporterRule</code>
creates a temporary bundle 
 that contains the test class along with any classes required to run it, adds the appropriate

 <code>Sling-Test-Regexp</code> header to it, installs the bundle, runs the test
via the <code>JUnitServlet</code>,
@@ -163,6 +166,10 @@ with the appropriate IDE settings.</p>
 for examples or look at the 
 <a href="https://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/teleporter"><code>integrationtest.teleporter</code></a>
 package. </p>
+<p>As I write this the teleporter mechanism is quite new, I suspect there might be
some weird interactions 
+between things like <code>@AfterClass</code>, custom test runners and this mechanism
but it works well to a growing
+number of tests in our <code>launchpad/integration-tests</code> module. Moving
to JUnit <code>Rules</code> as much as possible, 
+and combining them using JUnit's <code>RuleChain</code>, should help work around
such limitations if they arise.</p>
 <h3 id="more-details-on-the-junitservlet">More details on the JUnitServlet<a class="headerlink"
href="#more-details-on-the-junitservlet" title="Permanent link">&para;</a></h3>
 <p>To try the JUnitServlet interactively, you can install the 
 <a href="http://svn.apache.org/repos/asf/sling/trunk/testing/samples/sample-tests">org.apache.sling.testing.samples.sampletests</a>

@@ -236,7 +243,7 @@ same request again.      </p>
 but using the newer <code>TeleporterRule</code> described above is much simpler.
As a result, this bundle
 should only be needed for existing tests that were written using its mechanisms.   </p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1704503 by bdelacretaz on Tue, 22 Sep 2015 09:58:34 +0000
+        Rev. 1704509 by bdelacretaz on Tue, 22 Sep 2015 10:07:27 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message