<div dir="ltr"><div>You could use DefaultServer junit runner for your tests.</div><div><br></div><div>Same &quot;framework&quot; that undertow tests are written with.</div><div><br></div><div>for example see <a href="https://github.com/undertow-io/undertow/blob/master/core/src/test/java/io/undertow/server/handlers/file/FileHandlerTestCase.java">https://github.com/undertow-io/undertow/blob/master/core/src/test/java/io/undertow/server/handlers/file/FileHandlerTestCase.java</a></div><div><br></div><div>or pretty much any other test.</div><div><br></div><div>--</div><div>tomaz</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 8, 2017 at 3:10 PM, Michael Hixson <span dir="ltr">&lt;<a href="mailto:michael.hixson@gmail.com" target="_blank">michael.hixson@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I want to write junit tests for my application&#39;s HttpHandlers and I&#39;m<br>
wondering what the best way to simulate a request/response exchange<br>
is.  How do other people go about this?<br>
<br>
My first thought was that I want to somehow:<br>
<br>
1) Build up a valid HttpServerExchange object to represent my incoming<br>
request (likely the HTTP method, request URI, HTTP headers, and<br>
request entity/body would vary from test to test)<br>
<br>
2) Instantiate my HttpHandler directly, and invoke its handleRequest<br>
method directly<br>
<br>
3) Obtain a CompletableFuture that will complete when the exchange<br>
completes (possibly by adding an<br>
io.undertow.server.<wbr>ExchangeCompletionListener to my exchange)<br>
<br>
4) Verify the contents of the response (possibly by examining the<br>
HttpServerExchange object and by using an<br>
io.undertow.conduits.<wbr>StoredResponseStreamSinkCondui<wbr>t to record the<br>
response entity)<br>
<br>
This would all happen without creating an Undertow instance or binding<br>
to any ports.<br>
<br>
I started writing my own mock request/response library classes and<br>
they&#39;re getting complicated enough that I&#39;d rather reuse someone<br>
else&#39;s work here if possible.<br>
<br>
Maybe I&#39;m going down the wrong path...  I could create an Undertow<br>
server instance and use something like a Jersey client to make actual<br>
HTTP requests.  Is that what other people do in their tests?<br>
<br>
-Michael<br>
______________________________<wbr>_________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank" rel="noreferrer">https://lists.jboss.org/<wbr>mailman/listinfo/undertow-dev</a><br>
</blockquote></div><br></div>