Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] Using Jettty 9 to simulate errors

Hi,

I’m a committer on the WireMock project (http://wiremock.org). WireMock currently uses Jetty 6, and we’re upgrading to Jetty 9.

It’s been mostly painless, but there is one aspect of WireMock which is more problematic. It allows users to simulate four kinds of errors:

* connection timeouts before sending the request
* connection closed after the request is sent but before any response is received
* random data returned after the request is sent
* start of a valid response followed by random data

I’d appreciate any advice someone can offer on how to implement these.

I’ve implemented the first by putting the delay in HttpConnectionFactory.newConnection:
https://github.com/Mahoney/wiremock/blob/jetty9/src/main/java/com/github/tomakehurst/wiremock/jetty9/FaultInjectingHttpConnectionFactory.java

I’m slightly concerned this might not work if the connection is being reused across requests? Haven’t managed to write a failing test, though, so it seems to work...

I’ve implemented the second by calling close on the HttpConnection in HttpConnection.send:
https://github.com/Mahoney/wiremock/blob/jetty9/src/main/java/com/github/tomakehurst/wiremock/jetty9/FaultInjectingHttpConnection.java

I can’t work out how to do the last two at all, because I can’t get my head around how to write data to the endpoint - any advice appreciated.

Thanks,
Rob





Back to the top