mil.dod.th.ose.time.service/test/mil/dod/th/ose/time/service/TestTimeChangeServiceThread.java
@Test
    public void testRunReadTimeout() throws IOException, InterruptedException
    {
        Socket client = mock(Socket.class);
        when(m_ServerSocket.accept()).thenReturn(client);
        
        InputStream stream = mock(InputStream.class);
        when(client.getInputStream()).thenReturn(stream);
        
        doThrow(SocketException.class).
            when(stream).read(Mockito.any(byte[].class), Mockito.anyInt(), Mockito.anyInt());
       
        //kick off runner
        Thread thread = new Thread(m_SUT);
        thread.start();
        
        //give thread time to run
        Thread.sleep(100);
        
        m_SUT.stopRun();
        thread.join(5000);
        
        verify(m_SysTimeWrapper, never()).setSystemTime(Mockito.anyLong());        
    }
/**
     * Verify if no input received socket timeout occurs and the system time is never set.
     */
Verify if no input received socket timeout occurs and the system time is never set.
Verify if no input received socket timeout occurs and the system time is never set .
@Test
    public void testRunReadTimeout() throws IOException, InterruptedException
    {
        Socket client = mock(Socket.class);
        when(m_ServerSocket.accept()).thenReturn(client);
        InputStream stream = mock(InputStream.class);
        when(client.getInputStream()).thenReturn(stream);
        doThrow(SocketException.class).
            when(stream).read(Mockito.any(byte[].class), Mockito.anyInt(), Mockito.anyInt());
        Thread thread = new Thread(m_SUT);
        thread.start();
        Thread.sleep(100);
        m_SUT.stopRun();
        thread.join(5000);
        verify(m_SysTimeWrapper, never()).setSystemTime(Mockito.anyLong());        
    }
@ Test public void testRunReadTimeout ( ) throws IOException , InterruptedException { Socket client = mock ( Socket . class ) ; when ( m_ServerSocket . accept ( ) ) . thenReturn ( client ) ; InputStream stream = mock ( InputStream . class ) ; when ( client . getInputStream ( ) ) . thenReturn ( stream ) ; doThrow ( SocketException . class ) . when ( stream ) . read ( Mockito . any ( byte [ ] . class ) , Mockito . anyInt ( ) , Mockito . anyInt ( ) ) ; Thread thread = new Thread ( m_SUT ) ; thread . start ( ) ; Thread . sleep ( 100 ) ; m_SUT . stopRun ( ) ; thread . join ( 5000 ) ; verify ( m_SysTimeWrapper , never ( ) ) . setSystemTime ( Mockito . anyLong ( ) ) ; }
Verify if no input received socket timeout occurs and the system time is never set.
Verify if no input received socket timeout occurs and the system time is never set .
//kick off runner //give thread time to run