convert unit tests for cache module to use Mockito

Details

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.

Activity

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.

Joe Campbell
added a comment - 06/Oct/12 21:21 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?

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 Kalnichevski
added a comment - 07/Oct/12 21:19 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

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...

Joe Campbell
added a comment - 07/Oct/12 23:54 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

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 Kalnichevski
added a comment - 08/Oct/12 15:35 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

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.

Joseph Walton
added a comment - 22/Feb/15 12:43 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.