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

Disable WireMock banner in the CLI output by default #42

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,23 @@ public WireMockContainer(String image, String version) {
wireMockArgs = new StringBuilder();
setWaitStrategy(DEFAULT_WAITER);
}


/**
* Enables the banner when starting WireMock container.
* @return this instance
*/
public WireMockContainer withBanner() {
isBannerDisabled = false;
julian-michelmann marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

/**
* Adds CLI argument to the WireMock call.
* @param arg Argument
* @return this instance
*/
public WireMockContainer withCliArg(String arg) {
//TODO: Switch to framework with proper CLI escaping
if (arg.contains("--verbose")) {
isBannerDisabled = false;
}
wireMockArgs.append(' ').append(arg);
return this;
}
Expand Down Expand Up @@ -250,5 +256,4 @@ public Extension(String id) {
this.id = id;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,4 @@ public void helloWorldFromFile() throws Exception {
.as("Wrong response body")
.contains("Hello, world!");
}

@Test
public void defaultBannerDisabled() {
WireMockContainer wireMockContainerSpy = Mockito.spy(new WireMockContainer("2.35.0"));

wireMockContainerSpy.configure();

verify(wireMockContainerSpy).withCliArg("--disable-banner");
}

@ParameterizedTest
@ValueSource(strings = {
"--verbose",
" --verbose ",
"--verbose --help"
})
public void showBannerWhenStartingVerbose(String verboseArg) {
WireMockContainer wireMockContainerSpy = Mockito.spy(new WireMockContainer("2.35.0"));
wireMockContainerSpy.withCliArg(verboseArg);

wireMockContainerSpy.configure();

verify(wireMockContainerSpy, times(0)).withCliArg("--disable-banner");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.wiremock.integrations.testcontainers;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class WireMockContainerUnitTest {

@Test
public void defaultBannerDisabled() {
WireMockContainer wireMockContainerSpy = Mockito.spy(new WireMockContainer("2.35.0"));

wireMockContainerSpy.configure();

verify(wireMockContainerSpy).withCliArg("--disable-banner");
}

@Test
public void enableBanner() {
WireMockContainer wireMockContainerSpy = Mockito.spy(new WireMockContainer("2.35.0")).withBanner();

wireMockContainerSpy.configure();

verify(wireMockContainerSpy, times(0)).withCliArg("--disable-banner");
}
}