Author: rafabene
Date: Wed Feb  4 19:23:37 2015
New Revision: 1657385

URL: http://svn.apache.org/r1657385
Log:
Site checkin for project Apache DeltaSpike Documentation

Modified:
    deltaspike/site/trunk/content/documentation/test-control.html

Modified: deltaspike/site/trunk/content/documentation/test-control.html
URL: 
http://svn.apache.org/viewvc/deltaspike/site/trunk/content/documentation/test-control.html?rev=1657385&r1=1657384&r2=1657385&view=diff
==============================================================================
--- deltaspike/site/trunk/content/documentation/test-control.html (original)
+++ deltaspike/site/trunk/content/documentation/test-control.html Wed Feb  4 
19:23:37 2015
@@ -736,14 +736,15 @@ constructor) and specify the target-type
 <div class="sect2">
 <h3 id="_using_jersey_test_with_test_control">Using jersey-test with 
test-control</h3>
 <div class="paragraph">
-<p>jersey-test starts jetty which answers requests in a separated thread. 
since ds test-control just handles the thread of the test itself, it&#8217;s 
needed to integrate jetty and jersey with the cdi-container. usually 
that&#8217;s done via a ServletRequestListener - the following part describes 
an alternative approach for jersey-test:</p>
+<p>Jersey-test starts jetty which answers requests in a separated thread. 
Since ds test-control just handles the thread of the test itself, it&#8217;s 
needed to integrate jetty and jersey with the cdi-container. Usually 
that&#8217;s done via a ServletRequestListener - the following part describes 
an alternative approach for jersey-test:</p>
 </div>
 <div class="listingblock">
 <div class="content">
 <pre class="CodeRay highlight"><code data-lang="java"><span 
class="comment">//use: 
-Djersey.config.test.container.factory=custom.CdiAwareJettyTestContainerFactory</span>
 
 <span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span 
class="class">SimpleCdiAndJaxRsTest</span> <span 
class="directive">extends</span> JerseyTest {
+<span class="directive">public</span> <span class="type">class</span> <span 
class="class">SimpleCdiAndJaxRsTest</span> <span 
class="directive">extends</span> JerseyTest
+{
   <span class="comment">//...</span>
 }</code></pre>
 </div>
@@ -753,23 +754,28 @@ constructor) and specify the target-type
 </div>
 <div class="listingblock">
 <div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span 
class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareJerseyTest</span> <span class="directive">extends</span> 
JerseyTest {
-    <span class="directive">static</span> {
-        <span class="predefined-type">System</span>.setProperty(<span 
class="string"><span class="delimiter">&quot;</span><span 
class="content">jersey.config.test.container.factory</span><span 
class="delimiter">&quot;</span></span>,CdiAwareJettyTestContainerFactory.class.getName());
+<pre class="CodeRay highlight"><code data-lang="java"><span 
class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareJerseyTest</span> <span class="directive">extends</span> 
JerseyTest
+{
+    <span class="directive">static</span>
+    {
+        <span class="predefined-type">System</span>.setProperty(<span 
class="string"><span class="delimiter">&quot;</span><span 
class="content">jersey.config.test.container.factory</span><span 
class="delimiter">&quot;</span></span>, 
CdiAwareJettyTestContainerFactory.class.getName());
     }
 }
 
 <span class="annotation">@RunWith</span>(CdiTestRunner.class)
-<span class="directive">public</span> <span class="type">class</span> <span 
class="class">SimpleCdiAndJaxRsTest</span> <span 
class="directive">extends</span> CdiAwareJerseyTest {
+<span class="directive">public</span> <span class="type">class</span> <span 
class="class">SimpleCdiAndJaxRsTest</span> <span 
class="directive">extends</span> CdiAwareJerseyTest
+{
     <span class="comment">//...</span>
 }</code></pre>
 </div>
 </div>
 <div class="listingblock">
 <div class="content">
-<pre class="CodeRay highlight"><code data-lang="java"><span 
class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareJettyTestContainerFactory</span> <span 
class="directive">implements</span> TestContainerFactory {
+<pre class="CodeRay highlight"><code data-lang="java"><span 
class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareJettyTestContainerFactory</span> <span 
class="directive">implements</span> TestContainerFactory
+{
     <span class="annotation">@Override</span>
-    <span class="directive">public</span> TestContainer create(<span 
class="directive">final</span> <span class="predefined-type">URI</span> 
baseUri, <span class="directive">final</span> DeploymentContext context) <span 
class="directive">throws</span> <span 
class="exception">IllegalArgumentException</span> {
+    <span class="directive">public</span> TestContainer create(<span 
class="directive">final</span> <span class="predefined-type">URI</span> 
baseUri, <span class="directive">final</span> DeploymentContext context) <span 
class="directive">throws</span> <span 
class="exception">IllegalArgumentException</span>
+    {
         <span class="keyword">return</span> <span class="keyword">new</span> 
CdiAwareJettyTestContainer(baseUri, context);
     }
 }</code></pre>
@@ -791,15 +797,20 @@ cdiHandlerWrapper.setHandler(<span class
 <div class="listingblock">
 <div class="content">
 <pre class="CodeRay highlight"><code data-lang="java"><span 
class="comment">//activate the request-context e.g. via:</span>
-<span class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareHandlerWrapper</span> <span 
class="directive">extends</span> HandlerWrapper {
+<span class="directive">public</span> <span class="type">class</span> <span 
class="class">CdiAwareHandlerWrapper</span> <span 
class="directive">extends</span> HandlerWrapper
+{
     <span class="annotation">@Override</span>
-    <span class="directive">public</span> <span class="type">void</span> 
handle(<span class="predefined-type">String</span> target, Request baseRequest, 
HttpServletRequest request, HttpServletResponse response) <span 
class="directive">throws</span> <span class="exception">IOException</span>, 
ServletException {
+    <span class="directive">public</span> <span class="type">void</span> 
handle(<span class="predefined-type">String</span> target, Request baseRequest, 
HttpServletRequest request, HttpServletResponse response) <span 
class="directive">throws</span> <span class="exception">IOException</span>, 
ServletException
+    {
         CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
 
-        <span class="keyword">try</span> {
+        <span class="keyword">try</span>
+        {
             cdiContainer.getContextControl().startContext(RequestScoped.class);
             <span class="local-variable">super</span>.handle(target, 
baseRequest, request, response);
-        } <span class="keyword">finally</span> {
+        }
+        <span class="keyword">finally</span>
+        {
             cdiContainer.getContextControl().stopContext(RequestScoped.class);
         }
     }


Reply via email to