Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15672

SimpleRequestExpectationManager fails with sequential calls with different count

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.3.8
    • Fix Version/s: 4.3.10, 5.0 RC3
    • Component/s: Test
    • Labels:

      Description

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              polysantiago Pablo Santiago
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 45 weeks, 4 days ago