Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: No ParameterResolver registered for org.apache.http.HttpRequest #1481

Closed
knutwannheden opened this issue Nov 16, 2021 · 6 comments

Comments

@knutwannheden
Copy link

We are currently testing the new 4.3.0 release and discovered a regression in the JUnit 5 integration: There is no longer a ParameterResolver registered for the org.apache.http.HttpRequest type. Thus a test method can no longer declare a HttpRequest parameter as described in the documentation:

    @TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider.class)
    void testTemplate(PactVerificationContext context, HttpRequest request) {
      // This will add a header to the request
      request.addHeader("X-Auth-Token", "1234");
      context.verifyInteraction();
    }

Looking at the history it looks like this would work if the parameter were declared as of type ClassicHttpRequest, but this is a subtype of HttpRequest and I assume this was refactored by accident.

@uglyog
Copy link
Member

uglyog commented Nov 16, 2021

With 4.3.0 the Apache HTTP client has been upgraded to 5, which has different interfaces and classes. HttpRequest is now an interface that does not have any methods to get the request/response bodies. ClassicHttpRequest provides the same interface as the previous version.

But as you probably only need to use it to set headers, supporting it makes sense.

@uglyog
Copy link
Member

uglyog commented Nov 16, 2021

Just a note that the new interface is now org.apache.hc.core5.http.HttpRequest not org.apache.http.HttpRequest

@knutwannheden
Copy link
Author

I see. Thanks for the feedback. So possibly all that is needed is a documentation update and a migration guide.

@uglyog
Copy link
Member

uglyog commented Nov 16, 2021

Migration doc is there already https://github.com/pact-foundation/pact-jvm/blob/master/upgrade-to-4.3.x.md, I'll update the docs.

@uglyog
Copy link
Member

uglyog commented Nov 16, 2021

4.3.1 released which will allow you to use HttpRequest

@knutwannheden
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants