I am using the ServletTester class provided by Jetty to test one of my servlets.
The servlet reads the body of the request using InputStream.read () to construct the byte [], which is decoded and acted upon by the servlet.
The ServletTest class provides the getResponses (ByteArrayBuffer) method, but I'm not sure how to create one of them in the correct format, since it should also contain things like headers (for example, "Content-Type: application / octet-stream).
Can someone show me an easy way to build this, preferably using an existing library so that I can use it in a similar way to the HttpTester class.
If there is a “better” way to test servlets (ideally using a local connector and not through the tcp stack), I would also like to hear that.
Many thanks,
source
share