com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer Java Examples

The following examples show how to use com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WireMockAutoConfiguration.java    From restdocs-wiremock with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public WireMockConfiguration wireMockConfiguration(WireMockProperties properties) {
	WireMockConfiguration config = WireMockConfiguration.options();
	if(properties.getPort() > 0) {
		log.info("Starting WireMock on port " + properties.getPort());
		config.port(properties.getPort());
	} else {
		log.info("Starting WireMock on dynamic port");
		config.dynamicPort();
	}
	if(properties.getStubPath() != null) {
		config.fileSource(new ClasspathFileSource(properties.getStubPath()));
	}
	config.extensions(new ResponseTemplateTransformer(false));
	return config;
}
 
Example #2
Source File: WireMockConfiguration.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() throws IOException {
	if (log.isDebugEnabled()) {
		log.debug("Running initialization of the WireMock configuration");
	}
	if (this.options == null) {
		com.github.tomakehurst.wiremock.core.WireMockConfiguration factory = WireMockSpring
				.options();
		if (this.wireMock.getServer().getPort() != 8080) {
			factory.port(this.wireMock.getServer().getPort());
		}
		if (this.wireMock.getServer().getHttpsPort() != -1) {
			factory.httpsPort(this.wireMock.getServer().getHttpsPort());
		}
		registerFiles(factory);
		factory.notifier(new Slf4jNotifier(true));
		if (this.wireMock.getPlaceholders().isEnabled()) {
			factory.extensions(new ResponseTemplateTransformer(false));
		}
		this.options = factory;
		if (this.customizer != null) {
			this.customizer.customize(factory);
		}
	}
	reRegisterServerWithResetMappings();
	reRegisterBeans();
	updateCurrentServer();
}
 
Example #3
Source File: IronTestApplication.java    From irontest with Apache License 2.0 5 votes vote down vote up
@Override
public void run(IronTestConfiguration configuration, Environment environment) throws IOException {
    final JdbiFactory jdbiFactory = new JdbiFactory();
    final Jdbi systemDBJdbi = jdbiFactory.build(environment, configuration.getSystemDatabase(), "systemDatabase");

    if (!checkVersion(systemDBJdbi)) {
        System.out.println("Press Enter to exit.");
        System.in.read();
        System.exit(0);
    }

    //  Override Java's trusted cacerts with our own trust store if available.
    //  Notice that setting the properties without the trust store being existing could cause unexpected result
    //  at runtime with Java 10 (Java 1.8 does not have the issue), such as failure of SOAP test step run (caused
    //  by 'new SSLContextBuilder().loadTrustMaterial').
    if (new File(configuration.getSslTrustStorePath()).exists()) {
        System.setProperty("javax.net.ssl.trustStore", configuration.getSslTrustStorePath());
        System.setProperty("javax.net.ssl.trustStorePassword", configuration.getSslTrustStorePassword());
    }

    //  start WireMock server (in the same JVM)
    WireMockServer wireMockServer = new WireMockServer(options()
            .extensions(new ResponseTemplateTransformer(true))
            .port(Integer.parseInt(configuration.getWireMock().get("port")))
            .maxRequestJournalEntries(Integer.parseInt(configuration.getWireMock().get("maxRequestJournalEntries")))
            .notifier(new WireMockFileNotifier())
    );
    wireMockServer.start();

    createSystemResources(configuration, environment, systemDBJdbi, wireMockServer);
    createSampleResources(configuration, environment);
}
 
Example #4
Source File: AbstractGatewayTest.java    From gravitee-gateway with Apache License 2.0 4 votes vote down vote up
protected WireMockRule getWiremockRule() {
    return new WireMockRule(
            wireMockConfig()
                    .dynamicPort()
                    .extensions(new ResponseTemplateTransformer(true)));
}