mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestConfigurationMgr.java
@SuppressWarnings({"rawtypes", "unchecked"})
    @Test
    public void testFrameworkEventStarted_ConfigsProcessed() throws UnmarshalException, IOException
    {
        when(m_ConfigAdmin.getConfiguration(ConfigurationMgr.class.getName())).thenReturn(m_OSGiConfiguration);
        when(m_OSGiConfiguration.getProperties()).thenReturn(null);
        
        List<FactoryObjectConfig> fConfigs = new ArrayList<>();
        FactoryObjectConfig config = mock(FactoryObjectConfig.class);
        fConfigs.add(config);
        
        List<PidConfig> pConfigs = new ArrayList<>();
        PidConfig pconfig = mock(PidConfig.class);
        pConfigs.add(pconfig);
        
        List<AddressConfig> aConfigs = new ArrayList<>();
        AddressConfig aconfig = mock(AddressConfig.class);
        aConfigs.add(aconfig);
        
        List<EventConfig> eConfigs = new ArrayList<>();
        EventConfig eConfig = mock(EventConfig.class);
        eConfigs.add(eConfig);
        
        List<SocketChannelConfig> sConfigs = new ArrayList<>();
        SocketChannelConfig sConfig = mock(SocketChannelConfig.class);
        sConfigs.add(sConfig);
        
        List<TransportChannelConfig> tConfigs = new ArrayList<>();
        TransportChannelConfig tConfig = mock(TransportChannelConfig.class);
        tConfigs.add(tConfig);
        
        when(m_XmlConfiguration.getFactoryObjects()).thenReturn(fConfigs);
        when(m_XmlConfiguration.getOsgiConfigs()).thenReturn(pConfigs);
        when(m_XmlConfiguration.getAddresses()).thenReturn(aConfigs);
        when(m_XmlConfiguration.getEventRegs()).thenReturn(eConfigs);
        when(m_XmlConfiguration.getSocketChannels()).thenReturn(sConfigs);
        when(m_XmlConfiguration.getTransportChannels()).thenReturn(tConfigs);
        
        m_SUT.activate(m_BundleContext);
        
        ArgumentCaptor<List> fCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_FactoryObjLoader).process(fCaptor.capture(), eq(true));
        
        assertThat(fCaptor.getValue().size(), is(1));
        assertThat((FactoryObjectConfig)fCaptor.getValue().get(0), is(config));
        
        ArgumentCaptor<List> pCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_OsgiConfigLoader).process(pCaptor.capture(), eq(true));
        
        assertThat(pCaptor.getValue().size(), is(1));
        assertThat((PidConfig)pCaptor.getValue().get(0), is(pconfig));
        
        ArgumentCaptor<List> aCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_AddrConfigLoader).process(aCaptor.capture(), eq(true));
        
        assertThat(aCaptor.getValue().size(), is(1));
        assertThat((AddressConfig)aCaptor.getValue().get(0), is(aconfig));
        
        ArgumentCaptor<List> eCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_EventConfigLoader).process(eCaptor.capture());
        assertThat(eCaptor.getValue().size(), is(1));
        assertThat((EventConfig)eCaptor.getValue().get(0), is(eConfig));
        
        ArgumentCaptor<List> sCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processSocketChannels(sCaptor.capture());
        assertThat(sCaptor.getValue().size(), is(1));
        assertThat((SocketChannelConfig)sCaptor.getValue().get(0), is(sConfig));
        
        ArgumentCaptor<List> tCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processTransportChannels(tCaptor.capture());
        assertThat(tCaptor.getValue().size(), is(1));
        assertThat((TransportChannelConfig)tCaptor.getValue().get(0), is(tConfig));

        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin,
            ConfigLoadingConstants.TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT);
    }
/**
     * Verify that the framework started event is handled properly and configurations are processed when a configs.xml
     * file is found during activation.
     */
