mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestManagedExecutors.java
public final void testScriptExceptionLoggiong() throws Exception
    {
        LogReaderService logReader = ServiceUtils.getService(m_Context, LogReaderService.class);
        
        final Semaphore semaphore = new Semaphore(0);
        
        logReader.addLogListener(new LogListener()
        {
            @Override
            public void logged(LogEntry entry)
            {
                if (entry.getMessage().contains("Executor threw an exception"))
                {
                    semaphore.release();
                }
            }
        });
        
        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(true).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withSchedule(schedule).
                withProgramName("test-exception-executor").withTemplateName("exceptionExecutor-template");
        
        Program program = m_MissionProgramManager.loadParameters(params);
        
        try
        {
            // allow some errors to be logged to be made
            Thread.sleep(2500);
            
            // verify log message is read
            assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS), is(true));
            
            // stop asset data capture        
            m_ManagedExecutors.shutdownAllExecutorServices();
            
            // allow current iteration to finish
            Thread.sleep(500);
        }
        finally
        {
            MissionProgramUtils.shutdownSync(m_Context, program);
        }
    }
/*
     * This tests exception logging if the exception is thrown from a running mission script
     */
This tests exception logging if the exception is thrown from a running mission script
This tests exception logging if the exception is thrown from a running mission script
public final void testScriptExceptionLoggiong() throws Exception
    {
        LogReaderService logReader = ServiceUtils.getService(m_Context, LogReaderService.class);
        final Semaphore semaphore = new Semaphore(0);
        logReader.addLogListener(new LogListener()
        {
            @Override
            public void logged(LogEntry entry)
            {
                if (entry.getMessage().contains("Executor threw an exception"))
                {
                    semaphore.release();
                }
            }
        });
        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(true).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withSchedule(schedule).
                withProgramName("test-exception-executor").withTemplateName("exceptionExecutor-template");
        Program program = m_MissionProgramManager.loadParameters(params);
        try
        {
            Thread.sleep(2500);
            assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS), is(true));
            m_ManagedExecutors.shutdownAllExecutorServices();
            Thread.sleep(500);
        }
        finally
        {
            MissionProgramUtils.shutdownSync(m_Context, program);
        }
    }
public final void testScriptExceptionLoggiong ( ) throws Exception { LogReaderService logReader = ServiceUtils . getService ( m_Context , LogReaderService . class ) ; final Semaphore semaphore = new Semaphore ( 0 ) ; logReader . addLogListener ( new LogListener ( ) { @ Override public void logged ( LogEntry entry ) { if ( entry . getMessage ( ) . contains ( "Executor threw an exception" ) ) { semaphore . release ( ) ; } } } ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( false ) . withImmediately ( true ) . withActive ( true ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withSchedule ( schedule ) . withProgramName ( "test-exception-executor" ) . withTemplateName ( "exceptionExecutor-template" ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; try { Thread . sleep ( 2500 ) ; assertThat ( semaphore . tryAcquire ( 5 , TimeUnit . SECONDS ) , is ( true ) ) ; m_ManagedExecutors . shutdownAllExecutorServices ( ) ; Thread . sleep ( 500 ) ; } finally { MissionProgramUtils . shutdownSync ( m_Context , program ) ; } }
This tests exception logging if the exception is thrown from a running mission script
This tests exception logging if the exception is thrown from a running mission script
// allow some errors to be logged to be made // verify log message is read // stop asset data capture         // allow current iteration to finish