MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
I need to mock a post request with multi part form body as given below. tried with regex pattern for unqiue string Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN , but didnt work. can some one guide me on this .
I need to mock a post request with multi part form body as given below. tried with regex pattern for unqiue string Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN , but didnt work. can some one guide me on this .
BODY :
"body":"--Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="dataset" Content-Type: text/plain;charset=UTF-8 Content-Length: 14 drugs --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="searchQuery" Content-Type: text/plain;charset=UTF-8 Content-Length: 6 cancer --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="queryLanguage" Content-Type: text/plain;charset=UTF-8 Content-Length: 4 ssql --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="returnFields" Content-Type: text/plain;charset=UTF-8 Content-Length: 22 Id,name --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="returnLimit" Content-Type: text/plain;charset=UTF-8 Content-Length: 1 1 --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN Content-Disposition: form-data; name="offset" Content-Type: text/plain;charset=UTF-8 Content-Length: 1 0 --Z5KfGboCdJvPl4VsEq74AeK7PZN4EyN-- "
I tried like -
mockServerClient .when( request() .withMethod("POST") .withHeaders( new Header("Content-Type", "multipart/form-data")) .withPath("abc/xyz") .withBody(regex(**"[\n.\w\W]** Content-Disposition: form-data; name=\"dataset\" Content-Type: text/plain;charset=UTF-8 Content-Length: 14 drugs [\n.\w\W] Content-Disposition: form-data; name=\"searchQuery\" Content-Type: text/plain;charset=UTF-8 Content-Length: 6 cancer [\n.\w\W] Content-Disposition: form-data; name=\"queryLanguage\" Content-Type: text/plain;charset=UTF-8 Content-Length: 4 ssql [\n.\w\W] Content-Disposition: form-data; name=\"returnFields\" Content-Type: text/plain;charset=UTF-8 Content-Length: 22 Id,name [\n.\w\W] Content-Disposition: form-data; name=\"returnLimit\" Content-Type: text/plain;charset=UTF-8 Content-Length: 1 1 [\n.\w\W] Content-Disposition: form-data; name=\"offset\" Content-Type: text/plain;charset=UTF-8 Content-Length: 1 0 [\n.\w\W]*-- ")) )