Possible test utilities for registry-aware-jersey-client? #155
sleberknight
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Also see this gist from some half-baked experimental code I worked on last fall (October 2021): https://gist.github.com/sleberknight/b4a4bfce7fc6a1860907331d5415f128 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Over time and across various services, we've accumulated some boilerplate code related to code that uses
RegistryAwareClient
, specifically in tests for code that usestargetForService
and which use theDropwizardClientExtension
. This is because we need a way to redirect thetargetForService
call so that it returns the test resource provided toDropwizardClientExtension
.We have typically used a Mockito spy in order to override only the value returned by calls to
targetForService
, since we need all the other real functionality of the client.The following provides several different variations I've found recently in several different services. We will need to determine the similarities and differences between them and determine an appropriate feature set for what to provide.
The first example has two methods. The first one creates the
RegistryAwareClient
with a mockRegistryClient
while the second one accepts anyRegistryAwareClient
that you provide.Next is an example that lets you specific JAX-RS client request filters:
The last example accepts a URI and the service name, and creates a spied
RegistryAwareClient
whosetargetForService
returns the given URI but only for the specific service name.There are probably others lying around inside various other services but these seemed to be the most common variations (which were almost certainly copied around).
Note that in order to provide test utilities inside the registry-aware-jersey-client JAR, we'd need to change the scope of test dependencies from test to compile scope. Otherwise we'd have to provide a separate test JAR which I'm not too keen on.
Beta Was this translation helpful? Give feedback.
All reactions