mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestManagedExecutors.java
public void testExecuteScript() throws Exception
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        asset.setName("executorAsset");
                
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        assertThat(observationStore, is(notNullValue()));

        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(true).
            withImmediately(true).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withSchedule(schedule).
            withProgramName("test-executor").withTemplateName("executor-template").
                withParameters(new MapEntry("asset", "executorAsset"));
        
        EventHandlerSyncer executionSyncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "test-executor"));
        
        Program program = m_MissionProgramManager.loadParameters(params);
        
        try
        {
            executionSyncer.waitForEvent(5);
            
            // allow some observations to be made
            Thread.sleep(4500);
            
            // stop asset data capture        
            m_ManagedExecutors.shutdownAllExecutorServices();
            
            // allow current iteration to finish
            Thread.sleep(1500);
            
            // should have capture 1/second 4-5 in 4500 ms, depends on how quickly this check is made
            Collection<Observation> observations1 = observationStore.queryByAsset(asset);
            assertThat("At least 4 observations not found", observations1.size() >= 4);
            
            // wait and make sure no more captured
            Thread.sleep(2500);
            Collection<Observation> observations2 = observationStore.queryByAsset(asset);
            // should still be 4
            assertThat(observations2.size(), is(observations1.size()));
        }
        finally
        {
            MissionProgramUtils.shutdownSync(m_Context, program);
        }
    }
/*
     * This tests the execution of scripts that have dependencies and the ability to stop the executor. Furthermore, 
     * this test allows time for the script/mission to execute for a specific period of time, then shuts down the 
     * executor and verifies the observations collected(from the mission), and ensures that after shutdown no additional
     * observations were made.   
     */
This tests the execution of scripts that have dependencies and the ability to stop the executor. Furthermore,
this test allows time for the script/mission to execute for a specific period of time, then shuts down the
executor and verifies the observations collected(from the mission), and ensures that after shutdown no additional
observations were made.
This tests the execution of scripts that have dependencies and the ability to stop the executor . Furthermore this test allows time for the script / mission to execute for a specific period of time then shuts down the executor and verifies the observations collected ( from the mission ) and ensures that after shutdown no additional observations were made .
public void testExecuteScript() throws Exception
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        asset.setName("executorAsset");
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        assertThat(observationStore, is(notNullValue()));
        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(true).
            withImmediately(true).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withSchedule(schedule).
            withProgramName("test-executor").withTemplateName("executor-template").
                withParameters(new MapEntry("asset", "executorAsset"));
        EventHandlerSyncer executionSyncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "test-executor"));
        Program program = m_MissionProgramManager.loadParameters(params);
        try
        {
            executionSyncer.waitForEvent(5);
            Thread.sleep(4500);
            m_ManagedExecutors.shutdownAllExecutorServices();
            Thread.sleep(1500);
            Collection<Observation> observations1 = observationStore.queryByAsset(asset);
            assertThat("At least 4 observations not found", observations1.size() >= 4);
            Thread.sleep(2500);
            Collection<Observation> observations2 = observationStore.queryByAsset(asset);
            assertThat(observations2.size(), is(observations1.size()));
        }
        finally
        {
            MissionProgramUtils.shutdownSync(m_Context, program);
        }
    }
public void testExecuteScript ( ) throws Exception { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; Asset asset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) ) ; asset . setName ( "executorAsset" ) ; ObservationStore observationStore = ServiceUtils . getService ( m_Context , ObservationStore . class ) ; assertThat ( observationStore , is ( notNullValue ( ) ) ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( true ) . withImmediately ( true ) . withActive ( true ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withSchedule ( schedule ) . withProgramName ( "test-executor" ) . withTemplateName ( "executor-template" ) . withParameters ( new MapEntry ( "asset" , "executorAsset" ) ) ; EventHandlerSyncer executionSyncer = new EventHandlerSyncer ( m_Context , Program . TOPIC_PROGRAM_EXECUTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , "test-executor" ) ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; try { executionSyncer . waitForEvent ( 5 ) ; Thread . sleep ( 4500 ) ; m_ManagedExecutors . shutdownAllExecutorServices ( ) ; Thread . sleep ( 1500 ) ; Collection < Observation > observations1 = observationStore . queryByAsset ( asset ) ; assertThat ( "At least 4 observations not found" , observations1 . size ( ) >= 4 ) ; Thread . sleep ( 2500 ) ; Collection < Observation > observations2 = observationStore . queryByAsset ( asset ) ; assertThat ( observations2 . size ( ) , is ( observations1 . size ( ) ) ) ; } finally { MissionProgramUtils . shutdownSync ( m_Context , program ) ; } }
This tests the execution of scripts that have dependencies and the ability to stop the executor.
This tests the execution of scripts that have dependencies and the ability to stop the executor .
// allow some observations to be made // stop asset data capture         // allow current iteration to finish // should have capture 1/second 4-5 in 4500 ms, depends on how quickly this check is made // wait and make sure no more captured // should still be 4