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;
}
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());
}
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());
}
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;
}
Aggregations