mil.dod.th.ose.linux.serial/test/mil/dod/th/ose/linux/physical/TestSerialPortProxyImpl.java
@Test
    public void testSetProperties() throws PhysicalLinkException
    {   
        ArgumentCaptor<Long> actualCFlag = ArgumentCaptor.forClass(Long.class);
        ArgumentCaptor<Long> actualIFlag = ArgumentCaptor.forClass(Long.class);
        
        // set each port to the same setting so they can talk with each other
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 57600, 8, ParityEnum.NONE, StopBitsEnum.ONE_STOP_BIT, 
            FlowControlEnum.NONE, 0);
        
        m_SUT.open();
        
        PowerMockito.verifyStatic();
        int fd = 0;
        long c_iflag = 0;
        long c_oflag = 0;
        long c_cflag = B57600 | CLOCAL | CREAD | CS8; // CLOCAL and CREAD always apply
        long c_lflag = 0;
        // make sure waiting for at least one character
        short[] c_cc = new short[]{1, 0, 0, 0, 0}; 
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
        
        // reduce to 7 data bits and use 2 stop bits
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 9600, 7, ParityEnum.ODD, StopBitsEnum.TWO_STOP_BITS, 
            FlowControlEnum.XON_XOFF, 0);
        
        PowerMockito.verifyStatic(times(2));
        c_iflag = IXOFF | IXON;
        c_cflag = B9600 | CLOCAL | CREAD | CS7 | CSTOPB | PARODD | PARENB; // CLOCAL and CREAD always apply
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
        
        // reduce to 7 data bits and use 2 stop bits
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 9600, 8, ParityEnum.EVEN, StopBitsEnum.ONE_STOP_BIT, 
            FlowControlEnum.HARDWARE, 0);
        
        PowerMockito.verifyStatic(times(3));
        c_iflag = 0;
        c_cflag = B9600 | CLOCAL | CREAD | CS8 | PARENB | CRTSCTS; // CLOCAL and CREAD always apply
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
    }
/**
     * Verify ability to set properties, that the property flag values are sent to native call.
     */
Verify ability to set properties, that the property flag values are sent to native call.
Verify ability to set properties that the property flag values are sent to native call .
@Test
    public void testSetProperties() throws PhysicalLinkException
    {   
        ArgumentCaptor<Long> actualCFlag = ArgumentCaptor.forClass(Long.class);
        ArgumentCaptor<Long> actualIFlag = ArgumentCaptor.forClass(Long.class);
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 57600, 8, ParityEnum.NONE, StopBitsEnum.ONE_STOP_BIT, 
            FlowControlEnum.NONE, 0);
        m_SUT.open();
        PowerMockito.verifyStatic();
        int fd = 0;
        long c_iflag = 0;
        long c_oflag = 0;
        long c_cflag = B57600 | CLOCAL | CREAD | CS8; 
        long c_lflag = 0;
        short[] c_cc = new short[]{1, 0, 0, 0, 0}; 
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 9600, 7, ParityEnum.ODD, StopBitsEnum.TWO_STOP_BITS, 
            FlowControlEnum.XON_XOFF, 0);
        PowerMockito.verifyStatic(times(2));
        c_iflag = IXOFF | IXON;
        c_cflag = B9600 | CLOCAL | CREAD | CS7 | CSTOPB | PARODD | PARENB; 
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
        m_Context = mockProperties(m_SUT, PORT_A_NAME, 9600, 8, ParityEnum.EVEN, StopBitsEnum.ONE_STOP_BIT, 
            FlowControlEnum.HARDWARE, 0);
        PowerMockito.verifyStatic(times(3));
        c_iflag = 0;
        c_cflag = B9600 | CLOCAL | CREAD | CS8 | PARENB | CRTSCTS; 
        TerminalIO.tcSetAttr(eq(fd), actualIFlag.capture(), eq(c_oflag), actualCFlag.capture(), eq(c_lflag), eq(c_cc));
        assertThat(actualCFlag.getValue(), is(c_cflag));
        assertThat(actualIFlag.getValue(), is(c_iflag));
    }
@ Test public void testSetProperties ( ) throws PhysicalLinkException { ArgumentCaptor < Long > actualCFlag = ArgumentCaptor . forClass ( Long . class ) ; ArgumentCaptor < Long > actualIFlag = ArgumentCaptor . forClass ( Long . class ) ; m_Context = mockProperties ( m_SUT , PORT_A_NAME , 57600 , 8 , ParityEnum . NONE , StopBitsEnum . ONE_STOP_BIT , FlowControlEnum . NONE , 0 ) ; m_SUT . open ( ) ; PowerMockito . verifyStatic ( ) ; int fd = 0 ; long c_iflag = 0 ; long c_oflag = 0 ; long c_cflag = B57600 | CLOCAL | CREAD | CS8 ; long c_lflag = 0 ; short [ ] c_cc = new short [ ] { 1 , 0 , 0 , 0 , 0 } ; TerminalIO . tcSetAttr ( eq ( fd ) , actualIFlag . capture ( ) , eq ( c_oflag ) , actualCFlag . capture ( ) , eq ( c_lflag ) , eq ( c_cc ) ) ; assertThat ( actualCFlag . getValue ( ) , is ( c_cflag ) ) ; assertThat ( actualIFlag . getValue ( ) , is ( c_iflag ) ) ; m_Context = mockProperties ( m_SUT , PORT_A_NAME , 9600 , 7 , ParityEnum . ODD , StopBitsEnum . TWO_STOP_BITS , FlowControlEnum . XON_XOFF , 0 ) ; PowerMockito . verifyStatic ( times ( 2 ) ) ; c_iflag = IXOFF | IXON ; c_cflag = B9600 | CLOCAL | CREAD | CS7 | CSTOPB | PARODD | PARENB ; TerminalIO . tcSetAttr ( eq ( fd ) , actualIFlag . capture ( ) , eq ( c_oflag ) , actualCFlag . capture ( ) , eq ( c_lflag ) , eq ( c_cc ) ) ; assertThat ( actualCFlag . getValue ( ) , is ( c_cflag ) ) ; assertThat ( actualIFlag . getValue ( ) , is ( c_iflag ) ) ; m_Context = mockProperties ( m_SUT , PORT_A_NAME , 9600 , 8 , ParityEnum . EVEN , StopBitsEnum . ONE_STOP_BIT , FlowControlEnum . HARDWARE , 0 ) ; PowerMockito . verifyStatic ( times ( 3 ) ) ; c_iflag = 0 ; c_cflag = B9600 | CLOCAL | CREAD | CS8 | PARENB | CRTSCTS ; TerminalIO . tcSetAttr ( eq ( fd ) , actualIFlag . capture ( ) , eq ( c_oflag ) , actualCFlag . capture ( ) , eq ( c_lflag ) , eq ( c_cc ) ) ; assertThat ( actualCFlag . getValue ( ) , is ( c_cflag ) ) ; assertThat ( actualIFlag . getValue ( ) , is ( c_iflag ) ) ; }
Verify ability to set properties, that the property flag values are sent to native call.
Verify ability to set properties that the property flag values are sent to native call .
// set each port to the same setting so they can talk with each other // CLOCAL and CREAD always apply // make sure waiting for at least one character // reduce to 7 data bits and use 2 stop bits // CLOCAL and CREAD always apply // reduce to 7 data bits and use 2 stop bits // CLOCAL and CREAD always apply