1. 15 8月, 2015 4 次提交
    • S
      Rename test classes to avoid confusion · e7c95add
      Sam Brannen 提交于
      e7c95add
    • S
      Polishing · d4d5e5ce
      Sam Brannen 提交于
      d4d5e5ce
    • S
      Differentiate b/t (in)definite results in JsonPath assertions · 07bb0378
      Sam Brannen 提交于
      Prior to this commit, the exists() method in JsonPathExpectationsHelper
      correctly asserted that the evaluated JsonPath expression resulted in a
      value (i.e., that a non-null value exists); however, if the value was
      an empty array, the exists() method always threw an AssertionError.
      
      The existing behavior makes sense if the JsonPath expression is
      'indefinite' -- for example, if the expression uses a filter to select
      results based on a predicate for which there is no match in the JSON
      document, but the existing behavior is illogical and therefore invalid
      if the JsonPath expression is 'definite' (i.e., directly references an
      array in the JSON document that exists but happens to be empty). For
      example, prior to this commit, the following threw an AssertionError.
      
          new JsonPathExpectationsHelper("$.arr").exists("{ 'arr': [] }");
      
      Similar arguments can be made for the doesNotExist() method.
      
      After thorough analysis of the status quo, it has become apparent that
      the existing specialized treatment of arrays is a result of the fact
      that the JsonPath library always returns an empty list if the path is
      an 'indefinite' path that does not evaluate to a specific result.
      Consult the discussion on "What is Returned When?" in the JsonPath
      documentation for details:
      
          https://github.com/jayway/JsonPath#what-is-returned-when
      
      This commit addresses these issues by ensuring that empty arrays are
      considered existent if the JsonPath expression is definite but
      nonexistent if the expression is indefinite.
      
      Issue: SPR-13351
      07bb0378
    • S
      Polish assertion msgs in JsonPathExpectationsHelper · d2503340
      Sam Brannen 提交于
      d2503340
  2. 14 8月, 2015 3 次提交
  3. 13 8月, 2015 1 次提交
  4. 12 8月, 2015 1 次提交
  5. 07 8月, 2015 2 次提交
    • S
      Return null instead of empty cookies array in Spring MVC Test · 93c07e76
      Sam Brannen 提交于
      Prior to this commit, MockHttpServletRequestBuilder always supplied an
      array of cookies to the MockHttpServletRequest that it built, even if
      the array was empty.
      
      However, this violates the contract of HttpServletRequest. According to
      the Servlet API, the getCookies() method "returns null if no cookies
      were sent."
      
      This commit ensures that MockHttpServletRequestBuilder no longer
      configures an empty array of cookies in the mock request that it builds.
      
      Issue: SPR-13314
      93c07e76
    • C
      Introduce additional JsonPath matchers in Spring MVC Test · fffdd1e9
      Craig Andrews 提交于
      This commit introduces the following methods in JsonPathResultMatchers
      in the Spring MVC Test framework.
      
      - isString()
      - isBoolean()
      - isNumber()
      - isMap()
      
      In addition, this commit overhauls the Javadoc in
      JsonPathResultMatchers and JsonPathExpectationsHelper.
      
      Issue: SPR-13320
      fffdd1e9
  6. 28 7月, 2015 4 次提交
    • S
      Polish · 29e6272c
      Sam Brannen 提交于
      29e6272c
    • S
      Redesign MockMvcHtmlUnitDriverBuilder API · 9023cf6a
      Sam Brannen 提交于
      This commit introduces a dedicated build() method in
      MockMvcHtmlUnitDriverBuilder to replace createDriver(). In addition,
      the configureDriver() method has been renamed to withDelegate() and now
      returns the builder for further customization.
      
      This commit also overhauls the Javadoc for static factory methods and
      the class-level Javadoc in MockMvcHtmlUnitDriverBuilder for greater
      clarity to end users.
      
      Issues SPR-13158
      9023cf6a
    • S
      Redesign MockMvcWebClientBuilder API · 3b84a7e8
      Sam Brannen 提交于
      This commit introduces a dedicated build() method in
      MockMvcWebClientBuilder to replace createWebClient(). In addition, the
      configureWebClient() method has been renamed to withDelegate() and now
      returns the builder for further customization.
      
      This commit also overhauls the constructor and class-level Javadoc in
      MockMvcWebClientBuilder for greater clarity to end users.
      
      Issues SPR-13158
      3b84a7e8
    • S
      Polish Javadoc in HtmlUnit support · 3d6f4656
      Sam Brannen 提交于
      3d6f4656
  7. 27 7月, 2015 6 次提交
  8. 26 7月, 2015 4 次提交
    • S
      Introduce @Commit alias for @Rollback(false) · d6bdfcaa
      Sam Brannen 提交于
      Due to common usage of @Rollback(false), this commit introduces a new
      @Commit annotation that more clearly conveys the intent of the code
      while retaining the run-time semantics.
      
      @Commit is in fact meta-annotated with @Rollback(false).
      
      Issue: SPR-13279
      d6bdfcaa
    • S
      Polishing · baa66f7b
      Sam Brannen 提交于
      baa66f7b
    • S
      Migrate @TxConfig usage to @Rollback & @Transactional qualifiers · c4bbc9df
      Sam Brannen 提交于
      Issue: SPR-13276, SPR-13277
      c4bbc9df
    • S
      Support @Rollback on classes & deprecate @TxConfig · 3f8b5128
      Sam Brannen 提交于
      Since Spring Framework 2.5, @Rollback has been supported on test
      methods, with class-level rollback settings configured via
      @TransactionConfiguration; however, allowing @Rollback to be declared
      on test classes with method-level declarations overriding class-level
      declarations would prove more intuitive than having to declare both
      @TransactionConfiguration and @Rollback. Furthermore, the
      transactionManager flag in @TransactionConfiguration was made
      superfluous many years ago with the introduction of support for a
      qualifier in @Transactional.
      
      This commit enables @Rollback to be declared at the class level for
      default rollback semantics within test class hierarchies and deprecates
      @TransactionConfiguration in favor of @Rollback and @Transactional
      qualifiers.
      
      Issue: SPR-13276, SPR-13277
      3f8b5128
  9. 23 7月, 2015 1 次提交
    • B
      Improve DateHeaders in MockServletRequest/Response · 43e36e2d
      Brian Clozel 提交于
      Prior to this change, calling the `setDateHeader` method on a
      Spring Test MockHttpServletResponse instance would just store the given
      long value in a Map, not writing it as a formatted date String.
      Also, calling `getDateHeader` on a MockHttpServletRequest would not
      support date strings and could not parse those values.
      
      This can be problematic when testing features related to date headers
      such as "Expires", "If-Modified-Since", "Last-Modified", etc.
      
      This commit adds formatting and parsing capabilities to Servlet Mocks
      for date strings in HTTP headers.
      
      When formatting dates to Strings, the date format used is the one
      preferred by the HTTP RFC. When parsing date Strings, multiple date
      formats are supported for better compatibility.
      
      Issue: SPR-11912
      43e36e2d
  10. 22 7月, 2015 2 次提交
    • S
      Do not reuse mock requests in Spring MVC Test · 3c799e6e
      Sam Brannen 提交于
      SPR-13211 introduced support for reusing mock requests in Spring MVC
      Test if the request was created by the the Spring TestContext
      Framework. Unfortunately, that change makes it impossible for
      MockMvc.perform() to be invoked multiple times within the same test
      method without side effects. For example, session attributes and
      request parameters are transparently and unexpectedly retained for
      subsequent invocations of perform(), causing certain categories of
      tests to fail.
      
      This commit reverts the changes introduced in SPR-13211 and introduces
      a new MockMvcReuseTests class to serve as regression tests within
      Spring's test suite.
      
      Issue: SPR-13260, SPR-13211
      3c799e6e
    • B
      Add a dateValue HeaderResultMatcher · cf2aed9d
      Brian Clozel 提交于
      HTTP headers such as "Expires", "Last-Modified" all use date
      strings like "Tue, 21 Jul 2015 10:00:00 GMT". Prior to this commit,
      there was no way to match those header values, besides formatting dates
      manually.
      
      This commit introduces a new HeaderResultMatcher to test those date
      headers using a long timestamp:
      
      ```
      this.mockMvc.perform(get("/persons/1").header("If-Modified-Since", now))
        .andExpect(status().isNotModified())
        .andExpect(header().dateValue("Last-Modified", timestamp));
      ```
      
      Issue: SPR-13263
      cf2aed9d
  11. 21 7月, 2015 3 次提交
    • S
      Delete unused imports in HeaderAssertionTests · d8fb6c55
      Sam Brannen 提交于
      d8fb6c55
    • B
      Partial revert of SPR-13090 · dba46c13
      Brian Clozel 提交于
      Use ServletHttpResponse.setDateHeader whenever possible and avoid using
      SimpleDateFormat.
      dba46c13
    • S
      Reuse mock request from the TCF in Spring MVC Test · bf06bf33
      Sam Brannen 提交于
      Prior to this commit, the Spring MVC Test Framework always created a
      new MockHttpServletRequest, disregarding any mock request already
      present in Spring Web's RequestContextHolder -- for example, one
      created by the ServletTestExecutionListener in the Spring TestContext
      Framework (TCF).
      
      This commit modifies MockHttpServletRequestBuilder so that it reuses a
      mock request created by the TCF. However,
      MockMultipartHttpServletRequestBuilder continues to always create a new
      MockMultipartHttpServletRequest since a MockHttpServletRequest created
      by the TCF is not directly compatible with a
      MockMultipartHttpServletRequest. Furthermore, in order to avoid
      unforeseen side effects, MockHttpServletRequestBuilder will always
      create a new MockHttpServletRequest if a mock request is present in the
      RequestContextHolder but not created by the TCF.
      
      Issue: SPR-13211
      bf06bf33
  12. 17 7月, 2015 2 次提交
  13. 15 7月, 2015 1 次提交
  14. 10 7月, 2015 1 次提交
    • S
      Populate RequestAttributes before invoking Filters in MockMvc · 9c46228a
      Sam Brannen 提交于
      When using the Spring TestContext Framework (TCF) to load a
      WebApplicationContext and the Spring MVC Test Framework (MockMvc) to
      test a controller, two instances of MockHttpServletRequest will be
      created. Due to an ordering issue with regard to population of the
      RequestAttributes, it is therefore possible that a filter accesses the
      mocked request managed by the TCF, while the controller accesses the
      mocked request managed by MockMvc, and this leads to test failures if
      the controller expects data from the filter to be present in the
      request.
      
      This commit fixes this bug by ensuring that the RequestAttributes
      backed by the mocked request managed by MockMvc are stored in the
      RequestContextHolder before any filters are invoked by MockMvc.
      
      Issue: SPR-13217
      9c46228a
  15. 08 7月, 2015 2 次提交
    • S
      Investigate claims raised in SPR-13211 · 3c2efeec
      Sam Brannen 提交于
      This commit adds additional tests to RequestContextHolderTests that
      verify proper support for the MockHttpServletRequest managed by Spring
      MVC Test in the following scenarios:
      
      - request-scoped service invoked by controller
      - session-scoped service invoked by controller
      - custom filter that sets request attributes
      
      Issue: SPR-13211
      3c2efeec
    • S
      Update RequestContextHolderTests · 5e24ee9b
      Sam Brannen 提交于
      This commit refactors RequestContextHolderTests in preparation for the
      work to be done in SPR-13211.
      
      Issue: SPR-13211
      5e24ee9b
  16. 04 7月, 2015 1 次提交
  17. 03 7月, 2015 2 次提交