Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleRequestExpectationManager fails with sequential calls with different count [SPR-15672] #20231

Closed
spring-issuemaster opened this issue Jun 16, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Jun 16, 2017

Pablo Santiago opened SPR-15672 and commented

When creating a MockRestServiceServer and setting a sequential expectation with different counts, it fails:

public class ExpectedCountTest {

    private SimpleRequestExpectationManager manager = new SimpleRequestExpectationManager();

    @Test
    public void sequentialRequestsWithDifferentCount() throws Exception {
        this.manager.expectRequest(times(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
        this.manager.expectRequest(once(), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());

        this.manager.validateRequest(createRequest(GET, "/foo"));
        this.manager.validateRequest(createRequest(GET, "/foo"));
        this.manager.validateRequest(createRequest(GET, "/bar"));
    }

    private ClientHttpRequest createRequest(HttpMethod method, String url) {
        return new MockAsyncClientHttpRequest(method, URI.create(url));
    }

}

Affects: 4.3.8

Reference URL: https://github.com/spring-projects/spring-framework-issues/tree/master/SPR-15672

Issue Links:

  • #20275 MockRestServiceServer does not honor expectation order with expectations that mandate more than 1 execution. ("supersedes")

Referenced from: commits efb735a, a17255a

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 16, 2017

Stéphane Nicoll commented

There is a repro project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.