HttpComponents HttpClient
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1244

convert unit tests for cache module to use Mockito

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Future
    • Component/s: HttpCache
    • Labels:

      Description

      Currently the unit tests for the caching module, while comprehensive, use strict mocks from EasyMock. In many cases, these tests are brittle in ways they shouldn't be. Converting to Mockito (as the rest of the httpclient codebase does) would potentially help here, as well as unifying the unit test frameworks used across the codebase.

        Issue Links

          Activity

          Hide
          Joe Campbell added a comment -

          I think actually - that I converted the last of the original mockito tests that existed in the HTTPclient code base when the caching client was originally submitted. Rather I think what we would like to do is change the 'strict' mock default of EasyMock to the 'relaxed' version so that additional calls that are made the don't impact the over all compliance can be added without impacting hundreds of unit tests.

          Thoughts?

          Show
          Joe Campbell added a comment - I think actually - that I converted the last of the original mockito tests that existed in the HTTPclient code base when the caching client was originally submitted. Rather I think what we would like to do is change the 'strict' mock default of EasyMock to the 'relaxed' version so that additional calls that are made the don't impact the over all compliance can be added without impacting hundreds of unit tests. Thoughts?
          Hide
          Oleg Kalnichevski added a comment -

          Joe et al
          Switching EasyMock to the 'relaxed' mode would certainly be a reasonable immediate action. It would great if some one familiar with EasyMock could look into it. However. long term we should migrate the caching unit tests to Mockito.

          Oleg

          Show
          Oleg Kalnichevski added a comment - Joe et al Switching EasyMock to the 'relaxed' mode would certainly be a reasonable immediate action. It would great if some one familiar with EasyMock could look into it. However. long term we should migrate the caching unit tests to Mockito. Oleg
          Hide
          Joe Campbell added a comment -

          Ok - Attached is a patch that just does the createMock --> createNiceMock conversion for the caching unit tests. Will work on converting to mockito at some point in the nearish future. Can I assume that it is an apache standard to use mockito...

          Thanks,
          Joe

          Show
          Joe Campbell added a comment - Ok - Attached is a patch that just does the createMock --> createNiceMock conversion for the caching unit tests. Will work on converting to mockito at some point in the nearish future. Can I assume that it is an apache standard to use mockito... Thanks, Joe
          Hide
          Oleg Kalnichevski added a comment -

          Patch committed to both SVN trunk and 4.2.x branch. Many thanks, Joe, for contributing it.

          To my best knowledge the only standards that ASF enforces is licensing. Otherwise it is pretty much up to individual projects to decide what kind of ALv2 compatible software to use. I am personally biased toward Mockito, but could live with any mocking framework as long as it is being used consistently across all HC projects and modules. At present migration off EasyMock to Mockito looks easier.

          Oleg

          Show
          Oleg Kalnichevski added a comment - Patch committed to both SVN trunk and 4.2.x branch. Many thanks, Joe, for contributing it. To my best knowledge the only standards that ASF enforces is licensing. Otherwise it is pretty much up to individual projects to decide what kind of ALv2 compatible software to use. I am personally biased toward Mockito, but could live with any mocking framework as long as it is being used consistently across all HC projects and modules. At present migration off EasyMock to Mockito looks easier. Oleg
          Hide
          Joseph Walton added a comment -

          In the interests of consolidating on Mockito, I've taken a look at converting the majority of the remaining tests (patch attached). It's a fairly mechanical conversion, which also drops some unused mocking.

          The remaining unconverted tests are the AbstractProtocolTest and TestCachingExec tests which make more extensive use of matchers.

          Show
          Joseph Walton added a comment - In the interests of consolidating on Mockito, I've taken a look at converting the majority of the remaining tests (patch attached). It's a fairly mechanical conversion, which also drops some unused mocking. The remaining unconverted tests are the AbstractProtocolTest and TestCachingExec tests which make more extensive use of matchers.
          Hide
          Oleg Kalnichevski added a comment -

          Awesome! Many thanks, Joseph, for contributing the patch. Committed to SVN trunk.

          Oleg

          Show
          Oleg Kalnichevski added a comment - Awesome! Many thanks, Joseph, for contributing the patch. Committed to SVN trunk. Oleg

            People

            • Assignee:
              Unassigned
              Reporter:
              Jon Moore
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Development