Verify that the framework started event is handled properly and configurations are processed when a configs.xml
file is found during activation.
Verify that the framework started event is handled properly and configurations are processed when a configs . xml file is found during activation .
@SuppressWarnings({"rawtypes", "unchecked"})
    @Test
    public void testFrameworkEventStarted_ConfigsProcessed() throws UnmarshalException, IOException
    {
        when(m_ConfigAdmin.getConfiguration(ConfigurationMgr.class.getName())).thenReturn(m_OSGiConfiguration);
        when(m_OSGiConfiguration.getProperties()).thenReturn(null);
        List<FactoryObjectConfig> fConfigs = new ArrayList<>();
        FactoryObjectConfig config = mock(FactoryObjectConfig.class);
        fConfigs.add(config);
        List<PidConfig> pConfigs = new ArrayList<>();
        PidConfig pconfig = mock(PidConfig.class);
        pConfigs.add(pconfig);
        List<AddressConfig> aConfigs = new ArrayList<>();
        AddressConfig aconfig = mock(AddressConfig.class);
        aConfigs.add(aconfig);
        List<EventConfig> eConfigs = new ArrayList<>();
        EventConfig eConfig = mock(EventConfig.class);
        eConfigs.add(eConfig);
        List<SocketChannelConfig> sConfigs = new ArrayList<>();
        SocketChannelConfig sConfig = mock(SocketChannelConfig.class);
        sConfigs.add(sConfig);
        List<TransportChannelConfig> tConfigs = new ArrayList<>();
        TransportChannelConfig tConfig = mock(TransportChannelConfig.class);
        tConfigs.add(tConfig);
        when(m_XmlConfiguration.getFactoryObjects()).thenReturn(fConfigs);
        when(m_XmlConfiguration.getOsgiConfigs()).thenReturn(pConfigs);
        when(m_XmlConfiguration.getAddresses()).thenReturn(aConfigs);
        when(m_XmlConfiguration.getEventRegs()).thenReturn(eConfigs);
        when(m_XmlConfiguration.getSocketChannels()).thenReturn(sConfigs);
        when(m_XmlConfiguration.getTransportChannels()).thenReturn(tConfigs);
        m_SUT.activate(m_BundleContext);
        ArgumentCaptor<List> fCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_FactoryObjLoader).process(fCaptor.capture(), eq(true));
        assertThat(fCaptor.getValue().size(), is(1));
        assertThat((FactoryObjectConfig)fCaptor.getValue().get(0), is(config));
        ArgumentCaptor<List> pCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_OsgiConfigLoader).process(pCaptor.capture(), eq(true));
        assertThat(pCaptor.getValue().size(), is(1));
        assertThat((PidConfig)pCaptor.getValue().get(0), is(pconfig));
        ArgumentCaptor<List> aCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_AddrConfigLoader).process(aCaptor.capture(), eq(true));
        assertThat(aCaptor.getValue().size(), is(1));
        assertThat((AddressConfig)aCaptor.getValue().get(0), is(aconfig));
        ArgumentCaptor<List> eCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_EventConfigLoader).process(eCaptor.capture());
        assertThat(eCaptor.getValue().size(), is(1));
        assertThat((EventConfig)eCaptor.getValue().get(0), is(eConfig));
        ArgumentCaptor<List> sCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processSocketChannels(sCaptor.capture());
        assertThat(sCaptor.getValue().size(), is(1));
        assertThat((SocketChannelConfig)sCaptor.getValue().get(0), is(sConfig));
        ArgumentCaptor<List> tCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_ChannelConfigLoader).processTransportChannels(tCaptor.capture());
        assertThat(tCaptor.getValue().size(), is(1));
        assertThat((TransportChannelConfig)tCaptor.getValue().get(0), is(tConfig));
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin,
            ConfigLoadingConstants.TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT);
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Test public void testFrameworkEventStarted_ConfigsProcessed ( ) throws UnmarshalException , IOException { when ( m_ConfigAdmin . getConfiguration ( ConfigurationMgr . class . getName ( ) ) ) . thenReturn ( m_OSGiConfiguration ) ; when ( m_OSGiConfiguration . getProperties ( ) ) . thenReturn ( null ) ; List < FactoryObjectConfig > fConfigs = new ArrayList < > ( ) ; FactoryObjectConfig config = mock ( FactoryObjectConfig . class ) ; fConfigs . add ( config ) ; List < PidConfig > pConfigs = new ArrayList < > ( ) ; PidConfig pconfig = mock ( PidConfig . class ) ; pConfigs . add ( pconfig ) ; List < AddressConfig > aConfigs = new ArrayList < > ( ) ; AddressConfig aconfig = mock ( AddressConfig . class ) ; aConfigs . add ( aconfig ) ; List < EventConfig > eConfigs = new ArrayList < > ( ) ; EventConfig eConfig = mock ( EventConfig . class ) ; eConfigs . add ( eConfig ) ; List < SocketChannelConfig > sConfigs = new ArrayList < > ( ) ; SocketChannelConfig sConfig = mock ( SocketChannelConfig . class ) ; sConfigs . add ( sConfig ) ; List < TransportChannelConfig > tConfigs = new ArrayList < > ( ) ; TransportChannelConfig tConfig = mock ( TransportChannelConfig . class ) ; tConfigs . add ( tConfig ) ; when ( m_XmlConfiguration . getFactoryObjects ( ) ) . thenReturn ( fConfigs ) ; when ( m_XmlConfiguration . getOsgiConfigs ( ) ) . thenReturn ( pConfigs ) ; when ( m_XmlConfiguration . getAddresses ( ) ) . thenReturn ( aConfigs ) ; when ( m_XmlConfiguration . getEventRegs ( ) ) . thenReturn ( eConfigs ) ; when ( m_XmlConfiguration . getSocketChannels ( ) ) . thenReturn ( sConfigs ) ; when ( m_XmlConfiguration . getTransportChannels ( ) ) . thenReturn ( tConfigs ) ; m_SUT . activate ( m_BundleContext ) ; ArgumentCaptor < List > fCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_FactoryObjLoader ) . process ( fCaptor . capture ( ) , eq ( true ) ) ; assertThat ( fCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( FactoryObjectConfig ) fCaptor . getValue ( ) . get ( 0 ) , is ( config ) ) ; ArgumentCaptor < List > pCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_OsgiConfigLoader ) . process ( pCaptor . capture ( ) , eq ( true ) ) ; assertThat ( pCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( PidConfig ) pCaptor . getValue ( ) . get ( 0 ) , is ( pconfig ) ) ; ArgumentCaptor < List > aCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_AddrConfigLoader ) . process ( aCaptor . capture ( ) , eq ( true ) ) ; assertThat ( aCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( AddressConfig ) aCaptor . getValue ( ) . get ( 0 ) , is ( aconfig ) ) ; ArgumentCaptor < List > eCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_EventConfigLoader ) . process ( eCaptor . capture ( ) ) ; assertThat ( eCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( EventConfig ) eCaptor . getValue ( ) . get ( 0 ) , is ( eConfig ) ) ; ArgumentCaptor < List > sCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_ChannelConfigLoader ) . processSocketChannels ( sCaptor . capture ( ) ) ; assertThat ( sCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( SocketChannelConfig ) sCaptor . getValue ( ) . get ( 0 ) , is ( sConfig ) ) ; ArgumentCaptor < List > tCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_ChannelConfigLoader ) . processTransportChannels ( tCaptor . capture ( ) ) ; assertThat ( tCaptor . getValue ( ) . size ( ) , is ( 1 ) ) ; assertThat ( ( TransportChannelConfig ) tCaptor . getValue ( ) . get ( 0 ) , is ( tConfig ) ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , ConfigLoadingConstants . TOPIC_CONFIG_PROCESSING_COMPLETE_EVENT ) ; }
Verify that the framework started event is handled properly and configurations are processed when a configs.xml
 file is found during activation.
Verify that the framework started event is handled properly and configurations are processed when a configs . xml file is found during activation .