Code example for Socket

Methods: getInputStreamgetSoTimeout

5
 
    @Test 
    public void testAwaitInputInSocket() throws Exception { 
        final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
                new byte[] {1, 2, 3, 4, 5})); 
        Mockito.when(socket.getInputStream()).thenReturn(instream);
        Mockito.when(socket.getSoTimeout()).thenReturn(345);
 
        conn.bind(socket);
        conn.ensureOpen();
 
        Assert.assertTrue(conn.awaitInput(432));
 
        Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
        Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
        Mockito.verify(instream, Mockito.times(1)).read(
                Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()); 
    } 
 
    @Test 
Connect your IDE to all the code out there  Get Codota for Java