Guest User

Untitled

a guest
Nov 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. private String decodeResponse(byte bresp[])
  2. {
  3.  
  4. String spresp = null;
  5.  
  6. byte bcontent[] = new byte[bresp.length - 2];
  7.  
  8. for(int i = 0; i < bcontent.length; i++)
  9. bcontent[i] = bresp[i + 1];
  10.  
  11. try
  12. {
  13. spresp = new String(bcontent, "US-ASCII");
  14. }
  15. catch(UnsupportedEncodingException ex)
  16. {
  17. return null;
  18. }
  19.  
  20. return spresp;
  21. }
  22.  
  23. @PrepareForTest(SPSocketCommunicator.class)
  24. @RunWith(PowerMockRunner.class)
  25. public class SPSocketCommunicatorTest{
  26.  
  27. @test
  28. public void test() throws Exception {
  29. byte[] temp = null;
  30. SPSocketCommunicator socketCommunicator=new SPSocketCommunicator(request, Map);
  31. SPSocketCommunicator spy = PowerMockito.spy(socketCommunicator);
  32. PowerMockito.spy(SPSocketCommunicator.class);
  33. PowerMockito.doReturn("a string").when(spy,"decodeResponse",Matchers.<byte[]>any());
  34. socketCommunicator.decodeResponse(temp);
  35. }
  36. }
Add Comment
Please, Sign In to add comment