mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestManagedExecutors.java
@SuppressWarnings({ "unchecked", "unused", "rawtypes" })
    public final void testExecutionException() 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();
                }
            }
        });

        ExecutorService es = m_ManagedExecutors.newCachedThreadPool();

        Future future = es.submit(new Callable()
        {
            @Override
            public Throwable call() throws IOException
            {
                IOException throwMe = new IOException("A test exception");
                throw throwMe;
            }
        });
        
        // verify log message is read
        assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS), is(true));
    }
/*
     * This test that an exception thrown by a thread in an executor service logs the thrown exception.
     */
This test that an exception thrown by a thread in an executor service logs the thrown exception.
This test that an exception thrown by a thread in an executor service logs the thrown exception .
@SuppressWarnings({ "unchecked", "unused", "rawtypes" })
    public final void testExecutionException() 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();
                }
            }
        });
        ExecutorService es = m_ManagedExecutors.newCachedThreadPool();
        Future future = es.submit(new Callable()
        {
            @Override
            public Throwable call() throws IOException
            {
                IOException throwMe = new IOException("A test exception");
                throw throwMe;
            }
        });
        assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS), is(true));
    }
@ SuppressWarnings ( { "unchecked" , "unused" , "rawtypes" } ) public final void testExecutionException ( ) 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 ( ) ; } } } ) ; ExecutorService es = m_ManagedExecutors . newCachedThreadPool ( ) ; Future future = es . submit ( new Callable ( ) { @ Override public Throwable call ( ) throws IOException { IOException throwMe = new IOException ( "A test exception" ) ; throw throwMe ; } } ) ; assertThat ( semaphore . tryAcquire ( 5 , TimeUnit . SECONDS ) , is ( true ) ) ; }
This test that an exception thrown by a thread in an executor service logs the thrown exception.
This test that an exception thrown by a thread in an executor service logs the thrown exception .
// verify log message is read