Search in sources :

Example 1 with SingleRootFileSource

use of com.github.tomakehurst.wiremock.common.SingleRootFileSource 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 SingleRootFileSource

use of com.github.tomakehurst.wiremock.common.SingleRootFileSource in project blueocean-plugin by jenkinsci.

the class GithubMockBase method setup.

@Override
public void setup() throws Exception {
    super.setup();
    // setup github api mock with WireMock
    new File("src/test/resources/api/mappings").mkdirs();
    new File("src/test/resources/api/__files").mkdirs();
    githubApi.enableRecordMappings(new SingleRootFileSource("src/test/resources/api/mappings"), new SingleRootFileSource("src/test/resources/api/__files"));
    githubApi.stubFor(WireMock.get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom("https://api.github.com/")));
    this.user = login("vivek", "Vivek Pandey", "vivek.pandey@gmail.com");
    this.githubApiUrl = String.format("http://localhost:%s", githubApi.port());
}
Also used : File(java.io.File) SingleRootFileSource(com.github.tomakehurst.wiremock.common.SingleRootFileSource)

Example 3 with SingleRootFileSource

use of com.github.tomakehurst.wiremock.common.SingleRootFileSource 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 4 with SingleRootFileSource

use of com.github.tomakehurst.wiremock.common.SingleRootFileSource 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)

Aggregations

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