mil.dod.th.ose.linux.serial/test/mil/dod/th/ose/linux/physical/TestSerialPortInputStream.java
@Test
    public void testReadBytes() throws IOException, FactoryException
    {
        when(FileOperations.readBuffer(eq(5), Mockito.any(byte[].class), eq(3), eq(10L), eq(0)))
            .thenAnswer(new Answer<Integer>()
            {
                @Override
                public Integer answer(InvocationOnMock invocation) throws Throwable
                {
                    byte[] buf = (byte[])invocation.getArguments()[1];
                    buf[0] = (byte)0xde;
                    buf[1] = (byte)0xad;
                    buf[2] = (byte)0xbe;
                    buf[3] = (byte)0xef;
                    return 5;
                }
            });
        
        byte[] buf = new byte[10];
        int bytesRead = m_SUT.read(buf, 3, 10);
        assertThat(bytesRead, is(5));
        assertThat(buf[0], is((byte)0xde));
        assertThat(buf[1], is((byte)0xad));
        assertThat(buf[2], is((byte)0xbe));
        assertThat(buf[3], is((byte)0xef));
    }
/**
     * Verify read buffer returns the buffer from {@link FileOperations}.
     */
Verify read buffer returns the buffer from  FileOperations.
Verify read buffer returns the buffer from FileOperations .
@Test
    public void testReadBytes() throws IOException, FactoryException
    {
        when(FileOperations.readBuffer(eq(5), Mockito.any(byte[].class), eq(3), eq(10L), eq(0)))
            .thenAnswer(new Answer<Integer>()
            {
                @Override
                public Integer answer(InvocationOnMock invocation) throws Throwable
                {
                    byte[] buf = (byte[])invocation.getArguments()[1];
                    buf[0] = (byte)0xde;
                    buf[1] = (byte)0xad;
                    buf[2] = (byte)0xbe;
                    buf[3] = (byte)0xef;
                    return 5;
                }
            });
        byte[] buf = new byte[10];
        int bytesRead = m_SUT.read(buf, 3, 10);
        assertThat(bytesRead, is(5));
        assertThat(buf[0], is((byte)0xde));
        assertThat(buf[1], is((byte)0xad));
        assertThat(buf[2], is((byte)0xbe));
        assertThat(buf[3], is((byte)0xef));
    }
@ Test public void testReadBytes ( ) throws IOException , FactoryException { when ( FileOperations . readBuffer ( eq ( 5 ) , Mockito . any ( byte [ ] . class ) , eq ( 3 ) , eq ( 10L ) , eq ( 0 ) ) ) . thenAnswer ( new Answer < Integer > ( ) { @ Override public Integer answer ( InvocationOnMock invocation ) throws Throwable { byte [ ] buf = ( byte [ ] ) invocation . getArguments ( ) [ 1 ] ; buf [ 0 ] = ( byte ) 0xde ; buf [ 1 ] = ( byte ) 0xad ; buf [ 2 ] = ( byte ) 0xbe ; buf [ 3 ] = ( byte ) 0xef ; return 5 ; } } ) ; byte [ ] buf = new byte [ 10 ] ; int bytesRead = m_SUT . read ( buf , 3 , 10 ) ; assertThat ( bytesRead , is ( 5 ) ) ; assertThat ( buf [ 0 ] , is ( ( byte ) 0xde ) ) ; assertThat ( buf [ 1 ] , is ( ( byte ) 0xad ) ) ; assertThat ( buf [ 2 ] , is ( ( byte ) 0xbe ) ) ; assertThat ( buf [ 3 ] , is ( ( byte ) 0xef ) ) ; }
Verify read buffer returns the buffer from {@link FileOperations}.
Verify read buffer returns the buffer from { @link FileOperations } .