Comments (6)
You can new up WireMock
in addition to calling static methods on it e.g.
WireMock wireMock = new WireMock("localhost", "8082");
then create stubs like this:
wireMock.register(get(urlEqualTo("/test")).willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("Hello world!")));
Does that help?
from wiremock.
Yep, thanks. I suspect they'll be more problems with the mismatch of static vs my instance. Do you recommend a particular way?
I'd still need the WireMockServer
though right; if I'm new'ing up a WireMock
as you suggest?
from wiremock.
I tend to use the instance approach if I'm wrapping wiremock inside another
class e.g. MyServiceStub. That way a number of these can co-habit provided
the ports don't clash.
Yes, you still need to run the server in this setup. The WireMock class is
just client code.
On 14 Mar 2013 20:15, "Toby" [email protected] wrote:
Yep, thanks. I suspect they'll be more problems with the mismatch of
static vs my instance. Do you recommend a particular way?I'd still need the WireMockServer though right; if I'm new'ing up a
WireMock as you suggest?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-14926428
.
from wiremock.
That is some nice code.
Steven Barkdull
[email protected]
From: tomakehurst [email protected]
To: tomakehurst/wiremock [email protected]
Sent: Thursday, March 14, 2013 3:13 PM
Subject: Re: [wiremock] Question: Avoiding the static defaultInstance of WireMock (#18)
You can new up WireMock in addition to calling static methods on it e.g.
WireMock wireMock = new WireMock("localhost", "8082");
then create stubs like this:
wireMock.register(get(urlEqualTo("/test")).willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("Hello world!")));
Does that help?
—
Reply to this email directly or view it on GitHub.
from wiremock.
Hi there, I'm trying to achieve a similar thing, but I don't seem to find the right code for it; if I try something like this:
public MockedService(int port) {
wireMock = new WireMock("localhost", port);
wireMock.register(get(urlMatching("/process/?param1=.*¶m2=.*"))
.willReturn(aResponse()
.withBody(GenericMediaResponse.RESPONSE_OK.toJSONString()))
);
}
I get a ConnectionRefused issue.I would basically like to use WireMock to have a standalone embedded server that I can use as a test service for external tests, but I'm not sure how to hook handlers to WireMockServer and the relationship between WireMock and WireMockServer?
from wiremock.
WireMock is just the client part, so for this to work you'd need to run the server up from the command line, new up an instance of WireMockServer and start it or usr the @rule
from wiremock.
Related Issues (20)
- Add a unique id to the template request model
- Add self-description callback(s) to MatchResult for use in Diff
- Report webhook errors and results as sub-events
- Support mTLS (client certificate) for standalone WireMock client
- urlPathTemplate does not work in combination with queryParameters HOT 1
- Allow loading a stub for a single file instead of a directory
- Make checking for duplicate IDs optional HOT 2
- No command line option to set template escape disabled to false
- ID reported as already taken when registering a single stub HOT 2
- Optimal order of offsetting and truncating expected date/time values
- Recording fails when JSON in a request was invalid
- could not find helper: "jsonMerge" HOT 3
- Add idle timeout configuration when running as forward (browser) proxy
- Add support for HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables
- PatternSyntaxException in PathTemplate.SPECIAL_SYMBOL_REGEX on Android HOT 2
- Support removeAndGet method on stores
- Support for configuring cipher suites of WiremockServer in WireMockConfiguration
- Adding support for compressed stub for snappy compression HOT 1
- Response Template behaviour changed in 3.X version HOT 1
- WireMock alters both strong and weak etags values when serving a gzipped response
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.