mil.dod.th.ose.time.service/test/mil/dod/th/ose/time/service/TestTimeChangeServiceThread.java
@Test
    public void testRun() throws IOException, InterruptedException
    {
        Socket client = mock(Socket.class);
        when(m_ServerSocket.accept()).thenReturn(client);
        
        long time = System.currentTimeMillis();
        
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(time);
        
        InputStream stream = new ByteArrayInputStream(buffer.array());
        when(client.getInputStream()).thenReturn(stream);
        
        //kick off runner
        Thread thread = new Thread(m_SUT);
        thread.start();
        
        //give thread time to run
        ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
        verify(m_SysTimeWrapper, timeout(1000)).setSystemTime(captor.capture());
        
        m_SUT.stopRun();
        thread.join(5000);
        
        verify(client, atLeast(1)).setSoTimeout(eq(10000));
        
        assertThat(captor.getValue().longValue(), is(time));
    }
/**
     * Verify that thread can be successfully run and a call to set the system time 
     * is made.
     */
Verify that thread can be successfully run and a call to set the system time
is made.
Verify that thread can be successfully run and a call to set the system time is made .
@Test
    public void testRun() throws IOException, InterruptedException
    {
        Socket client = mock(Socket.class);
        when(m_ServerSocket.accept()).thenReturn(client);
        long time = System.currentTimeMillis();
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(time);
        InputStream stream = new ByteArrayInputStream(buffer.array());
        when(client.getInputStream()).thenReturn(stream);
        Thread thread = new Thread(m_SUT);
        thread.start();
        ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
        verify(m_SysTimeWrapper, timeout(1000)).setSystemTime(captor.capture());
        m_SUT.stopRun();
        thread.join(5000);
        verify(client, atLeast(1)).setSoTimeout(eq(10000));
        assertThat(captor.getValue().longValue(), is(time));
    }
@ Test public void testRun ( ) throws IOException , InterruptedException { Socket client = mock ( Socket . class ) ; when ( m_ServerSocket . accept ( ) ) . thenReturn ( client ) ; long time = System . currentTimeMillis ( ) ; ByteBuffer buffer = ByteBuffer . allocate ( 8 ) ; buffer . putLong ( time ) ; InputStream stream = new ByteArrayInputStream ( buffer . array ( ) ) ; when ( client . getInputStream ( ) ) . thenReturn ( stream ) ; Thread thread = new Thread ( m_SUT ) ; thread . start ( ) ; ArgumentCaptor < Long > captor = ArgumentCaptor . forClass ( Long . class ) ; verify ( m_SysTimeWrapper , timeout ( 1000 ) ) . setSystemTime ( captor . capture ( ) ) ; m_SUT . stopRun ( ) ; thread . join ( 5000 ) ; verify ( client , atLeast ( 1 ) ) . setSoTimeout ( eq ( 10000 ) ) ; assertThat ( captor . getValue ( ) . longValue ( ) , is ( time ) ) ; }
Verify that thread can be successfully run and a call to set the system time
 is made.
Verify that thread can be successfully run and a call to set the system time is made .
//kick off runner //give thread time to run