Good morning. I've been beating my head against this for the past 24 hours.
The following three links are:
- RestClient class - https://gist.github.com/2a2dd1e1b227dac24e80
- RestClient Testclass - https://gist.github.com/ad45ab59ac1f9f1a251f
- HttpCalloutMock provider - https://gist.github.com/b71ef196ebd2114e6d4e
In any given dev org (that I've tried), and in the sandbox org these tests run without error, and demonstrate 100% test coverage of the test class. (whether thats a good thing is not at play here please). However, if I try to push this code to production I receive the following errors:
Furthermore, this is all the debug log information I can find. Nothing shows in the dev console, nothing shows in the debug logs. If I deploy via a change set I get marginally more information -- in that I get line numbers on which the errors occur.
Interesting, to me at least, is that the errors all seem to occur on HTTP Success codes (200) statuses.
I have seen the very similar seeming issue here: https://stackoverflow.com/questions/14833509/exception-when-deploying-a-httpcalloutmock
but there does not seem to be clear indications on when/what or if that issue was overcome. Additionally, I have retraced my code, and verified that, for instance the failure on line 51 does indeed invoke the get convenience method, which invokes the full constructor, which creates a request, and finally invokes the .send() method.
I am at a complete loss here, and any help would be greatly appreciated. Even if it's just to hit me upside the head and tell me where to look to see more detailed logs...
Update I have narrowed this down pretty specifically.
If you attempt to push a test that utilizes the above linked HttpCalloutMock Provider with a return code of 200, and a body, that test will fail. Specifically, the body will not be returned from the mock object to the rest class and hence to the test. Either not returning a body (and why would you want to do that on a success test?) or changing the response code allow this to run.
Do any of my fellow force.com Apex nerds (represent!) see anything wrong with that HttpCalloutMock class? I'm hours away from offering an SE bounty -- but I will start the beer @ df (for appropriately aged peeps) bounty right now.
And yes, I have a case open with SF. I am starting to get that sick-to-your-stomach-guess-who's-got-two-thumbs-and-found-a-platform-bug feeling.