-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wiremock engine: make browser proxying, notifier verbosity and gzip c…
…ompression configurable #151
- Loading branch information
Piotr Kulasek-Szwed
committed
Nov 8, 2020
1 parent
bba8a2e
commit 4114fa5
Showing
4 changed files
with
40 additions
and
19 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/mokka/src/main/java/pl/hycom/mokka/stubbing/WireMockProperties.java
This file contains 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,24 @@ | ||
package pl.hycom.mokka.stubbing; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* Configuration properties for WireMock engine. | ||
* | ||
* @author Piotr Kulasek-Szwed <[email protected]> | ||
*/ | ||
@ConfigurationProperties(prefix = "wiremock") | ||
@Data | ||
public class WireMockProperties { | ||
|
||
private boolean enabled = false; | ||
|
||
private int httpPort = 8082; | ||
|
||
private boolean verbose = false; | ||
|
||
private boolean browserProxying = false; | ||
|
||
private boolean gzip = true; | ||
} |
This file contains 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,9 +1,10 @@ | ||
package pl.hycom.mokka.stubbing; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
import com.github.tomakehurst.wiremock.common.Slf4jNotifier; | ||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration; | ||
import com.github.tomakehurst.wiremock.standalone.MappingsSource; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import pl.hycom.mokka.stubbing.responsetemplating.GroovyResponseTransformer; | ||
|
@@ -14,25 +15,23 @@ | |
* @author Piotr Kulasek-Szwed <[email protected]> | ||
*/ | ||
@Configuration | ||
@EnableConfigurationProperties(WireMockProperties.class) | ||
public class WireMockServerConfiguration { | ||
|
||
/** | ||
* WireMock HTTP port to be exposed. | ||
*/ | ||
@Value("${wiremock.httpPort}") | ||
private int wiremockHttpPort; | ||
|
||
/** | ||
* Provides configured {@link com.github.tomakehurst.wiremock.WireMockServer}. | ||
* | ||
* @return | ||
*/ | ||
@Bean | ||
public WireMockServer wireMockServer(MappingsSource wireMockMappingSource) { | ||
public WireMockServer wireMockServer(WireMockProperties wireMockProperties, MappingsSource wireMockMappingSource) { | ||
WireMockConfiguration o = new WireMockConfiguration(); | ||
o.port(wiremockHttpPort); | ||
o.port(wireMockProperties.getHttpPort()); | ||
o.mappingSource(wireMockMappingSource); | ||
o.extensions(GroovyResponseTransformer.class); | ||
o.enableBrowserProxying(wireMockProperties.isBrowserProxying()); | ||
o.notifier(new Slf4jNotifier(wireMockProperties.isVerbose())); | ||
o.gzipDisabled(wireMockProperties.isGzip()); | ||
return new WireMockServer(o); | ||
} | ||
} |
This file contains 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
This file contains 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