I'm trying to write a simple test where I submit a request to http://localhost:12345/%
, knowing that this is an illegal URI, because I want to assert that my HTTP Server's error-handling code behaves correctly. However, I am having a hard time forcing Java to do this.
If I try to create a Java 11 HttpRequest
with URI.create("localhost:12345/%")
, I get a URISyntaxException, which is correct and not helpful.
Similarly, using a ws-rs WebTarget
:
ClientBuilder.newBuilder().build().target("http://localhost:12345").path("/%")
builds me a WebTarget pointing to /%25
, which would normally be very helpful, but is not what I want in this particular situation.
Is there a way to test my error-handling behavior without resorting to low-level bytestream manipulation?