https://linen.dev logo
#help
Title
# help
s

Steven Cheswic

02/23/2024, 7:52 PM
Hi I am trying to do custom response transformations but am having issues even getting a hello world version to work I tried following the docs and wasn't able to make any progress does any one have any additional resources or docs for how this works?
Only thing I could think of is I'm using docker, and my imagine isn't finding the ResponeTranformerV2 implementation file I had
t

Tom

02/23/2024, 9:19 PM
WireMock shows the extensions it has loaded in its startup info, so I suggest checking whether yours is listed.
s

Steven Cheswic

02/23/2024, 10:22 PM
So then would I add my class that implements ResponseTransformerV2 into extensions at start up. Or am I misunderstanding how transformers work and I need to be loading a different extension
Still having issues getting my wiremock docker image to find my custom class. Is there any documentation on how this process works I haven't been able to find anything that's gotten me out of this blocker online. My current understanding is I copy into the /extension_dir folder and then call --extension filename
t

Tom

02/26/2024, 7:21 PM
The
--extension
parameter takes the class name, rather than the filename. But if your extension has the
META-INF/services
file you don’t need that parameter at all. I suggest doing it this way. Are you using the official WireMock Docker image as your base?
s

Steven Cheswic

02/26/2024, 7:25 PM
Yes currently using latest wiremock docker image
t

Tom

02/26/2024, 7:27 PM
OK, so putting your JAR file under
/var/wiremock/extensions
inside the container should be sufficient on its own provided you’ve added the service file.
I’m going to update the README I think…
❤️ 1
README updated, if that’s any help at this point
s

Steven Cheswic

02/26/2024, 7:33 PM
Let me give it a look real quick
So if I'm writing my own extension how do I add the meta-inf services file so that this workflow is recognized
That’s the version to use if your extension uses ExtensionFactory. If you want to use the extension class directly, name the file:
com.github.tomakehurst.wiremock.extension.Extension
s

Steven Cheswic

02/26/2024, 7:47 PM
So I need to use this grpc extension to have wiremock recognize my implementation of ResponseTransformerV2?
t

Tom

02/26/2024, 7:47 PM
No, I’m just using it as an example of how extensions declare themselves
Basically you need to create a file in your source project:
src/main/resources/META-INF/services/com.github.tomakehurst.wiremock.extension.Extension
and in this file put the fully-qualified name of your extension class.
❤️ 1
s

Steven Cheswic

02/26/2024, 9:19 PM
So I'm getting a java.util.serviceconfigurationerror that my extension class is not a subtype any idea what my last thing I'm doing wrong is?
wiremock-test | Exception in thread "main" java.util.ServiceConfigurationError: com.github.tomakehurst.wiremock.extension.ExtensionFactory: com.SiteControllerWiremockTransformer not a subtype
t

Tom

02/26/2024, 10:02 PM
Is it a subclass of
Extension
? If so, use
com.github.tomakehurst.wiremock.extension.Extension
as the filename
s

Steven Cheswic

02/26/2024, 10:07 PM
Ya it's a subclass of extension. And I have the filename set as that now still getting this subtype issue
Got it working. Thank you so much!
13 Views