Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String decodeResponse(byte bresp[])
- {
- String spresp = null;
- byte bcontent[] = new byte[bresp.length - 2];
- for(int i = 0; i < bcontent.length; i++)
- bcontent[i] = bresp[i + 1];
- try
- {
- spresp = new String(bcontent, "US-ASCII");
- }
- catch(UnsupportedEncodingException ex)
- {
- return null;
- }
- return spresp;
- }
- @PrepareForTest(SPSocketCommunicator.class)
- @RunWith(PowerMockRunner.class)
- public class SPSocketCommunicatorTest{
- @test
- public void test() throws Exception {
- byte[] temp = null;
- SPSocketCommunicator socketCommunicator=new SPSocketCommunicator(request, Map);
- SPSocketCommunicator spy = PowerMockito.spy(socketCommunicator);
- PowerMockito.spy(SPSocketCommunicator.class);
- PowerMockito.doReturn("a string").when(spy,"decodeResponse",Matchers.<byte[]>any());
- socketCommunicator.decodeResponse(temp);
- }
- }
Add Comment
Please, Sign In to add comment