edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testStartProcessingFailOpenSerial() throws IllegalArgumentException, CCommException, 
        PhysicalLinkException, IllegalStateException, FactoryException
    {
        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);
        
        //Verify that handling of the open method if it throws an exception.
        doThrow(PhysicalLinkException.class).when(m_SerialPort).open();
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Serial port open method should throw a physical link exception that will be caught and wrapped in an" 
                    + " asset exception.");
        }
        catch (final AssetException exception)
        {
            //expected exception
        }
        verify(m_SerialPort).close();
        verify(m_SerialPort).release();
        
        //Verify that handling of the set property method if it throws an exception.
        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("Seral port set property method should throw a factory exception that will be caught and wrapped in an"
                    + " asset exception.");
        }
        catch (final AssetException exception)
        {
            //expected exception
        }
        verify(m_SerialPort, times(2)).release();
    }
/**
     * Verify the start processing method throws an asset exception if the serial port fails to open or to be able
     * to set the baud rate.
     */
Verify the start processing method throws an asset exception if the serial port fails to open or to be able
to set the baud rate.
Verify the start processing method throws an asset exception if the serial port fails to open or to be able to set the baud rate .
@Test
    public void testStartProcessingFailOpenSerial() throws IllegalArgumentException, CCommException, 
        PhysicalLinkException, IllegalStateException, FactoryException
    {
        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(PhysicalLinkException.class).when(m_SerialPort).open();
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Serial port open method should throw a physical link exception that will be caught and wrapped in an" 
                    + " asset exception.");
        }
        catch (final AssetException exception)
        {
        }
        verify(m_SerialPort).close();
        verify(m_SerialPort).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("Seral port set property method should throw a factory exception that will be caught and wrapped in an"
                    + " asset exception.");
        }
        catch (final AssetException exception)
        {
        }
        verify(m_SerialPort, times(2)).release();
    }
@ Test public void testStartProcessingFailOpenSerial ( ) throws IllegalArgumentException , CCommException , PhysicalLinkException , IllegalStateException , FactoryException { 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 ( PhysicalLinkException . class ) . when ( m_SerialPort ) . open ( ) ; try { m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; fail ( "Serial port open method should throw a physical link exception that will be caught and wrapped in an" + " asset exception." ) ; } catch ( final AssetException exception ) { } verify ( m_SerialPort ) . close ( ) ; verify ( m_SerialPort ) . 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 ( "Seral port set property method should throw a factory exception that will be caught and wrapped in an" + " asset exception." ) ; } catch ( final AssetException exception ) { } verify ( m_SerialPort , times ( 2 ) ) . release ( ) ; }
Verify the start processing method throws an asset exception if the serial port fails to open or to be able
 to set the baud rate.
Verify the start processing method throws an asset exception if the serial port fails to open or to be able to set the baud rate .
//Verify that handling of the open method if it throws an exception. //expected exception //Verify that handling of the set property method if it throws an exception. //expected exception