本文整理了Java中com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor()
方法的一些代码示例,展示了WireMock.getRequestedFor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireMock.getRequestedFor()
方法的具体详情如下:
包路径:com.github.tomakehurst.wiremock.client.WireMock
类名称:WireMock
方法名:getRequestedFor
暂无
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testSuccessful() throws Exception {
setupStub(200);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isEqualTo("Hello, world!");
verify(testServiceFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallback() throws Exception {
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testRevertFallback() throws Exception {
setupStub(400);
testService.greeting();
setupStub(200);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isEqualTo("Hello, world!");
verify(testServiceFallback, times(1)).greeting();
verify(2, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackExceptionFilterNotCalled() throws Exception {
final TestService testServiceExceptionFallback = mock(TestService.class);
when(testServiceExceptionFallback.greeting()).thenReturn("exception fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceExceptionFallback, CircuitBreakerOpenException.class)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(testServiceExceptionFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testSuccessfulCall() throws Exception {
final CircuitBreaker.Metrics metrics = circuitBreaker.getMetrics();
setupStub(200);
testService.greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
assertThat(metrics.getNumberOfSuccessfulCalls())
.describedAs("Successful Calls")
.isEqualTo(1);
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackExceptionFilter() throws Exception {
final TestService testServiceExceptionFallback = mock(TestService.class);
when(testServiceExceptionFallback.greeting()).thenReturn("exception fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceExceptionFallback, FeignException.class)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("exception fallback");
verify(testServiceFallback, times(0)).greeting();
verify(testServiceExceptionFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackFilter() throws Exception {
final TestService testServiceFilterFallback = mock(TestService.class);
when(testServiceFilterFallback.greeting()).thenReturn("filter fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceFilterFallback, ex -> true)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("filter fallback");
verify(testServiceFallback, times(0)).greeting();
verify(testServiceFilterFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackFilterNotCalled() throws Exception {
final TestService testServiceFilterFallback = mock(TestService.class);
when(testServiceFilterFallback.greeting()).thenReturn("filter fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceFilterFallback, ex -> false)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(testServiceFilterFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testSuccessfulCall() throws Exception {
setupStub(200);
testService.greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test(expected = RequestNotPermitted.class)
public void testRatelimterLimiting() throws Exception {
setupStub(200);
testService.greeting();
testService.greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void decorateSuccessfulCall() throws Exception {
stubFor(get(urlPathEqualTo("/greeting"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("hello world")));
service.greeting().execute();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldNotCallServiceOnEnqueueWhenOpen() throws Throwable {
stubFor(get(urlPathEqualTo("/greeting"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("hello world")));
circuitBreaker.transitionToOpenState();
try {
EnqueueDecorator.enqueue(service.greeting());
fail("CircuitBreakerOpenException was expected");
} catch (CircuitBreakerOpenException ignore) {
}
ensureAllRequestsAreExecuted(Duration.ofSeconds(1));
verify(0, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void decorateSuccessfulEnqueuedCall() throws Throwable {
stubFor(get(urlPathEqualTo("/greeting"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("hello world")));
EnqueueDecorator.enqueue(service.greeting());
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void decorateSuccessfulCall() throws Exception {
stubFor(get(urlPathEqualTo("/greeting"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("hello world")));
service.greeting().execute();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void decorateSuccessfulEnqueuedCall() throws Throwable {
stubFor(get(urlPathEqualTo("/greeting"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/plain")
.withBody("hello world")));
EnqueueDecorator.enqueue(service.greeting());
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: palantir/atlasdb
@Test
public void directProxyIsConfigurableOnClientRequests() {
Optional<ProxySelector> directProxySelector = Optional.of(
ServiceCreator.createProxySelector(ProxyConfiguration.DIRECT));
TestResource clientWithDirectCall = AtlasDbHttpClients.createProxyWithFailover(
new MetricRegistry(), NO_SSL,
directProxySelector, ImmutableSet.of(getUriForPort(availablePort)), TestResource.class);
clientWithDirectCall.getTestNumber();
String defaultUserAgent = UserAgents.fromStrings(UserAgents.DEFAULT_VALUE, UserAgents.DEFAULT_VALUE);
availableServer.verify(getRequestedFor(urlMatching(TEST_ENDPOINT))
.withHeader(FeignOkHttpClients.USER_AGENT_HEADER, WireMock.equalTo(defaultUserAgent)));
}
代码示例来源: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 userAgentIsPresentOnClientRequests() {
TestResource client =
AtlasDbHttpClients.createProxy(
new MetricRegistry(), NO_SSL, getUriForPort(availablePort), TestResource.class);
client.getTestNumber();
String defaultUserAgent = UserAgents.fromStrings(UserAgents.DEFAULT_VALUE, UserAgents.DEFAULT_VALUE);
availableServer.verify(getRequestedFor(urlMatching(TEST_ENDPOINT))
.withHeader(FeignOkHttpClients.USER_AGENT_HEADER, WireMock.equalTo(defaultUserAgent)));
}
代码示例来源: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
@Test
public void remoteCallsElidedIfTalkingToLocalServer() throws IOException, InterruptedException {
setUpForLocalServices();
setUpLeaderBlockInConfig();
TransactionManagers.LockAndTimestampServices lockAndTimestamp = getLockAndTimestampServices();
availableServer.verify(getRequestedFor(urlMatching(LEADER_UUID_PATH)));
lockAndTimestamp.timelock().getFreshTimestamp();
lockAndTimestamp.lock().currentTimeMillis();
availableServer.verify(0, postRequestedFor(urlMatching(TIMESTAMP_PATH))
.withHeader(USER_AGENT_HEADER, WireMock.equalTo(USER_AGENT)));
availableServer.verify(0, postRequestedFor(urlMatching(LOCK_PATH))
.withHeader(USER_AGENT_HEADER, WireMock.equalTo(USER_AGENT)));
}
内容来源于网络,如有侵权,请联系作者删除!