Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a convenience mechanism to get stub runner port #573

Closed
shanman190 opened this issue Mar 12, 2018 · 3 comments
Labels
Milestone

Comments

@shanman190
Copy link
Contributor

@shanman190 shanman190 commented Mar 12, 2018

It would be nice to have a helper mechanism to acquire the stub runner port of a given producer. Thinking in a similar fashion to the LocalServerPort from Spring Boot. Maybe an API that looks something like:

@StubRunnerPort("beer-api-producer")
private int beerApiProducerPort

Using the BeerControllerTest as the basis for the example.

@marcingrzejszczak

This comment has been minimized.

Copy link
Contributor

@marcingrzejszczak marcingrzejszczak commented Mar 12, 2018

You can already user the property that allows you to access that prop, right? But maybe an additional annotation can be useful

@shanman190

This comment has been minimized.

Copy link
Contributor Author

@shanman190 shanman190 commented Mar 12, 2018

@marcingrzejszczak, absolutely true. We talked about it a little bit at SpringOne this last year. It was more a convenience, readability type of thing than anything. Just took me this long to get to it. Haha

@marcingrzejszczak

This comment has been minimized.

Copy link
Contributor

@marcingrzejszczak marcingrzejszczak commented Mar 16, 2018

Stub Runner Spring registers environment variables in the following manner
for every registered WireMock server. Example for Stub Runner ids
com.example:foo, com.example:bar.

  • stubrunner.runningstubs.foo.port
  • stubrunner.runningstubs.com.example.foo.port
  • stubrunner.runningstubs.bar.port
  • stubrunner.runningstubs.com.example.bar.port

Which you can reference in your code.

You can also use the @StubRunnerPort annotation to inject the port of a running stub.
Value of the annotation can be the groupid.artifactid or just the artifactid. Example for Stub Runner ids
com.example:foo, com.example:bar.

@StubRunnerPort("foo")
int fooPort;
@StubRunnerPort("com.example:bar")
int barPort;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.