-
-
Notifications
You must be signed in to change notification settings - Fork 13
Disable WireMock banner in the CLI output by default #42
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
Merged
oleg-nenashev
merged 8 commits into
wiremock:main
from
julian-michelmann:feature/disable-banner-by-default
May 24, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d38c6c1
Disable banner by default when container is not running verbose
e55d491
Fix format
julian-michelmann 65ff478
Do static import instead of wildcard
98c8844
Merge branch 'feature/disable-banner-by-default' of github.com:julian…
006a641
add method with banner instead of showing the banner when starting ve…
52508ef
Add separate unit test class
12115da
Remove mockito dependency
a6355f3
Add a method "withBanner" to enable the banner
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 43 additions & 42 deletions
85
src/test/java/org/wiremock/integrations/testcontainers/WireMockContainerJUnit5Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,56 @@ | ||
| package org.wiremock.integrations.testcontainers; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.net.http.HttpResponse; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.ValueSource; | ||
| import org.testcontainers.junit.jupiter.Container; | ||
| import org.testcontainers.junit.jupiter.Testcontainers; | ||
| import org.wiremock.integrations.testcontainers.testsupport.http.TestHttpClient; | ||
|
|
||
| import java.net.http.HttpResponse; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @Testcontainers | ||
| public class WireMockContainerJUnit5Test { | ||
|
|
||
| @Container | ||
| public WireMockContainer wiremockServer = new WireMockContainer("2.35.0") | ||
| .withMapping("hello", WireMockContainerTest.class, "hello-world.json") | ||
| .withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json") | ||
| .withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class, | ||
| "hello-world-resource-response.xml"); | ||
|
|
||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = { | ||
| "hello", | ||
| "/hello" | ||
| }) | ||
| public void helloWorld(String path) throws Exception { | ||
| // given | ||
| String url = wiremockServer.getUrl(path); | ||
|
|
||
| // when | ||
| HttpResponse<String> response = TestHttpClient.newInstance().get(url); | ||
|
|
||
| // then | ||
| assertThat(response.body()) | ||
| .as("Wrong response body") | ||
| .contains("Hello, world!"); | ||
| } | ||
|
|
||
| @Test | ||
| public void helloWorldFromFile() throws Exception { | ||
| // given | ||
| String url = wiremockServer.getUrl("/hello-from-file"); | ||
|
|
||
| // when | ||
| HttpResponse<String> response = TestHttpClient.newInstance().get(url); | ||
|
|
||
| // then | ||
| assertThat(response.body()) | ||
| .as("Wrong response body") | ||
| .contains("Hello, world!"); | ||
| } | ||
| @Container | ||
| public WireMockContainer wiremockServer = new WireMockContainer("2.35.0") | ||
| .withMapping("hello", WireMockContainerTest.class, "hello-world.json") | ||
| .withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json") | ||
| .withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class, | ||
| "hello-world-resource-response.xml"); | ||
|
|
||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = { | ||
| "hello", | ||
| "/hello" | ||
| }) | ||
| public void helloWorld(String path) throws Exception { | ||
| // given | ||
| String url = wiremockServer.getUrl(path); | ||
|
|
||
| // when | ||
| HttpResponse<String> response = TestHttpClient.newInstance().get(url); | ||
|
|
||
| // then | ||
| assertThat(response.body()) | ||
| .as("Wrong response body") | ||
| .contains("Hello, world!"); | ||
| } | ||
|
|
||
| @Test | ||
| public void helloWorldFromFile() throws Exception { | ||
| // given | ||
| String url = wiremockServer.getUrl("/hello-from-file"); | ||
|
|
||
| // when | ||
| HttpResponse<String> response = TestHttpClient.newInstance().get(url); | ||
|
|
||
| // then | ||
| assertThat(response.body()) | ||
| .as("Wrong response body") | ||
| .contains("Hello, world!"); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
src/test/java/org/wiremock/integrations/testcontainers/WireMockContainerUnitTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package org.wiremock.integrations.testcontainers; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| public class WireMockContainerUnitTest { | ||
|
|
||
| @Test | ||
| public void bannerIsByDefaultDisabled() { | ||
| WireMockContainer wireMockContainer = new WireMockContainer("2.35.0"); | ||
| wireMockContainer.configure(); | ||
|
|
||
| String[] startUpArgs = wireMockContainer.getCommandParts(); | ||
|
|
||
| assertTrue(Arrays.asList(startUpArgs).contains("--disable-banner")); | ||
| } | ||
|
|
||
| @Test | ||
| public void enableBanner() { | ||
| WireMockContainer wireMockContainerSpy = new WireMockContainer("2.35.0") | ||
| .withBanner(); | ||
| wireMockContainerSpy.configure(); | ||
|
|
||
| String[] startUpArgs = wireMockContainerSpy.getCommandParts(); | ||
|
|
||
| assertFalse(Arrays.asList(startUpArgs).contains("--disable-banner")); | ||
| } | ||
|
|
||
| @Test | ||
| public void disableBanner() { | ||
| WireMockContainer wireMockContainerSpy = new WireMockContainer("2.35.0") | ||
| .withBanner() | ||
| .withoutBanner(); | ||
| wireMockContainerSpy.configure(); | ||
|
|
||
| String[] startUpArgs = wireMockContainerSpy.getCommandParts(); | ||
|
|
||
| assertTrue(Arrays.asList(startUpArgs).contains("--disable-banner")); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.