mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestAbstractFactoryObject.java
@SuppressWarnings("unchecked")
    @Test (timeout = 2000) //timeout to be sure that the first call exits, and the second can proceed
    public void testLatchCountdownException() throws ConfigurationException, IllegalArgumentException, 
        IllegalStateException, FactoryException, IOException
    {
        doThrow(new ConfigurationException("", "")).when(m_FactoryProxy).updated(Mockito.anyMap());
        
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("key", "value");
        //try to set the property, and exception should be thrown
        try
        {
            m_SUT.setProperties(props);
            fail("expecting property to fail");
        }
        catch (Exception e)
        {
            //exception expected
        }
        
        //make the call again, this verifies that the latch is released, otherwise this call would fail
        try
        {
            m_SUT.setProperties(props);
            fail("expecting property to fail");
        }
        catch (Exception e)
        {
            //exception expected
        }
        
        //Test will fail if lock is not released as the set properties call will timeout later than this test
        //will timeout. Thus by the test not timing out we are proving that the release is in fact happening and
        //the set properties method is returning out.
    }
/**
     * Verify latch is released even if an exception occurs during an objects update.
     */
Verify latch is released even if an exception occurs during an objects update.
Verify latch is released even if an exception occurs during an objects update .
@SuppressWarnings("unchecked")
    @Test (timeout = 2000) 
    public void testLatchCountdownException() throws ConfigurationException, IllegalArgumentException, 
        IllegalStateException, FactoryException, IOException
    {
        doThrow(new ConfigurationException("", "")).when(m_FactoryProxy).updated(Mockito.anyMap());
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("key", "value");
        try
        {
            m_SUT.setProperties(props);
            fail("expecting property to fail");
        }
        catch (Exception e)
        {
        }
        try
        {
            m_SUT.setProperties(props);
            fail("expecting property to fail");
        }
        catch (Exception e)
        {
        }
    }
@ SuppressWarnings ( "unchecked" ) @ Test ( timeout = 2000 ) public void testLatchCountdownException ( ) throws ConfigurationException , IllegalArgumentException , IllegalStateException , FactoryException , IOException { doThrow ( new ConfigurationException ( "" , "" ) ) . when ( m_FactoryProxy ) . updated ( Mockito . anyMap ( ) ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( "key" , "value" ) ; try { m_SUT . setProperties ( props ) ; fail ( "expecting property to fail" ) ; } catch ( Exception e ) { } try { m_SUT . setProperties ( props ) ; fail ( "expecting property to fail" ) ; } catch ( Exception e ) { } }
Verify latch is released even if an exception occurs during an objects update.
Verify latch is released even if an exception occurs during an objects update .
//timeout to be sure that the first call exits, and the second can proceed //try to set the property, and exception should be thrown //exception expected //make the call again, this verifies that the latch is released, otherwise this call would fail //exception expected //Test will fail if lock is not released as the set properties call will timeout later than this test //will timeout. Thus by the test not timing out we are proving that the release is in fact happening and //the set properties method is returning out.