Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Mockery mocker = new Mockery(){{
  2. setImposteriser(ClassImposteriser.INSTANCE);
  3. }};
  4.  
  5. // Setup http mocks
  6. final DefaultHttpClient httpClient = mocker.mock(DefaultHttpClient.class);
  7. final HttpResponse httpResponse = mocker.mock(HttpResponse.class);
  8. final HttpEntity httpEntity = mocker.mock(HttpEntity.class);
  9.  
  10. try {
  11. mocker.checking(new Expectations() {{
  12. oneOf (httpClient).execute(with(any(HttpUriRequest.class)));
  13. will(returnValue(httpResponse));
  14.  
  15. oneOf (httpResponse).getEntity();
  16. will(returnValue(httpEntity));
  17.  
  18. oneOf (httpEntity).getContent();
  19. will(returnValue(new ByteArrayInputStream("Boo".getBytes("UTF-8"))));
  20.  
  21. }});
  22. }catch(Exception e){
  23. e.printStackTrace();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement