Generating random values in a response using Wiremock standalone

4,743 views
Skip to first unread message

Ilyas Patel

unread,
Jan 26, 2016, 12:43:31 PM1/26/16
to wiremock-user
Is it possible to generate random values before a response is returned using Wiremock Standalone?

My use case is to generate random user ids in a http header.

thanks

Ilyas Patel

unread,
Jan 26, 2016, 5:25:50 PM1/26/16
to wiremock-user
Just found this in the documentation but can I use this in standalone mode?

http://wiremock.org/extending-wiremock.html

Tom Akehurst

unread,
Jan 27, 2016, 4:06:08 AM1/27/16
to wiremock-user
Yes, you can also do this when running standalone. You either need to bake your extension into a runnable jar with wiremock, or add it to the classpath when starting wiremock-standalone. The latter means you can't use java -jar unfortunately, but instead add both jars to the classpath via -cp.

Ilyas Patel

unread,
Feb 2, 2016, 10:15:55 AM2/2/16
to wiremock-user
Tom, I have this working but I would like to now deploy it to AWS and I require a main class to execute it. The manifest file doesn't contain a main method. Do you know which one I can use?

This is the command I'm using. 

java -cp "target/recommendations-wiremock-id-stub-1.0-SNAPSHOT.jar;wiremock-1.58-standalone.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --extensions co.uk.example.qa.HeaderTransformer

Tom Akehurst

unread,
Feb 2, 2016, 12:58:50 PM2/2/16
to wiremock-user
Your command line looks about right. What happens when you run it?

Ilyas Patel

unread,
Feb 2, 2016, 2:59:19 PM2/2/16
to wiremock-user
We sorted this one out. Thanks.

Raj Kumar

unread,
Apr 12, 2018, 11:08:54 AM4/12/18
to wiremock-user
How did you resolve this? Even I need to generate some random value in the response.

Tom Akehurst

unread,
Apr 16, 2018, 2:03:26 PM4/16/18
to wiremock-user
Hey all, check out the latest version (2.17.0) for added support for this.

Raj Kumar

unread,
Apr 16, 2018, 3:19:27 PM4/16/18
to Tom Akehurst, wiremock-user
wow... that looks good. let me implement tomorrow and update you. Thanks a lot.

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-user+unsubscribe@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/e0792a14-1ead-4789-9448-89f9f8507b78%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tom Akehurst

unread,
Apr 16, 2018, 3:35:11 PM4/16/18
to wiremock-user
Please do, it'd be great to get your feedback.


On Monday, 16 April 2018 20:19:27 UTC+1, Raj Kumar wrote:
wow... that looks good. let me implement tomorrow and update you. Thanks a lot.

Raj Kumar

unread,
Apr 17, 2018, 5:48:28 AM4/17/18
to Tom Akehurst, wiremock-user
Check RandomValue generationg looks good and it's very helpful. Thanks


{{randomValue length=33 type='ALPHANUMERIC'}}
{{randomValue length=12 type='ALPHANUMERIC' uppercase=true}}
{{randomValue length=55 type='ALPHABETIC'}}
{{randomValue length=27 type='ALPHABETIC' uppercase=true}}
{{randomValue length=10 type='NUMERIC'}}
{{randomValue length=5 type='ALPHANUMERIC_AND_SYMBOLS'}}
{{randomValue type='UUID'}}


On Mon, Apr 16, 2018 at 8:35 PM, 'Tom Akehurst' via wiremock-user <wiremo...@googlegroups.com> wrote:
Please do, it'd be great to get your feedback.


On Monday, 16 April 2018 20:19:27 UTC+1, Raj Kumar wrote:
wow... that looks good. let me implement tomorrow and update you. Thanks a lot.

On Mon, Apr 16, 2018 at 7:03 PM, 'Tom Akehurst' via wiremock-user <wiremo...@googlegroups.com> wrote:
Hey all, check out the latest version (2.17.0) for added support for this.

