本文整理汇总了Java中org.mockserver.matchers.TimeToLive.unlimited方法的典型用法代码示例。如果您正苦于以下问题:Java TimeToLive.unlimited方法的具体用法?Java TimeToLive.unlimited怎么用?Java TimeToLive.unlimited使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mockserver.matchers.TimeToLive
的用法示例。
在下文中一共展示了TimeToLive.unlimited方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldNotRemoveAfterTimesComplete
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
@Test
public void shouldNotRemoveAfterTimesComplete() {
// when
Expectation expectation = new Expectation(new HttpRequest().withPath("somepath"), Times.exactly(2), TimeToLive.unlimited()).thenRespond(httpResponse.withBody("someBody"));
mockServerMatcher.add(expectation);
Expectation notRemovedExpectation = new Expectation(httpRequest.withPath("someOtherPath"), Times.exactly(2), TimeToLive.unlimited());
mockServerMatcher.add(notRemovedExpectation.thenRespond(response().withBody("someOtherBody")));
// then
assertEquals(expectation, mockServerMatcher.firstMatchingExpectation(new HttpRequest().withPath("somepath")));
assertEquals(expectation, mockServerMatcher.firstMatchingExpectation(new HttpRequest().withPath("somepath")));
assertEquals(notRemovedExpectation, mockServerMatcher.firstMatchingExpectation(new HttpRequest().withPath("someOtherPath")));
assertThat(mockServerMatcher.httpRequestMatchers.size(), is(1));
// then
assertEquals(notRemovedExpectation, mockServerMatcher.firstMatchingExpectation(new HttpRequest().withPath("someOtherPath")));
assertThat(mockServerMatcher.httpRequestMatchers.size(), is(0));
}
示例2: shouldHandleNullFieldInput
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
@Test
public void shouldHandleNullFieldInput() {
// when
ExpectationDTO expectationDTO = new ExpectationDTO(new Expectation(null, null, TimeToLive.unlimited()));
// then
assertThat(expectationDTO.getHttpRequest(), is(nullValue()));
assertThat(expectationDTO.getTimes(), is(nullValue()));
assertThat(expectationDTO.getHttpResponse(), is(nullValue()));
assertThat(expectationDTO.getHttpResponseTemplate(), is(nullValue()));
assertThat(expectationDTO.getHttpResponseClassCallback(), is(nullValue()));
assertThat(expectationDTO.getHttpResponseObjectCallback(), is(nullValue()));
assertThat(expectationDTO.getHttpForward(), is(nullValue()));
assertThat(expectationDTO.getHttpForwardTemplate(), is(nullValue()));
assertThat(expectationDTO.getHttpForwardClassCallback(), is(nullValue()));
assertThat(expectationDTO.getHttpForwardObjectCallback(), is(nullValue()));
assertThat(expectationDTO.getHttpOverrideForwardedRequest(), is(nullValue()));
assertThat(expectationDTO.getHttpError(), is(nullValue()));
}
示例3: buildObject
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
public TimeToLive buildObject() {
if (unlimited) {
return TimeToLive.unlimited();
} else {
return TimeToLive.exactly(timeUnit, timeToLive);
}
}
示例4: shouldReduceRemainingMatches
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
@Test
public void shouldReduceRemainingMatches() {
// given
Expectation expectation = new Expectation(null, Times.once(), TimeToLive.unlimited());
// when
expectation.decrementRemainingMatches();
// then
assertThat(expectation.getTimes().getRemainingTimes(), is(0));
}
示例5: shouldNotThrowExceptionWithReducingNullRemainingMatches
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
@Test
public void shouldNotThrowExceptionWithReducingNullRemainingMatches() {
// given
Expectation expectation = new Expectation(null, null, TimeToLive.unlimited());
// when
expectation.decrementRemainingMatches();
// then
assertThat(expectation.getTimes(), nullValue());
}
示例6: Expectation
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
public Expectation(HttpRequest httpRequest) {
this(httpRequest, Times.unlimited(), TimeToLive.unlimited());
}
示例7: buildObject
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
public Expectation buildObject() {
HttpRequest httpRequest = null;
HttpResponse httpResponse = null;
HttpTemplate httpResponseTemplate = null;
HttpClassCallback httpResponseClassCallback = null;
HttpObjectCallback httpResponseObjectCallback = null;
HttpForward httpForward = null;
HttpTemplate httpForwardTemplate = null;
HttpClassCallback httpForwardClassCallback = null;
HttpObjectCallback httpForwardObjectCallback = null;
HttpOverrideForwardedRequest httpOverrideForwardedRequest = null;
HttpError httpError = null;
Times times;
TimeToLive timeToLive;
if (this.httpRequest != null) {
httpRequest = this.httpRequest.buildObject();
}
if (this.httpResponse != null) {
httpResponse = this.httpResponse.buildObject();
}
if (this.httpResponseTemplate != null) {
httpResponseTemplate = this.httpResponseTemplate.buildObject();
}
if (this.httpResponseClassCallback != null) {
httpResponseClassCallback = this.httpResponseClassCallback.buildObject();
}
if (this.httpResponseObjectCallback != null) {
httpResponseObjectCallback = this.httpResponseObjectCallback.buildObject();
}
if (this.httpForward != null) {
httpForward = this.httpForward.buildObject();
}
if (this.httpForwardTemplate != null) {
httpForwardTemplate = this.httpForwardTemplate.buildObject();
}
if (this.httpForwardClassCallback != null) {
httpForwardClassCallback = this.httpForwardClassCallback.buildObject();
}
if (this.httpForwardObjectCallback != null) {
httpForwardObjectCallback = this.httpForwardObjectCallback.buildObject();
}
if (this.httpOverrideForwardedRequest != null) {
httpOverrideForwardedRequest = this.httpOverrideForwardedRequest.buildObject();
}
if (this.httpError != null) {
httpError = this.httpError.buildObject();
}
if (this.times != null) {
times = this.times.buildObject();
} else {
times = Times.unlimited();
}
if (this.timeToLive != null) {
timeToLive = this.timeToLive.buildObject();
} else {
timeToLive = TimeToLive.unlimited();
}
return new Expectation(httpRequest, times, timeToLive)
.thenRespond(httpResponse)
.thenRespond(httpResponseTemplate)
.thenRespond(httpResponseClassCallback)
.thenRespond(httpResponseObjectCallback)
.thenForward(httpForward)
.thenForward(httpForwardTemplate)
.thenForward(httpForwardClassCallback)
.thenForward(httpForwardObjectCallback)
.thenForward(httpOverrideForwardedRequest)
.thenError(httpError);
}
示例8: when
import org.mockserver.matchers.TimeToLive; //导入方法依赖的package包/类
/**
* Specify an limited expectation that will respond a specified number of times when the http is matched
* for example:
* <pre>
* mockServerClient
* .when(
* request()
* .withPath("/some_path")
* .withBody("some_request_body"),
* Times.exactly(5)
* )
* .respond(
* response()
* .withBody("some_response_body")
* .withHeader("responseName", "responseValue")
* )
* </pre>
*
* @param httpRequest the http request that must be matched for this expectation to respond
* @param times the number of times to respond when this http is matched
* @return an Expectation object that can be used to specify the response
*/
public ForwardChainExpectation when(HttpRequest httpRequest, Times times) {
return new ForwardChainExpectation(this, new Expectation(httpRequest, times, TimeToLive.unlimited()));
}