mil.dod.th.ose.integration/src/mil/dod/th/ose/controller/integration/TestPrepFor2ndRun.java
@Test
    public void testFirstRunAndOverrideConfigurations() throws Exception
    {
        // Remove Assets to test first run setting
        String assetName1 = "xmlConfigAsset1";
        String assetName2 = "xmlConfigAsset2";
        
        AssetDirectoryService assetDirectoryService = IntegrationTestRunner.getService(AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        
        try
        {
            Asset testAsset1 = assetDirectoryService.getAssetByName(assetName1);
            AssetTestUtils.deactivateAsset(testAsset1);
            AssetTestUtils.tryDeleteAsset(testAsset1);
        }
        catch (IllegalArgumentException e)
        {
            Logging.log(LogService.LOG_WARNING, e, "Asset [%s] not found in lookup, no need to remove.", assetName1);
        }

        try
        {
            Asset testAsset2 = assetDirectoryService.getAssetByName(assetName2);    
            AssetTestUtils.tryDeleteAsset(testAsset2);
        }
        catch (IllegalArgumentException e)
        {
            Logging.log(LogService.LOG_WARNING, e, "Asset [%s] not found in lookup, no need to remove.", assetName2);
        }
                               
        // Remove Addresses to test FirstRun setting
        String address1desc = "Example:1";
        String address2desc = "Example:2";
        String address3desc = "Example:3";
        AddressManagerService addressManagerService = IntegrationTestRunner.getService(AddressManagerService.class);
        assertThat(addressManagerService, is(notNullValue()));
        if (addressManagerService.checkAddressAlreadyExists(address1desc))
        {
            Address addr1 = addressManagerService.getOrCreateAddress(address1desc);
            addr1.delete();
        }
        if (addressManagerService.checkAddressAlreadyExists(address2desc))
        {
            Address addr2 = addressManagerService.getOrCreateAddress(address2desc);       
            addr2.delete();
        }
        if (addressManagerService.checkAddressAlreadyExists(address3desc))
        {
            Address addr3 = addressManagerService.getOrCreateAddress(address3desc);       
            addr3.delete();
        }

        // Remove LinkLayer to test creation.
        String testLinkName = "xmlConfigLinkLayer";
        CustomCommsService customCommsService = IntegrationTestRunner.getService(CustomCommsService.class);
        LinkLayer testLinkLayer = customCommsService.getLinkLayer(testLinkName);
        assertThat(testLinkLayer, is(notNullValue()));
        testLinkLayer.deactivateLayer();
        testLinkLayer.delete();
        
        // Remove Transport layer to test FirstRun setting
        String testTransportLayerName = "xmlConfigTransportLayer";
        TransportLayer transportLayer = customCommsService.getTransportLayer(testTransportLayerName);
        transportLayer.delete();
        
        // Remove PhysicalLink to test IfMissing setting
        String testPhysicalLinkName = "xmlConfigPhysicalLink";
        customCommsService.deletePhysicalLink(testPhysicalLinkName);

        // Remove configuration to test OSGi non-factory configuration creation on second run
        String osgiPid = "example.metatype.XML.ExampleClass";
        ConfigurationAdmin configAdmin = IntegrationTestRunner.getService(ConfigurationAdmin.class);     
        Configuration osgiNonFactoryConfig = configAdmin.getConfiguration(osgiPid);
        osgiNonFactoryConfig.delete();
    }
/**
     * Configure system for tests in {@link mil.dod.th.ose.controller.integration.config.TestXmlConfigurations2ndRun}.
     */
Configure system for tests in  mil.dod.th.ose.controller.integration.config.TestXmlConfigurations2ndRun.
Configure system for tests in mil . dod . th . ose . controller . integration . config . TestXmlConfigurations2ndRun .
@Test
    public void testFirstRunAndOverrideConfigurations() throws Exception
    {
        String assetName1 = "xmlConfigAsset1";
        String assetName2 = "xmlConfigAsset2";
        AssetDirectoryService assetDirectoryService = IntegrationTestRunner.getService(AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        try
        {
            Asset testAsset1 = assetDirectoryService.getAssetByName(assetName1);
            AssetTestUtils.deactivateAsset(testAsset1);
            AssetTestUtils.tryDeleteAsset(testAsset1);
        }
        catch (IllegalArgumentException e)
        {
            Logging.log(LogService.LOG_WARNING, e, "Asset [%s] not found in lookup, no need to remove.", assetName1);
        }
        try
        {
            Asset testAsset2 = assetDirectoryService.getAssetByName(assetName2);    
            AssetTestUtils.tryDeleteAsset(testAsset2);
        }
        catch (IllegalArgumentException e)
        {
            Logging.log(LogService.LOG_WARNING, e, "Asset [%s] not found in lookup, no need to remove.", assetName2);
        }
        String address1desc = "Example:1";
        String address2desc = "Example:2";
        String address3desc = "Example:3";
        AddressManagerService addressManagerService = IntegrationTestRunner.getService(AddressManagerService.class);
        assertThat(addressManagerService, is(notNullValue()));
        if (addressManagerService.checkAddressAlreadyExists(address1desc))
        {
            Address addr1 = addressManagerService.getOrCreateAddress(address1desc);
            addr1.delete();
        }
        if (addressManagerService.checkAddressAlreadyExists(address2desc))
        {
            Address addr2 = addressManagerService.getOrCreateAddress(address2desc);       
            addr2.delete();
        }
        if (addressManagerService.checkAddressAlreadyExists(address3desc))
        {
            Address addr3 = addressManagerService.getOrCreateAddress(address3desc);       
            addr3.delete();
        }
        String testLinkName = "xmlConfigLinkLayer";
        CustomCommsService customCommsService = IntegrationTestRunner.getService(CustomCommsService.class);
        LinkLayer testLinkLayer = customCommsService.getLinkLayer(testLinkName);
        assertThat(testLinkLayer, is(notNullValue()));
        testLinkLayer.deactivateLayer();
        testLinkLayer.delete();
        String testTransportLayerName = "xmlConfigTransportLayer";
        TransportLayer transportLayer = customCommsService.getTransportLayer(testTransportLayerName);
        transportLayer.delete();
        String testPhysicalLinkName = "xmlConfigPhysicalLink";
        customCommsService.deletePhysicalLink(testPhysicalLinkName);
        String osgiPid = "example.metatype.XML.ExampleClass";
        ConfigurationAdmin configAdmin = IntegrationTestRunner.getService(ConfigurationAdmin.class);     
        Configuration osgiNonFactoryConfig = configAdmin.getConfiguration(osgiPid);
        osgiNonFactoryConfig.delete();
    }
@ Test public void testFirstRunAndOverrideConfigurations ( ) throws Exception { String assetName1 = "xmlConfigAsset1" ; String assetName2 = "xmlConfigAsset2" ; AssetDirectoryService assetDirectoryService = IntegrationTestRunner . getService ( AssetDirectoryService . class ) ; assertThat ( assetDirectoryService , is ( notNullValue ( ) ) ) ; try { Asset testAsset1 = assetDirectoryService . getAssetByName ( assetName1 ) ; AssetTestUtils . deactivateAsset ( testAsset1 ) ; AssetTestUtils . tryDeleteAsset ( testAsset1 ) ; } catch ( IllegalArgumentException e ) { Logging . log ( LogService . LOG_WARNING , e , "Asset [%s] not found in lookup, no need to remove." , assetName1 ) ; } try { Asset testAsset2 = assetDirectoryService . getAssetByName ( assetName2 ) ; AssetTestUtils . tryDeleteAsset ( testAsset2 ) ; } catch ( IllegalArgumentException e ) { Logging . log ( LogService . LOG_WARNING , e , "Asset [%s] not found in lookup, no need to remove." , assetName2 ) ; } String address1desc = "Example:1" ; String address2desc = "Example:2" ; String address3desc = "Example:3" ; AddressManagerService addressManagerService = IntegrationTestRunner . getService ( AddressManagerService . class ) ; assertThat ( addressManagerService , is ( notNullValue ( ) ) ) ; if ( addressManagerService . checkAddressAlreadyExists ( address1desc ) ) { Address addr1 = addressManagerService . getOrCreateAddress ( address1desc ) ; addr1 . delete ( ) ; } if ( addressManagerService . checkAddressAlreadyExists ( address2desc ) ) { Address addr2 = addressManagerService . getOrCreateAddress ( address2desc ) ; addr2 . delete ( ) ; } if ( addressManagerService . checkAddressAlreadyExists ( address3desc ) ) { Address addr3 = addressManagerService . getOrCreateAddress ( address3desc ) ; addr3 . delete ( ) ; } String testLinkName = "xmlConfigLinkLayer" ; CustomCommsService customCommsService = IntegrationTestRunner . getService ( CustomCommsService . class ) ; LinkLayer testLinkLayer = customCommsService . getLinkLayer ( testLinkName ) ; assertThat ( testLinkLayer , is ( notNullValue ( ) ) ) ; testLinkLayer . deactivateLayer ( ) ; testLinkLayer . delete ( ) ; String testTransportLayerName = "xmlConfigTransportLayer" ; TransportLayer transportLayer = customCommsService . getTransportLayer ( testTransportLayerName ) ; transportLayer . delete ( ) ; String testPhysicalLinkName = "xmlConfigPhysicalLink" ; customCommsService . deletePhysicalLink ( testPhysicalLinkName ) ; String osgiPid = "example.metatype.XML.ExampleClass" ; ConfigurationAdmin configAdmin = IntegrationTestRunner . getService ( ConfigurationAdmin . class ) ; Configuration osgiNonFactoryConfig = configAdmin . getConfiguration ( osgiPid ) ; osgiNonFactoryConfig . delete ( ) ; }
Configure system for tests in {@link mil.dod.th.ose.controller.integration.config.TestXmlConfigurations2ndRun}.
Configure system for tests in { @link mil . dod . th . ose . controller . integration . config . TestXmlConfigurations2ndRun } .
// Remove Assets to test first run setting // Remove Addresses to test FirstRun setting // Remove LinkLayer to test creation. // Remove Transport layer to test FirstRun setting // Remove PhysicalLink to test IfMissing setting // Remove configuration to test OSGi non-factory configuration creation on second run