<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christian Schenk&#187; jetty</title>
	<atom:link href="http://www.christianschenk.org/blog/tag/jetty/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christianschenk.org</link>
	<description>Writing about my experiences with technology and all different kinds of projects and experiments</description>
	<lastBuildDate>Sun, 29 Aug 2010 09:08:16 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Webservices with Hessian and Burlap</title>
		<link>http://www.christianschenk.org/blog/webservices-with-hessian-and-burlap/</link>
		<comments>http://www.christianschenk.org/blog/webservices-with-hessian-and-burlap/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 05:35:38 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[burlap]]></category>
		<category><![CDATA[hessian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/webservices-with-hessian-and-burlap/</guid>
		<description><![CDATA[How to develop web services with Hessian and Burlap]]></description>
			<content:encoded><![CDATA[<p>Developing webservices with <a title="Hessian Binary Web Service Protocol" href="http://www.caucho.com/hessian/">Hessian</a> or <a title="Burlap" href="http://www.caucho.com/resin-3.0/protocols/burlap.xtp">Burlap</a> can be really fun. While Hessian is a binary protocol, Burlap is the XML-based counterpart; both can be used for <abbr title="Remote procedure call">RPC</abbr> over HTTP. They can be used to serialize any object but they&#8217;re predestined to connect web services. It&#8217;s as easy as this:</p>
<ul>
<li>create an interface for your webservice</li>
<li>implement this interface in a class that extends either <code>HessianServlet</code> or <code>BurlapServlet</code></li>
<li>deploy a <code>HessianServlet</code> or <code>BurlapServlet</code> in your application server and configure it to use your newly created service</li>
<li>use the <code>HessianProxyFactory</code> or <code>BurlapProxyFactory</code> to create an instance of your service that transparently talks to the deployed servlet.</li>
</ul>
<p>I wrote a little test application that demonstrates the aforementioned steps in action. You can download the <a title="Eclipse.org" href="http://www.eclipse.org/">Eclipse</a> project as <a href="http://data.christianschenk.org/webservices-with-hessian-and-burlap/WebservicesWithHessianAndBurlap.tar.gz">tar.gz</a> or <a href="http://data.christianschenk.org/webservices-with-hessian-and-burlap/WebservicesWithHessianAndBurlap.zip">zip</a> or browse the code <a title="WebservicesWithHessianAndBurlap - Code Reference" href="http://data.christianschenk.org/webservices-with-hessian-and-burlap/xref/">here</a>. I haven&#8217;t used <a title="Spring Application Framework" href="http://www.springframework.org/">Spring</a>, but if you plan to integrate Hessian or Burlap into your Spring-powered application have a look at the <a title="Spring's remoting classes for Caucho's Hessian and Burlap" href="http://www.springframework.org/docs/api/org/springframework/remoting/caucho/package-summary.html">API docs</a>.</p>
<p>If you try to run the code don&#8217;t upgrade Hessian to version <code>3.0.8</code> as this will result in and infinite loop in the <code>init</code> method of the <code>HessianServlet</code>. This has been reported <a title="hessian init endless loop" href="http://maillist.caucho.com/pipermail/hessian-interest/2007-June/000067.html">here</a> and <a title="Bug report - Hessian init" href="http://bugs.caucho.com/view.php?id=1779">there</a> and it is fixed in version <code>3.1.2</code> &#8211; so wait until this version reaches the <a title="Maven" href="http://maven.apache.org/">Maven</a> repositories.</p>
<p><span id="more-32"></span></p>
<h2>How to?</h2>
<p>Lets go a little bit into detail how to expose a service with Hessian and Burlap to the web. First, we&#8217;ll create an interface for our service:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Calculator <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> add<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> sub<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> div<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> mul<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Next, this <code>Calculator</code> service will be implemented in a class that either extends <code>HessianServlet</code> or <code>BurlapServlet</code>. Have a look at the latter variant:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CalculatorService <span style="color: #000000; font-weight: bold;">extends</span> BurlapServlet
                               <span style="color: #000000; font-weight: bold;">implements</span> Calculator <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> add<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> a <span style="color: #339933;">+</span> b<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> sub<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> a <span style="color: #339933;">-</span> b<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> div<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> a <span style="color: #339933;">/</span> b<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> mul<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> a, <span style="color: #000066; font-weight: bold;">int</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> a <span style="color: #339933;">*</span> b<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see you can concentrate on the implementation of the methods provided by the <code>Calculator</code> interface.</p>
<p>Before you can access the service, you&#8217;ll have to deploy the <code>CalculatorService</code> servlet in an application server. To stick with this example you would take the default <code>BurlapServlet</code> and set its init parameters <code>service-class</code> and <code>api-class</code> to <code>CalculatorService</code> and <code>Calculator</code> respectively.</p>
<p>Finally, you can access the service with a client: create an instance of your service with the <code>HessianProxyFactory</code> or <code>BurlapProxyFactory</code> and requests to the service will be made transparently.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example.com/calc&quot;</span><span style="color: #339933;">;</span>
BurlapProxyFactory factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BurlapProxyFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Calculator calc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Calculator<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>Calculator.<span style="color: #000000; font-weight: bold;">class</span>, url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now you can make calls like <code>calc.add(1,2)</code> &#8211; it&#8217;s as easy as this.</p>
<h2>Testing</h2>
<p>In a <a title="Testing web applications with Jetty" href="http://www.christianschenk.org/blog/testing-web-applications-with-jetty/">post</a> about testing web applications I showed how to use Jetty for this purpose. We can do this here again and you can have a look at the complete code <a title="WebservicesWithHessianAndBurlap - Code Reference" href="http://data.christianschenk.org/webservices-with-hessian-and-burlap/xref/">here</a>. The important part is this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ServletTester tester<span style="color: #339933;">;</span>
...
<span style="color: #000000; font-weight: bold;">Class</span> burlapServlet <span style="color: #339933;">=</span> BurlapServlet.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> serviceName <span style="color: #339933;">=</span> CalculatorService.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> apiName <span style="color: #339933;">=</span> Calculator.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
<span style="color: #006633;">ServletHolder</span> servletHolder <span style="color: #339933;">=</span> tester.<span style="color: #006633;">addServlet</span><span style="color: #009900;">&#40;</span>burlapServlet, <span style="color: #0000ff;">&quot;/calc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
servletHolder.<span style="color: #006633;">setInitParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;service-class&quot;</span>, serviceName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
servletHolder.<span style="color: #006633;">setInitParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;api-class&quot;</span>, apiName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This hands the init parameters to the <code>BurlapServlet</code>. Once you&#8217;ve done that you can start requests with a client.</p>
<h2>Conclusion</h2>
<p>It was <a href="http://blog.platinumsolutions.com/node/83">said</a> that you should just use Hessian or Burlap if you don&#8217;t have to worry about interoperability. I think that this has changed in two ways.</p>
<p>First, there are implementations available for various languages. If you plan to support one of these, you&#8217;re all set: </p>
<ul class="inline">
<li>Java</li>
<li>Python</li>
<li>C++</li>
<li>.NET C#</li>
<li>D</li>
<li>Erlang</li>
<li>PHP</li>
<li class="last">Ruby</li>
</ul>
<p>Second, both tools are very easy to use. From a <cite><a title="Burlap Notes" href="http://www.caucho.com/resin-3.1/doc/burlap-notes.xtp">page</a> about the design goals for Burlap</cite>:</p>
<blockquote cite="http://www.caucho.com/resin-3.1/doc/burlap-notes.xtp"><p> If browsers mess up the simple cookie spec, the SOAP, XML Schema, SOAP Attachment, WSDL, and more! specs, are likely to cause interoperability and testing problems, like CORBA/IIOP did. Burlap tries to eliminate ambiguity so these problems never show up in the first place.</p></blockquote>
<p>
This might be true and it will be interesting how these technologies will develop in the future. But I guess that we&#8217;ll always have heavyweight and lightweight tools at our disposal (<em>doh</em>, who would have thought).</p>
<p>That being said, I think that Hessian and Burlap do a perfect job: you can expose a service to the web without worrying about writing servlets, a protocol or even a schema for the protocol. Since it&#8217;s really fun using these tools I fully recommend them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/webservices-with-hessian-and-burlap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing web applications with Jetty</title>
		<link>http://www.christianschenk.org/blog/testing-web-applications-with-jetty/</link>
		<comments>http://www.christianschenk.org/blog/testing-web-applications-with-jetty/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 12:00:19 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[servlets]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[webapps]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/testing-web-applications-with-jetty/</guid>
		<description><![CDATA[Shows how to deploy and test your servlets with Jetty - everything inside a JUnit test]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;d like to test your web application you might be interested in <a title="Jetty - WebServer" href="http://www.mortbay.org/">Jetty</a>: you can deploy your servlets in it, generate HTTP requests and check if certain criteria are met &#8211; everything inside a JUnit test.</p>
<p>Jetty has got enough <a title="Jetty Documentation" href="http://docs.codehaus.org/display/JETTY/Jetty+Documentation">documentation</a> to get you started; if you want more you can get support from the <a title="WebTide" href="http://www.webtide.com/">creators</a> of Jetty. This post was inspired by <a title="Testing servlets with an embedded Jetty server" href="http://docs.codehaus.org/display/JETTY/ServletTester">this</a> particular page from the docs. I setup a very small Eclipse project that can be downloaded as <a href="http://data.christianschenk.org/testing-web-applications-with-jetty/TestingWithJetty.tar.gz">tar.gz</a> or <a href="http://data.christianschenk.org/testing-web-applications-with-jetty/TestingWithJetty.zip">zip</a>; alternatively, you can browse the code <a title="TestingWithJetty - Code Reference" href="http://data.christianschenk.org/testing-web-applications-with-jetty/xref/">here</a>.</p>
<p><span id="more-31"></span></p>
<h2>JUnit scaffolding</h2>
<p>Lets have a look at a small JUnit class, that implements a <code>setUp</code> method to bootstrap Jetty:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.testing.HttpTester</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.testing.ServletTester</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> WebAppTest <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> ServletTester tester<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> HttpTester request<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> HttpTester response<span style="color: #339933;">;</span>
&nbsp;
  @Before
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">tester</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServletTester<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">tester</span>.<span style="color: #006633;">setContextPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">tester</span>.<span style="color: #006633;">addServlet</span><span style="color: #009900;">&#40;</span>MyServlet.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">tester</span>.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">request</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpTester<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">response</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpTester<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">request</span>.<span style="color: #006633;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">request</span>.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Host&quot;</span>, <span style="color: #0000ff;">&quot;tester&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">request</span>.<span style="color: #006633;">setVersion</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;HTTP/1.0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>This method leverages the features provided by the <code>ServletTester</code> class, which will create a Jetty server for us. Instead of writing a <code>web.xml</code>, we can add servlets to the server programmatically. After that we start the server and create a request/response pair that can be used in the test methods.</p>
<h2>Testing</h2>
<p>Now you can write several test methods for every request you&#8217;d like to check. If you want to check the start page of your web application you set the URI, generate a request, send it to Jetty, receive the response and check it like so:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  @Test
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testHomepage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">request</span>.<span style="color: #006633;">setURI</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">response</span>.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span>tester.<span style="color: #006633;">getResponses</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">generate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    assertTrue<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">response</span>.<span style="color: #006633;">getMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    assertEquals<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">response</span>.<span style="color: #006633;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello World&quot;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">response</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this simple case the <code>MyServlet</code> class contains a line like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello World&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Conclusion</h2>
<p>Jetty is said to be highly embeddable. As far as I&#8217;ve checked it out, that&#8217;s absolutely true. Due to this it&#8217;s very easy to use Jetty  inside unit tests. I haven&#8217;t tried to use Jetty with <a href="http://www.bibsonomy.org/user/cschenk/web+framework+software">web frameworks</a> but that should be no problem either. So if you&#8217;d like to test your servlets I recommend checking out <a title="Jetty - WebServer" href="http://www.mortbay.org/">Jetty</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/testing-web-applications-with-jetty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