On Thursday, 12 April 2018 16:08:54 UTC+1, Raj Kumar wrote:
How did you resolve this? Even I need to generate some random value in the response.



On Tuesday, 2 February 2016 19:59:19 UTC, Ilyas Patel wrote:
We sorted this one out. Thanks.

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-user+unsubscribe@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/e0792a14-1ead-4789-9448-89f9f8507b78%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-user+unsubscribe@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.

Raj Kumar

unread,
Apr 17, 2018, 5:51:44 AM4/17/18
to Tom Akehurst, wiremock-user
On the date and time helpers could you add unix epoch time as well.

Also some of the DateFormate is not working - 
{{now offset='10 years' format='yyyy-MM-dd'}}  Example Format yyyy-MM-dd'T'HH:mm:ss.SSSZ

If there is any single quote in the date format.

Tom Akehurst

unread,
Apr 17, 2018, 8:36:55 AM4/17/18
to wiremock-user
Epoch time is a good shout. I'll add that on the next pass.

Have you tried double quotes around the format parameter?

KK

unread,
Apr 30, 2018, 4:00:17 PM4/30/18
to wiremock-user
Hello Raj.I would love to know how you have resolve this.DO you have any example?


On Tuesday, April 17, 2018 at 5:48:28 AM UTC-4, Raj Kumar wrote:
Check RandomValue generationg looks good and it's very helpful. Thanks


{{randomValue length=33 type='ALPHANUMERIC'}}
{{randomValue length=12 type='ALPHANUMERIC' uppercase=true}}
{{randomValue length=55 type='ALPHABETIC'}}
{{randomValue length=27 type='ALPHABETIC' uppercase=true}}
{{randomValue length=10 type='NUMERIC'}}
{{randomValue length=5 type='ALPHANUMERIC_AND_SYMBOLS'}}
{{randomValue type='UUID'}}

On Mon, Apr 16, 2018 at 8:35 PM, 'Tom Akehurst' via wiremock-user <wiremo...@googlegroups.com> wrote:
Please do, it'd be great to get your feedback.


On Monday, 16 April 2018 20:19:27 UTC+1, Raj Kumar wrote:
wow... that looks good. let me implement tomorrow and update you. Thanks a lot.
On Mon, Apr 16, 2018 at 7:03 PM, 'Tom Akehurst' via wiremock-user <wiremo...@googlegroups.com> wrote:
Hey all, check out the latest version (2.17.0) for added support for this.

On Thursday, 12 April 2018 16:08:54 UTC+1, Raj Kumar wrote:
How did you resolve this? Even I need to generate some random value in the response.



On Tuesday, 2 February 2016 19:59:19 UTC, Ilyas Patel wrote:
We sorted this one out. Thanks.

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-use...@googlegroups.com.

To post to this group, send email to wiremo...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-use...@googlegroups.com.

To post to this group, send email to wiremo...@googlegroups.com.

Raj Kumar

unread,
May 1, 2018, 4:36:48 AM5/1/18
to KK, wiremock-user
Hi,

You use those value in the Json field. What's the problem you are facing?

r
Raj

To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-user+unsubscribe@googlegroups.com.

To post to this group, send email to wiremo...@googlegroups.com.

lmo

unread,
May 20, 2019, 12:02:16 PM5/20/19
to wiremock-user
Hello Raj,
Could you tell me which extension you installed to have this available ?

{{randomValue length=33 type='ALPHANUMERIC'}}
{{randomValue length=12 type='ALPHANUMERIC' uppercase=true}}
{{randomValue length=55 type='ALPHABETIC'}}
{{randomValue length=27 type='ALPHABETIC' uppercase=true}}
{{randomValue length=10 type='NUMERIC'}}
{{randomValue length=5 type='ALPHANUMERIC_AND_SYMBOLS'}}
{{randomValue type='UUID'}}
You spoke only about header modifier
Thanks !
To unsubscribe from this group and stop receiving emails from it, send an email to wiremo...@googlegroups.com.

To post to this group, send email to wiremo...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages