mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestOSGiConfigLoaderImpl.java
@Test
    @SuppressWarnings("unchecked")
    public void testProcessFactoryIOException() throws IOException
    {
        when(m_ConfigAdmin.createFactoryConfiguration(FACTORY_CONFIG_PID, null)).thenThrow(IOException.class);
        
        final List<PidConfig> configs = createConfigList();
        
        m_SUT.process(configs, true);
        
        @SuppressWarnings("rawtypes")
        final ArgumentCaptor<Dictionary> propsCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ConfigOverride).update(propsCaptor.capture());
        verify(m_ConfigNoOverride).update(propsCaptor.capture());
        verify(m_FactoryConfig, never()).update(propsCaptor.capture());
        
        Dictionary<String, Object> propList = propsCaptor.getAllValues().get(0);
        assertThat(propList.get("someInt"), is((Object)10));
        assertThat(propList.get("someString"), is((Object)"value"));
        assertThat(propList.get("someShort"), is((Object)(short)89));
        
        propList = propsCaptor.getAllValues().get(1);
        assertThat(propList.get("someFloat"), is((Object)12.5F));
        assertThat(propList.get("someByte"), is((Object)(byte)127));
        assertThat(propList.get("someChar"), is((Object)'A'));
        
        verify(m_Logging).error(Mockito.any(IOException.class), eq("An error occurred trying to create factory "
                + "configuration from factory with PID: %s"), eq(FACTORY_CONFIG_PID));
    }
/**
     * Verify that an IOException is handled appropriately when thrown while trying to create a factory configuration.
     */
Verify that an IOException is handled appropriately when thrown while trying to create a factory configuration.
Verify that an IOException is handled appropriately when thrown while trying to create a factory configuration .
@Test
    @SuppressWarnings("unchecked")
    public void testProcessFactoryIOException() throws IOException
    {
        when(m_ConfigAdmin.createFactoryConfiguration(FACTORY_CONFIG_PID, null)).thenThrow(IOException.class);
        final List<PidConfig> configs = createConfigList();
        m_SUT.process(configs, true);
        @SuppressWarnings("rawtypes")
        final ArgumentCaptor<Dictionary> propsCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_ConfigOverride).update(propsCaptor.capture());
        verify(m_ConfigNoOverride).update(propsCaptor.capture());
        verify(m_FactoryConfig, never()).update(propsCaptor.capture());
        Dictionary<String, Object> propList = propsCaptor.getAllValues().get(0);
        assertThat(propList.get("someInt"), is((Object)10));
        assertThat(propList.get("someString"), is((Object)"value"));
        assertThat(propList.get("someShort"), is((Object)(short)89));
        propList = propsCaptor.getAllValues().get(1);
        assertThat(propList.get("someFloat"), is((Object)12.5F));
        assertThat(propList.get("someByte"), is((Object)(byte)127));
        assertThat(propList.get("someChar"), is((Object)'A'));
        verify(m_Logging).error(Mockito.any(IOException.class), eq("An error occurred trying to create factory "
                + "configuration from factory with PID: %s"), eq(FACTORY_CONFIG_PID));
    }
@ Test @ SuppressWarnings ( "unchecked" ) public void testProcessFactoryIOException ( ) throws IOException { when ( m_ConfigAdmin . createFactoryConfiguration ( FACTORY_CONFIG_PID , null ) ) . thenThrow ( IOException . class ) ; final List < PidConfig > configs = createConfigList ( ) ; m_SUT . process ( configs , true ) ; @ SuppressWarnings ( "rawtypes" ) final ArgumentCaptor < Dictionary > propsCaptor = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_ConfigOverride ) . update ( propsCaptor . capture ( ) ) ; verify ( m_ConfigNoOverride ) . update ( propsCaptor . capture ( ) ) ; verify ( m_FactoryConfig , never ( ) ) . update ( propsCaptor . capture ( ) ) ; Dictionary < String , Object > propList = propsCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( propList . get ( "someInt" ) , is ( ( Object ) 10 ) ) ; assertThat ( propList . get ( "someString" ) , is ( ( Object ) "value" ) ) ; assertThat ( propList . get ( "someShort" ) , is ( ( Object ) ( short ) 89 ) ) ; propList = propsCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( propList . get ( "someFloat" ) , is ( ( Object ) 12.5F ) ) ; assertThat ( propList . get ( "someByte" ) , is ( ( Object ) ( byte ) 127 ) ) ; assertThat ( propList . get ( "someChar" ) , is ( ( Object ) 'A' ) ) ; verify ( m_Logging ) . error ( Mockito . any ( IOException . class ) , eq ( "An error occurred trying to create factory " + "configuration from factory with PID: %s" ) , eq ( FACTORY_CONFIG_PID ) ) ; }
Verify that an IOException is handled appropriately when thrown while trying to create a factory configuration.
Verify that an IOException is handled appropriately when thrown while trying to create a factory configuration .