Author: buildbot
Date: Thu Oct 13 13:47:21 2016
New Revision: 999323

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jaxrs-testing.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/jaxrs-testing.html
==============================================================================
--- websites/production/cxf/content/docs/jaxrs-testing.html (original)
+++ websites/production/cxf/content/docs/jaxrs-testing.html Thu Oct 13 13:47:21 
2016
@@ -117,13 +117,15 @@ Apache CXF -- JAXRS Testing
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><p><span class="inline-first-p" 
style="font-size:2em;font-weight:bold"> JAX-RS 
Testing</span></p><p>&#160;</p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1435780148120 {padding: 0px;}
-div.rbtoc1435780148120 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1435780148120 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1435780148120">
-<ul class="toc-indentation"><li><a shape="rect" 
href="#JAXRSTesting-EmbeddedJetty">Embedded Jetty</a></li><li><a shape="rect" 
href="#JAXRSTesting-LocalTransport">Local Transport</a></li></ul>
+<div id="ConfluenceContent"><p><span class="inline-first-p" 
style="font-size:2em;font-weight:bold">JAX-RS Testing</span>&#160;</p><p><style 
type="text/css">/*<![CDATA[*/
+div.rbtoc1476366408633 {padding: 0px;}
+div.rbtoc1476366408633 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1476366408633 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1476366408633">
+<ul class="toc-indentation"><li><a shape="rect" 
href="#JAXRSTesting-EmbeddedJetty">Embedded Jetty</a></li><li><a shape="rect" 
href="#JAXRSTesting-LocalTransport">Local Transport</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#JAXRSTesting-MockingHTTPcontexts">Mocking HTTP contexts</a></li></ul>
+</li></ul>
 </div><p>JAX-RS endpoints can be easily tested using the embedded Jetty or CXF 
Local Transport.</p><h1 id="JAXRSTesting-EmbeddedJetty">Embedded Jetty</h1><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Maven 
Dependency</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" 
style="font-size:12px;">&lt;dependency&gt;
    &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
@@ -317,7 +319,22 @@ public void testAddBookWithProxyDirectDi
         assertEquals(123L, book.getId());
     }
 </pre>
-</div></div></div>
+</div></div><p>&#160;</p><h2 id="JAXRSTesting-MockingHTTPcontexts">Mocking 
HTTP contexts</h2><p>If you test a code which depends on the injected HTTP 
contexts such as HttpServletRequest then these contexts will have to be 
mocked.</p><p>For example:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">JAXRSServerFactoryBean sf = new 
JAXRSServerFactoryBean();
+sf.setInvoker(new Invoker() {
+
+  Invoker jarsInvoker = new JAXRSInvoker();
+  @Override
+  public Object invoke(Exchange exchange, Object o) {
+
+   HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+   Mockito.when(request.getRemoteHost()).thenReturn("host");
+   exchange.getInMessage().put(AbstractHTTPDestination.HTTP_REQUEST, request);
+   return jarsInvoker.invoke(exchange, o);
+  }
+
+});</pre>
+</div></div><p>&#160;</p><p>&#160;</p></div>
            </div>
            <!-- Content -->
          </td>


Reply via email to