本文整理了Java中com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo()
方法的一些代码示例,展示了WireMock.urlEqualTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireMock.urlEqualTo()
方法的具体详情如下:
包路径:com.github.tomakehurst.wiremock.client.WireMock
类名称:WireMock
方法名:urlEqualTo
暂无
代码示例来源:origin: apache/drill
private void setupGetStubs() {
wireMockRule.stubFor(get(urlEqualTo("/api/suggest?type=metrics&max=" + Integer.MAX_VALUE))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(SAMPLE_DATA_FOR_GET_TABLE_NAME_REQUEST)));
wireMockRule.stubFor(get(urlEqualTo("/api/query?start=47y-ago&m=sum:warp.speed.test"))
.willReturn(aResponse()
.withStatus(200)
.withBody(SAMPLE_DATA_FOR_GET_TABLE_REQUEST)
));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAppend() throws Exception {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
final Appender appender = HttpAppender.newBuilder()
.withName("Http")
.withLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.build();
appender.append(createLogEvent());
wireMockRule.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
.withHeader("Host", containing("localhost"))
.withHeader("Content-Type", containing("application/json"))
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE + "\"")));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test(expected = AppenderLoggingException.class)
public void testAppendError() throws Exception {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(FAILURE_RESPONSE));
final Appender appender = HttpAppender.newBuilder()
.withName("Http")
.withLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.withIgnoreExceptions(false)
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.build();
appender.append(createLogEvent());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAppendMethodPut() throws Exception {
wireMockRule.stubFor(put(urlEqualTo("/test/log4j/1234"))
.willReturn(SUCCESS_RESPONSE));
final Appender appender = HttpAppender.newBuilder()
.withName("Http")
.withLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setMethod("PUT")
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/1234"))
.build();
appender.append(createLogEvent());
wireMockRule.verify(putRequestedFor(urlEqualTo("/test/log4j/1234"))
.withHeader("Host", containing("localhost"))
.withHeader("Content-Type", containing("application/json"))
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE + "\"")));
}
代码示例来源:origin: knightliao/disconf
stubFor(get(urlEqualTo(RemoteMockServer.ITEM_URL))
.willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
.withBody(GsonUtils.toJson(valueVo))));
stubFor(get(urlEqualTo(RemoteMockServer.FILE_URL))
.willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
.withHeader("Content-Disposition",
stubFor(get(urlEqualTo(RemoteMockServer.EMPTY_FILE_URL))
.willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
.withHeader("Content-Disposition",
stubFor(get(urlEqualTo(RemoteMockServer.STATIC_FILE_URL))
.willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
.withHeader("Content-Disposition",
stubFor(get(urlEqualTo(RemoteMockServer.NON_ANOTATION_FILE_URL))
.willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
.withHeader("Content-Disposition",
stubFor(get(urlEqualTo(RemoteMockServer.NON_ANOTATION_FILE_URL2))
.willReturn(aResponse().withHeader("Content-Type", "text/html;charset=UTF-8")
.withHeader("Content-Disposition",
stubFor(get(urlEqualTo(RemoteMockServer.ZOO_URL))
.willReturn(aResponse().withHeader("Content-Type", RemoteMockServer.CONTENT_TYPE).withStatus(200)
.withBody(GsonUtils.toJson(valueVo))));
stubFor(get(urlEqualTo(RemoteMockServer.ZOO_PREFIX_URL))
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAppendHttps() throws Exception {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
final Appender appender = HttpAppender.newBuilder()
.withName("Http")
.withLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("https://localhost:" + wireMockRule.httpsPort() + "/test/log4j/"))
.setSslConfiguration(SslConfiguration.createSSLConfiguration(null,
KeyStoreConfiguration.createKeyStoreConfiguration(TestConstants.KEYSTORE_FILE, TestConstants.KEYSTORE_PWD(), TestConstants.KEYSTORE_TYPE, null),
TrustStoreConfiguration.createKeyStoreConfiguration(TestConstants.TRUSTSTORE_FILE, TestConstants.TRUSTSTORE_PWD(), TestConstants.TRUSTSTORE_TYPE, null)))
.setVerifyHostname(false)
.build();
appender.append(createLogEvent());
wireMockRule.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
.withHeader("Host", containing("localhost"))
.withHeader("Content-Type", containing("application/json"))
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE + "\"")));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAppendErrorIgnore() throws Exception {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(FAILURE_RESPONSE));
appender.append(createLogEvent());
wireMockRule.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
.withHeader("Host", containing("localhost"))
.withHeader("Content-Type", containing("application/json"))
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAppendCustomHeader() throws Exception {
wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
.willReturn(SUCCESS_RESPONSE));
final Appender appender = HttpAppender.newBuilder()
.withName("Http")
.withLayout(JsonLayout.createDefaultLayout())
.setConfiguration(ctx.getConfiguration())
.setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
.setHeaders(new Property[] {
Property.createProperty("X-Test", "header value"),
Property.createProperty("X-Runtime", "${java:runtime}")
})
.build();
appender.append(createLogEvent());
wireMockRule.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
.withHeader("Host", containing("localhost"))
.withHeader("X-Test", equalTo("header value"))
.withHeader("X-Runtime", equalTo(JAVA_LOOKUP.getRuntime()))
.withHeader("Content-Type", containing("application/json"))
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE + "\"")));
}
代码示例来源:origin: apache/drill
private void setupPostStubs() {
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(POST_REQUEST_WITHOUT_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(POST_REQUEST_WITH_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(DOWNSAMPLE_REQUEST_WTIHOUT_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(END_PARAM_REQUEST_WTIHOUT_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(DOWNSAMPLE_REQUEST_WITH_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(END_PARAM_REQUEST_WITH_TAGS))
.willReturn(aResponse()
wireMockRule.stubFor(post(urlEqualTo("/api/query"))
.withRequestBody(equalToJson(REQUEST_TO_NONEXISTENT_METRIC))
.willReturn(aResponse()
代码示例来源:origin: palantir/atlasdb
@Test
public void migrationDoesNotProceedIfInvalidationFails() {
when(invalidator.backupAndInvalidate()).thenThrow(new IllegalStateException());
TimeLockMigrator migrator =
TimeLockMigrator.create(
MetricsManagers.createForTests(),
timelockConfig.toNamespacedServerList(), invalidator, USER_AGENT);
assertThatThrownBy(migrator::migrate).isInstanceOf(IllegalStateException.class);
wireMockRule.verify(0, postRequestedFor(urlEqualTo(TEST_ENDPOINT)));
}
代码示例来源:origin: palantir/atlasdb
private void verifyUserAgentOnTimelockTimestampAndLockRequests() {
verifyUserAgentOnTimestampAndLockRequests(TIMELOCK_TIMESTAMP_PATH, TIMELOCK_LOCK_PATH);
verify(invalidator, times(1)).backupAndInvalidate();
availableServer.verify(getRequestedFor(urlEqualTo(TIMELOCK_PING_PATH))
.withHeader(USER_AGENT_HEADER, WireMock.equalTo(USER_AGENT)));
availableServer.verify(postRequestedFor(urlEqualTo(TIMELOCK_FF_PATH))
.withHeader(USER_AGENT_HEADER, WireMock.equalTo(USER_AGENT)));
}
代码示例来源:origin: palantir/atlasdb
@Test
public void propagatesBackupTimestampToFastForwardOnRemoteService() {
wireMockRule.stubFor(TEST_MAPPING.willReturn(aResponse().withStatus(204)));
TimeLockMigrator migrator =
TimeLockMigrator.create(
MetricsManagers.createForTests(),
timelockConfig.toNamespacedServerList(), invalidator, USER_AGENT);
migrator.migrate();
wireMockRule.verify(getRequestedFor(urlEqualTo(PING_ENDPOINT)));
verify(invalidator, times(1)).backupAndInvalidate();
wireMockRule.verify(postRequestedFor(urlEqualTo(TEST_ENDPOINT)));
}
代码示例来源:origin: palantir/atlasdb
.until(migrator::isInitialized);
wireMockRule.verify(getRequestedFor(urlEqualTo(PING_ENDPOINT)));
verify(invalidator, times(2)).backupAndInvalidate();
wireMockRule.verify(postRequestedFor(urlEqualTo(TEST_ENDPOINT)));
代码示例来源:origin: geotools/geotools
@Test
public void testBasicHeader() throws IOException {
stubFor(
get(urlEqualTo("/test"))
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody("<response>Some content</response>")));
String longPassword = String.join("", Collections.nCopies(10, "0123456789"));
String userName = "user";
SimpleHttpClient client = new SimpleHttpClient();
client.setUser(userName);
client.setPassword(longPassword);
client.get(new URL("http://localhost:" + wireMockRule.port() + "/test"));
String encodedCredentials =
"dXNlcjowMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5";
verify(
getRequestedFor(urlEqualTo("/test"))
.withHeader("Authorization", equalTo("Basic " + encodedCredentials)));
}
}
代码示例来源:origin: palantir/atlasdb
@Test
public void asyncMigrationProceedsIfTimeLockInitiallyUnavailable() throws InterruptedException {
String nowSucceeding = "nowSucceeding";
wireMockRule.stubFor(PING_MAPPING.inScenario(SCENARIO)
.whenScenarioStateIs(Scenario.STARTED)
.willReturn(aResponse().withStatus(500))
.willSetStateTo(nowSucceeding));
wireMockRule.stubFor(PING_MAPPING.inScenario(SCENARIO)
.whenScenarioStateIs(nowSucceeding)
.willReturn(aResponse().withStatus(204)));
wireMockRule.stubFor(TEST_MAPPING.willReturn(aResponse().withStatus(204)));
TimeLockMigrator migrator =
TimeLockMigrator.create(
MetricsManagers.createForTests(),
() -> timelockConfig.toNamespacedServerList(), invalidator, USER_AGENT, true);
migrator.migrate();
Awaitility.await()
.atMost(30, TimeUnit.SECONDS)
.pollInterval(1, TimeUnit.SECONDS)
.until(migrator::isInitialized);
wireMockRule.verify(getRequestedFor(urlEqualTo(PING_ENDPOINT)));
verify(invalidator, times(1)).backupAndInvalidate();
wireMockRule.verify(postRequestedFor(urlEqualTo(TEST_ENDPOINT)));
}
代码示例来源:origin: allegro/hermes
public void expectMessages(List<String> messages) {
receivedRequests.clear();
expectedMessages = messages;
messages.forEach(m -> listener
.register(
post(urlEqualTo(path))
.willReturn(aResponse().withStatus(returnedStatusCode).withFixedDelay(delay))));
}
代码示例来源:origin: pl.allegro.tech.hermes/hermes-test-helper
public void expectMessages(List<String> messages) {
receivedRequests.clear();
expectedMessages = messages;
messages.forEach(m -> listener
.register(
post(urlEqualTo(path))
.willReturn(aResponse().withStatus(returnedStatusCode).withFixedDelay(delay))));
}
代码示例来源:origin: io.micrometer/micrometer-test
@Test
void successfulPostNoBody(HttpSender httpClient, @WiremockResolver.Wiremock WireMockServer server) throws Throwable {
server.stubFor(any(anyUrl()));
assertThat(httpClient.post(server.baseUrl() + "/api")
.withPlainText("this is a line")
.send().body()).isEqualTo(HttpSender.Response.NO_RESPONSE_BODY);
server.verify(postRequestedFor(urlEqualTo("/api")).withRequestBody(equalTo("this is a line")));
}
代码示例来源:origin: otros-systems/otroslogviewer
@BeforeClass
public static void setUp() throws IOException {
fsManager = VFS.getManager();
wireMock = new WireMockServer(wireMockConfig().port(PORT));
final byte[] gzipped = toByteArray(getSystemResourceAsStream("hierarchy/hierarchy.log.gz"));
final byte[] notGzipped = toByteArray(getSystemResourceAsStream("hierarchy/hierarchy.log"));
wireMock.stubFor(
get(urlEqualTo("/log.txt")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody(notGzipped)));
wireMock.stubFor(
get(urlEqualTo("/log.txt.gz")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody(gzipped)));
wireMock.start();
}
代码示例来源:origin: mozilla/zest
@Before
public void before() {
server.stubFor(
get(urlEqualTo(PATH_SERVER_FILE))
.willReturn(aResponse().withStatus(200).withBody("This is the response")));
}
内容来源于网络,如有侵权,请联系作者删除!