edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testStartProcessingFailStartAgain() 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);
        
        //simulating a working port
        when(m_SerialPort.isOpen()).thenReturn(true);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Expected exception because the port is already connected,");
        }
        catch (final IllegalStateException exception)
        {
            //expected exception
        }
    }
/**
     * Verify that the start processing method throws an illegal state if start has already been called.
     */
Verify that the start processing method throws an illegal state if start has already been called.
Verify that the start processing method throws an illegal state if start has already been called .
@Test
    public void testStartProcessingFailStartAgain() 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);
        try
        {
            m_SUT.startProcessing(m_PhysPort, m_BaudRate);
            fail("Expected exception because the port is already connected,");
        }
        catch (final IllegalStateException exception)
        {
        }
    }
@ Test public void testStartProcessingFailStartAgain ( ) 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 ) ; try { m_SUT . startProcessing ( m_PhysPort , m_BaudRate ) ; fail ( "Expected exception because the port is already connected," ) ; } catch ( final IllegalStateException exception ) { } }
Verify that the start processing method throws an illegal state if start has already been called.
Verify that the start processing method throws an illegal state if start has already been called .
//simulating a working port //expected exception