Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Trouble making FakeHttpServletRequest implement getParts() in Jetty 12

Thanks for Jetty.  I've been enjoying it for years now!

I'm trying to make a FakeHttpServletRequest with Jetty 12 for unit-testing and integration-testing my web applications.  I had one that worked with Jetty 11, but some things changed.

I'm looking at
org.eclipse.jetty.ee10.servlet.ServletApiRequest.getParts()
from
org.eclipse.jetty:jetty-servlet:12.0.12

It calls:
CompletableFuture<ServletMultiPartFormData.Parts> futureServletMultiPartFormData = ServletMultiPartFormData.from(this);
which ends up wanting some jetty-specific request-attributes.

for ServletContextRequest.MULTIPART_CONFIG_ELEMENT I think I can just pass MultipartConfigElement(""), but for ServletChannel::class.java.name, I found this constructor:
ServletChannel(ServletContextHandler, ConnectionMetaData)

ServletContextHandler() looks easy (don't know if it will work yet).
But I'm struggling with:
HttpConnection(HttpConfiguration(),
                        org.eclipse.jetty.server.ServerConnector(),
                        LocalEndPoint()
                    )
How hard is it going to be to construct all these things and what other stuff is it going to expect?  I thought it would be simplest to do an all-jetty version of a FakeHttpServletRequest because I'm using jetty in both my projects, but if it would be simpler to use Apache HttpComponents, that would be good to know.

I'm sorry to say that I don't remember everything I relied on FakeHttpServletRequest to do with Jetty 9 and 11, so I don't know why I didn't just feed it the various aspects of a request part manually instead of making Jetty parse my data like it's a real request.  I mean, it seems valuable to be realistic in general, but simplicity is valuable too.

Back to the top