edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testReconnect() throws IllegalArgumentException, CCommException, AssetException, 
        PhysicalLinkException, IOException
    {
        //Not activated therefore should return false.
        assertThat(m_SUT.isProcessing(), is(false));
        
        when(m_CustomCommService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, m_PhysPort)).
            thenReturn(m_UUID);
        when(m_CustomCommService.requestPhysicalLink(m_UUID)).thenReturn(m_SerialPort);
        when(m_SerialPort.getInputStream()).thenReturn(mock(InputStream.class));
        when(m_SerialPort.getName()).thenReturn(m_PhysPort);
        m_SUT.startProcessing(m_PhysPort, m_BaudRate);
        
        //report it as open so that close is called
        when(m_SerialPort.isOpen()).thenReturn(true);
        
        //reconnect should close the serial port
        m_SUT.reconnect();
        verify(m_SerialPort).close();
        verify(m_SerialPort).release();
    }
/**
     * Test the reconnect method with open port, verify it is closed and released.
     */
Test the reconnect method with open port, verify it is closed and released.
Test the reconnect method with open port verify it is closed and released .
@Test
    public void testReconnect() throws IllegalArgumentException, CCommException, AssetException, 
        PhysicalLinkException, IOException
    {
        assertThat(m_SUT.isProcessing(), is(false));
        when(m_CustomCommService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, m_PhysPort)).
            thenReturn(m_UUID);
        when(m_CustomCommService.requestPhysicalLink(m_UUID)).thenReturn(m_SerialPort);
        when(m_SerialPort.getInputStream()).thenReturn(mock(InputStream.class));
        when(m_SerialPort.getName()).thenReturn(m_PhysPort);
        m_SUT.startProcessing(m_PhysPort, m_BaudRate);
        when(m_SerialPort.isOpen()).thenReturn(true);
        m_SUT.reconnect();
        verify(m_SerialPort).close();
        verify(m_SerialPort).release();
    }
@ Test public void testReconnect ( ) throws IllegalArgumentException , CCommException , AssetException , PhysicalLinkException , IOException { assertThat ( m_SUT . isProcessing ( ) , is ( false ) ) ; when ( m_CustomCommService . tryCreatePhysicalLink ( PhysicalLinkTypeEnum . SERIAL_PORT , m_PhysPort ) ) . thenReturn ( m_UUID ) ; when ( m_CustomCommService . requestPhysicalLink ( m_UUID ) ) . thenReturn ( m_SerialPort ) ; when ( m_SerialPort . getInputStream ( ) ) . thenReturn ( mock ( InputStream . class ) ) ; when ( m_SerialPort . getName ( ) ) . thenReturn ( m_PhysPort ) ; m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; when ( m_SerialPort . isOpen ( ) ) . thenReturn ( true ) ; m_SUT . reconnect ( ) ; verify ( m_SerialPort ) . close ( ) ; verify ( m_SerialPort ) . release ( ) ; }
Test the reconnect method with open port, verify it is closed and released.
Test the reconnect method with open port verify it is closed and released .
//Not activated therefore should return false. //report it as open so that close is called //reconnect should close the serial port