Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. @isTest
  2.  
  3. private class WebSvcCalloutTest {
  4. @isTest static void testEchoString() {
  5. // This causes a fake response to be generated
  6. Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
  7.  
  8. // Call the method that invokes a callout
  9. String output = WebSvcCallout.callEchoString('Hello World!');
  10.  
  11. // Verify that a fake result is returned
  12. System.assertEquals('Mock response', output);
  13. }
  14. }
  15.  
  16. @isTest
  17.  
  18. global class WebServiceMockImpl implements WebServiceMock {
  19. global void doInvoke(
  20. Object stub,
  21. Object request,
  22. Map<String, Object> response,
  23. String endpoint,
  24. String soapAction,
  25. String requestName,
  26. String responseNS,
  27. String responseName,
  28. String responseType) {
  29. docSample.EchoStringResponse_element respElement =
  30. new docSample.EchoStringResponse_element();
  31. respElement.EchoStringResult = 'Mock response';
  32. response.put('response_x', respElement);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement