mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/physical/TestSerialPortImpl.java
@Test
    public void testSetPropertySetPropError() throws Exception
    {
        m_ConfigurationAdmin = mock(ConfigurationAdmin.class);
        
        //reset up
        String pid = "pid";
        m_SUT.initialize(m_FactReg, m_SerialProxy, m_PhysicalLinkFactoryInternal, m_ConfigurationAdmin, m_EventAdmin, 
                m_PowManInternal, m_Uuid, m_Name, pid, m_BaseType);
        
        Configuration config = mock(Configuration.class);
        when(config.getProperties()).thenReturn(new Hashtable<String, Object>());
        when(m_ConfigurationAdmin.listConfigurations(anyString()))
            .thenReturn(new Configuration[] {config})
            .thenThrow(new IOException("Exception"));
        
        try
        {
            m_SUT.setSerialPortProperties(115200, 7, ParityEnum.EVEN, StopBitsEnum.TWO_STOP_BITS, 
                    FlowControlEnum.XON_XOFF);
            fail("Expecting Exception, because the configuration will throw exception.");
        }
        catch (PhysicalLinkException e)
        {
            //expecting exception
        }
    }
/**
     * Verify physical link exception if set properties fails.
     */
Verify physical link exception if set properties fails.
Verify physical link exception if set properties fails .
@Test
    public void testSetPropertySetPropError() throws Exception
    {
        m_ConfigurationAdmin = mock(ConfigurationAdmin.class);
        String pid = "pid";
        m_SUT.initialize(m_FactReg, m_SerialProxy, m_PhysicalLinkFactoryInternal, m_ConfigurationAdmin, m_EventAdmin, 
                m_PowManInternal, m_Uuid, m_Name, pid, m_BaseType);
        Configuration config = mock(Configuration.class);
        when(config.getProperties()).thenReturn(new Hashtable<String, Object>());
        when(m_ConfigurationAdmin.listConfigurations(anyString()))
            .thenReturn(new Configuration[] {config})
            .thenThrow(new IOException("Exception"));
        try
        {
            m_SUT.setSerialPortProperties(115200, 7, ParityEnum.EVEN, StopBitsEnum.TWO_STOP_BITS, 
                    FlowControlEnum.XON_XOFF);
            fail("Expecting Exception, because the configuration will throw exception.");
        }
        catch (PhysicalLinkException e)
        {
        }
    }
@ Test public void testSetPropertySetPropError ( ) throws Exception { m_ConfigurationAdmin = mock ( ConfigurationAdmin . class ) ; String pid = "pid" ; m_SUT . initialize ( m_FactReg , m_SerialProxy , m_PhysicalLinkFactoryInternal , m_ConfigurationAdmin , m_EventAdmin , m_PowManInternal , m_Uuid , m_Name , pid , m_BaseType ) ; Configuration config = mock ( Configuration . class ) ; when ( config . getProperties ( ) ) . thenReturn ( new Hashtable < String , Object > ( ) ) ; when ( m_ConfigurationAdmin . listConfigurations ( anyString ( ) ) ) . thenReturn ( new Configuration [ ] { config } ) . thenThrow ( new IOException ( "Exception" ) ) ; try { m_SUT . setSerialPortProperties ( 115200 , 7 , ParityEnum . EVEN , StopBitsEnum . TWO_STOP_BITS , FlowControlEnum . XON_XOFF ) ; fail ( "Expecting Exception, because the configuration will throw exception." ) ; } catch ( PhysicalLinkException e ) { } }
Verify physical link exception if set properties fails.
Verify physical link exception if set properties fails .
//reset up //expecting exception