Helidon 4 SE Unit Testing: How do I test my code with ServerRequest and ServerResponse

135 Views Asked by At

I'm using Helidon 4 SE for a new service, and I would like to be able to test a function like this:

protected void myHandler(ServerRequest req, ServerResponse res)

I'm not as interested in the business logic at this point as the testing of this particular plumbing.

However, I'm having the hardest time finding and implementation of ServerRequest/Response. They are interfaces and I just can't seem to find working implementations. The answer may be between the difference SE and MP, but I can't find it.

I've tried a test with @ServerTest and ping the server with the provided client, but the debugger doesn't seem to attach to the thread the server runs in, so the client blows past my IntelliJ breakpoints.

Or, I'm missing something Helidon-ish (research indicates maybe JAX-RS-ish) that would allow me to create something that can be used as a io.helidon.webserver.http.ServerRequest. I'm willing to use Mockito to mock it, but I feel like there's an implementation somewhere that I'm just not finding.

In my mind there should be something like

ServerRequest reqImpl = ServerRequest.Builder.withUrl("blah").withHeaders(<some headers>).build();

Even in the examples I'm not finding a good example of "test this service this way".

Any clues appreciated.

1

There are 1 best solutions below

0
On

Helidon's documentation features a section on testing, complete with examples. Does this get you going?