edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testStartProcessingSerialPortPropsFail() throws FactoryException, IllegalArgumentException, 
        CCommException, PhysicalLinkException
    {
        when(m_CustomCommService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, m_PhysPort)).
            thenReturn(m_UUID);
        when(m_CustomCommService.requestPhysicalLink(m_UUID)).thenReturn(m_SerialPort);
        when(m_SerialPort.getName()).thenReturn(m_PhysPort);
        doThrow(FactoryException.class).when(m_SerialPort).setReadTimeout(1000);

        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if serial port fails to set read timeout.");
        }
        catch (final AssetException exception)
        {
            //expected exception
        }
        //verify cleanup
        verify(m_SerialPort).release();
        
        doThrow(IllegalArgumentException.class).when(m_SerialPort).setReadTimeout(1000);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if invalid read tiemout is passed to the serial port.");
        }
        catch (final AssetException exception)
        {
            //expected exception
        }
        //verify cleanup
        verify(m_SerialPort, times(2)).release();
        
        doThrow(PhysicalLinkException.class).when(m_SerialPort).setSerialPortProperties(m_BaudRate, 
                NovatelConstants.DEFAULT_NOVATEL_DATA_BITS, 
                NovatelConstants.DEFAULT_NOVATEL_PARITY, 
                NovatelConstants.DEFAULT_NOVATEL_STOP_BITS, 
                NovatelConstants.DEFAULT_NOVATEL_FLOW_CONTROL);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if serial port properties cannot be set.");
        }
        catch (final AssetException exception)
        {
            //expected exception
        }
        
        //verify cleanup
        verify(m_SerialPort, times(3)).release();
    }
/**
     * Verify the start processing method throws an asset exception if the custom comms service returns null for the 
     * serial port after being created. 
     */
Verify the start processing method throws an asset exception if the custom comms service returns null for the
serial port after being created.
Verify the start processing method throws an asset exception if the custom comms service returns null for the serial port after being created .
@Test
    public void testStartProcessingSerialPortPropsFail() throws FactoryException, IllegalArgumentException, 
        CCommException, PhysicalLinkException
    {
        when(m_CustomCommService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.SERIAL_PORT, m_PhysPort)).
            thenReturn(m_UUID);
        when(m_CustomCommService.requestPhysicalLink(m_UUID)).thenReturn(m_SerialPort);
        when(m_SerialPort.getName()).thenReturn(m_PhysPort);
        doThrow(FactoryException.class).when(m_SerialPort).setReadTimeout(1000);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if serial port fails to set read timeout.");
        }
        catch (final AssetException exception)
        {
        }
        verify(m_SerialPort).release();
        doThrow(IllegalArgumentException.class).when(m_SerialPort).setReadTimeout(1000);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if invalid read tiemout is passed to the serial port.");
        }
        catch (final AssetException exception)
        {
        }
        verify(m_SerialPort, times(2)).release();
        doThrow(PhysicalLinkException.class).when(m_SerialPort).setSerialPortProperties(m_BaudRate, 
                NovatelConstants.DEFAULT_NOVATEL_DATA_BITS, 
                NovatelConstants.DEFAULT_NOVATEL_PARITY, 
                NovatelConstants.DEFAULT_NOVATEL_STOP_BITS, 
                NovatelConstants.DEFAULT_NOVATEL_FLOW_CONTROL);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Should throw asset exception if serial port properties cannot be set.");
        }
        catch (final AssetException exception)
        {
        }
        verify(m_SerialPort, times(3)).release();
    }
@ Test public void testStartProcessingSerialPortPropsFail ( ) throws FactoryException , IllegalArgumentException , CCommException , PhysicalLinkException { when ( m_CustomCommService . tryCreatePhysicalLink ( PhysicalLinkTypeEnum . SERIAL_PORT , m_PhysPort ) ) . thenReturn ( m_UUID ) ; when ( m_CustomCommService . requestPhysicalLink ( m_UUID ) ) . thenReturn ( m_SerialPort ) ; when ( m_SerialPort . getName ( ) ) . thenReturn ( m_PhysPort ) ; doThrow ( FactoryException . class ) . when ( m_SerialPort ) . setReadTimeout ( 1000 ) ; try { m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; fail ( "Should throw asset exception if serial port fails to set read timeout." ) ; } catch ( final AssetException exception ) { } verify ( m_SerialPort ) . release ( ) ; doThrow ( IllegalArgumentException . class ) . when ( m_SerialPort ) . setReadTimeout ( 1000 ) ; try { m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; fail ( "Should throw asset exception if invalid read tiemout is passed to the serial port." ) ; } catch ( final AssetException exception ) { } verify ( m_SerialPort , times ( 2 ) ) . release ( ) ; doThrow ( PhysicalLinkException . class ) . when ( m_SerialPort ) . setSerialPortProperties ( m_BaudRate , NovatelConstants . DEFAULT_NOVATEL_DATA_BITS , NovatelConstants . DEFAULT_NOVATEL_PARITY , NovatelConstants . DEFAULT_NOVATEL_STOP_BITS , NovatelConstants . DEFAULT_NOVATEL_FLOW_CONTROL ) ; try { m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; fail ( "Should throw asset exception if serial port properties cannot be set." ) ; } catch ( final AssetException exception ) { } verify ( m_SerialPort , times ( 3 ) ) . release ( ) ; }
Verify the start processing method throws an asset exception if the custom comms service returns null for the
 serial port after being created.
Verify the start processing method throws an asset exception if the custom comms service returns null for the serial port after being created .
//expected exception //verify cleanup //expected exception //verify cleanup //expected exception //verify cleanup