Search in sources :

Example 1 with WireMockRule

use of com.github.tomakehurst.wiremock.junit.WireMockRule in project blueocean-plugin by jenkinsci.

the class WireMockBase method createWireMockServerRule.

protected static WireMockRule createWireMockServerRule(String resourceFolder, String baseUrl) {
    ReplaceUrlTransformer replaceUrlTransformer = new ReplaceUrlTransformer();
    final WireMockRule rule = new WireMockRule(wireMockConfig().dynamicPort().dynamicHttpsPort().usingFilesUnderClasspath(resourceFolder).extensions(new GzipDecompressTransformer(), replaceUrlTransformer));
    String mappingsPath = String.format("src/test/resources/%s/mappings", resourceFolder);
    String filesPath = String.format("src/test/resources/%s/__files", resourceFolder);
    new File(mappingsPath).mkdirs();
    new File(filesPath).mkdirs();
    rule.enableRecordMappings(new SingleRootFileSource(mappingsPath), new SingleRootFileSource(filesPath));
    rule.stubFor(WireMock.get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom(baseUrl)));
    replaceUrlTransformer.configure(baseUrl, rule);
    return rule;
}
Also used : WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) File(java.io.File) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource)

Example 2 with WireMockRule

use of com.github.tomakehurst.wiremock.junit.WireMockRule in project blueocean-plugin by jenkinsci.

the class BitbucketWireMockBase method setup.

@Before
public void setup() throws Exception {
    super.setup();
    this.authenticatedUser = login();
    WireMockRule bitbucketApi = getWireMockRule();
    String files = wireMockFileSystemPath() + "__files";
    String mappings = wireMockFileSystemPath() + "mappings";
    String proxyUrl = wireMockProxyUrl();
    new File(mappings).mkdirs();
    new File(files).mkdirs();
    bitbucketApi.enableRecordMappings(new SingleRootFileSource(mappings), new SingleRootFileSource(files));
    bitbucketApi.stubFor(WireMock.get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom(proxyUrl)));
    this.apiUrl = String.format("http://localhost:%s", bitbucketApi.port());
}
Also used : WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) File(java.io.File) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource) Before(org.junit.Before)

Example 3 with WireMockRule

use of com.github.tomakehurst.wiremock.junit.WireMockRule in project blueocean-plugin by jenkinsci.

the class HttpRequestTest method createWireMockServerRule.

private static WireMockRule createWireMockServerRule(String resourceFolder) {
    final WireMockRule rule = new WireMockRule(wireMockConfig().dynamicPort().usingFilesUnderClasspath(resourceFolder));
    String mappingsPath = String.format("src/test/resources/%s/mappings", resourceFolder);
    String filesPath = String.format("src/test/resources/%s/__files", resourceFolder);
    new File(mappingsPath).mkdirs();
    new File(filesPath).mkdirs();
    rule.enableRecordMappings(new SingleRootFileSource(mappingsPath), new SingleRootFileSource(filesPath));
    return rule;
}
Also used : WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) File(java.io.File) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource)

Example 4 with WireMockRule

use of com.github.tomakehurst.wiremock.junit.WireMockRule in project syndesis by syndesisio.

the class DynamicActionSalesforceITCase method startMockIfNeeded.

@BeforeClass
public static void startMockIfNeeded() {
    if (wireMock == null || !wireMock.isRunning()) {
        wireMock = new WireMockRule(wireMockConfig().dynamicPort());
        wireMock.start();
    }
}
Also used : WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) BeforeClass(org.junit.BeforeClass)

Example 5 with WireMockRule

use of com.github.tomakehurst.wiremock.junit.WireMockRule in project syndesis by syndesisio.

the class DynamicActionSqlStoredITCase method startMockIfNeeded.

@BeforeClass
public static void startMockIfNeeded() {
    if (wireMock == null || !wireMock.isRunning()) {
        wireMock = new WireMockRule(wireMockConfig().dynamicPort());
        wireMock.start();
    }
}
Also used : WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) BeforeClass(org.junit.BeforeClass)

Aggregations

WireMockRule (com.github.tomakehurst.wiremock.junit.WireMockRule)5 SingleRootFileSource (com.github.tomakehurst.wiremock.common.SingleRootFileSource)3 File (java.io.File)3 BeforeClass (org.junit.BeforeClass)2 Before (org.junit.Before)1