edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testStopProcessingCloseIOException() throws IllegalArgumentException, CCommException, 
        PhysicalLinkException, AssetException
    {
        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);
        
        //need to call start processing to set up serial port and read thread
        m_SUT.startProcessing(m_PhysPort, m_BaudRate);
        when(m_SerialPort.isOpen()).thenReturn(true);
        
        //exception from serial port
        doThrow(new PhysicalLinkException("exception")).when(m_SerialPort).close();
        m_SUT.stopProcessing();
        
        //verify release still called
        verify(m_SerialPort).release();
    }
/**
     * Verify error handling if IOException is thrown during close.
     */
Verify error handling if IOException is thrown during close.
Verify error handling if IOException is thrown during close .
@Test
    public void testStopProcessingCloseIOException() throws IllegalArgumentException, CCommException, 
        PhysicalLinkException, AssetException
    {
        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);
        doThrow(new PhysicalLinkException("exception")).when(m_SerialPort).close();
        m_SUT.stopProcessing();
        verify(m_SerialPort).release();
    }
@ Test public void testStopProcessingCloseIOException ( ) throws IllegalArgumentException , CCommException , PhysicalLinkException , AssetException { 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 ) ; doThrow ( new PhysicalLinkException ( "exception" ) ) . when ( m_SerialPort ) . close ( ) ; m_SUT . stopProcessing ( ) ; verify ( m_SerialPort ) . release ( ) ; }
Verify error handling if IOException is thrown during close.
Verify error handling if IOException is thrown during close .
//need to call start processing to set up serial port and read thread //exception from serial port //verify release still called