Record-mappings programtically

676 views
Skip to first unread message

Manohar Kvn

unread,
Aug 24, 2015, 10:43:47 AM8/24/15
to wiremock-user
hi all,

I am shifting from using wiremock standalone to programmatically (Non-jnit usage). I couldn't find how to record-mappings using  java.

My standalone command : java -jar wiremock-1.57-standalone.jar --port 9999 --proxy-all="https://10.112.58.50" --record-mappings --https-port 9292
It worked fine but when I used the following code it is failing to record though it's running.
                WireMockServer wmServer =
                    new WireMockServer(9999,9292);
                FileSource mappings = new SingleRootFileSource("E:\\wiremock\\embedded\\mappings");
                FileSource files = new SingleRootFileSource("E:\\wiremock\\embedded\\files");
                wmServer.enableRecordMappings(mappings, files);  
            
            wmServer.stubFor(get(urlMatching("/*")).
                    willReturn(aResponse().proxiedFrom("https://10.112.58.50/");

Can anyone correct me ?

Thanks ,
Manohar

Manohar Kvn

unread,
Aug 25, 2015, 10:03:21 AM8/25/15
to wiremock-user
Hi,
I am able to record mappings now. Found out that the requests I am getting are POST.
So , now how can I playback pro-grammatically?

Tom Akehurst

unread,
Aug 26, 2015, 6:34:26 AM8/26/15
to wiremock-user
Provided the recorded mappings ended up in the mappings and __files directories you've configured WireMock to use (or the defaults), then just starting it up will cause it to load them.

Manohar Kvn

unread,
Aug 26, 2015, 6:52:34 AM8/26/15
to wiremock-user
Ok. It is replaying but, in my case i have multiple folders which contain different recordings.How can I make sure that it will load certain folder?
Is there a way to tell wiremock ?


On Monday, 24 August 2015 20:13:47 UTC+5:30, Manohar Kvn wrote:

Manohar Kvn

unread,
Aug 26, 2015, 7:14:47 AM8/26/15
to wiremock-user
I have recordings in multiple folders. It is replaying but I have no idea which one it is loading.
I am storing recordings in web-inf/wiremock under my war project as it will search for recordings there only.is there a way to tell wiremock to load particular folder only during playback?


On Monday, 24 August 2015 20:13:47 UTC+5:30, Manohar Kvn wrote:

Tom Akehurst

unread,
Aug 28, 2015, 3:41:58 PM8/28/15
to wiremock-user
If you're running WireMock programmatically from Java you the wireMockConfig() builder has the option to change the folder. If you're running standalone you can use the --root-dir CLI option. If you're building a WAR you're out of luck I'm afraid (but I can't think why you'd want to change it in a WAR file anyway).

Manohar Kvn

unread,
Sep 1, 2015, 5:36:49 AM9/1/15
to wiremock-user
Thanks Tom. wireMockConfig() helped me.


On Monday, 24 August 2015 20:13:47 UTC+5:30, Manohar Kvn wrote:

Rayan Ahmed

unread,
Jul 25, 2019, 1:39:58 PM7/25/19
to wiremock-user
Hi can you please share how you were able to run wiremock proxying and record mappings using the java api?
Message has been deleted

Pratham Shah

unread,
Aug 2, 2019, 8:45:48 AM8/2/19
to wiremock-user
Reply all
Reply to author
Forward
0 new messages