edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/impl/connection/TestNovatelConnectionMgrImpl.java
@Test
    public void testStartProcessingFailStopAgain() 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);
        
        m_SUT.stopProcessing();

        try
        {
            m_SUT.stopProcessing();
            fail("Expected exception because the connection is already stopped,");
        }
        catch (final IllegalStateException exception)
        {
            //expected exception
        }
    }
/**
     * Verify that the stop processing method throws an illegal state if start has already been called.
     */
Verify that the stop processing method throws an illegal state if start has already been called.
Verify that the stop processing method throws an illegal state if start has already been called .
@Test
    public void testStartProcessingFailStopAgain() 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);
        m_SUT.stopProcessing();
        try
        {
            m_SUT.stopProcessing();
            fail("Expected exception because the connection is already stopped,");
        }
        catch (final IllegalStateException exception)
        {
        }
    }
@ Test public void testStartProcessingFailStopAgain ( ) 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 ) ; m_SUT . stopProcessing ( ) ; try { m_SUT . stopProcessing ( ) ; fail ( "Expected exception because the connection is already stopped," ) ; } catch ( final IllegalStateException exception ) { } }
Verify that the stop processing method throws an illegal state if start has already been called.
Verify that the stop processing method throws an illegal state if start has already been called .
//simulating a working port //expected exception