Message-ID: <1686820462.25947.1394294558217.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_25946_1184205421.1394294558217" ------=_Part_25946_1184205421.1394294558217 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The jetty infrastructure can be use to test servlets with an embedded se= rver configured by the ServletTester class. The HTTP requests and responses for testing can b= e generated and parsed with the HttpTester class.=20
The embedded server uses a special local connector, and thus avoids the = need to open sockets in order to test the servlet.=20
An example of a test harness that uses these classes is ServletTest.= p>=20
The ServletTester= a> can configure a single context. Servlets and Filters may be added to the= context by class name or class instance. Context attributes, a resource ba= se or a classloader may optionally be set. eg.=20 =20
The ServletTester takes a string containing requests and
returns a= string containing the corresponding responses (eventually byte arrays will= be supported for testing character encoding and binary content). More than= one request can be pipelined and multiple responses will be returned if pe= rsistent connection conditions are met. eg.
Dealing with raw HTTP can be a bit verbose and difficult to test non pro= tocol aspects. The HttpTe= ster class allows for simple generation of requests and parsing of resp= onse (it can also parse requests and generate responses). eg.=20 =20
Once setup, the HttpTester instances may be reused and only the parts th=
at change need to be
set for subsequent requests. eg.