EMMA Coverage Report (generated Wed Oct 03 04:37:30 CEST 2012)
[all classes][org.jdtaus.core.lang.spi.it]

COVERAGE SUMMARY FOR SOURCE FILE [ExecutorTest.java]

nameclass, %method, %block, %line, %
ExecutorTest.java0%   (0/4)0%   (0/11)0%   (0/102)0%   (0/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExecutorTest0%   (0/1)0%   (0/5)0%   (0/82)0%   (0/19)
<static initializer> 0%   (0/1)0%   (0/19)0%   (0/2)
ExecutorTest (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getExceptionEventSource (): ExceptionEventSource 0%   (0/1)0%   (0/3)0%   (0/1)
testNullArguments (): void 0%   (0/1)0%   (0/28)0%   (0/8)
testOnException (): void 0%   (0/1)0%   (0/29)0%   (0/7)
     
class ExecutorTest$10%   (0/1)0%   (0/2)0%   (0/7)0%   (0/2)
ExecutorTest$1 (): void 0%   (0/1)0%   (0/3)0%   (0/1)
run (): void 0%   (0/1)0%   (0/4)0%   (0/1)
     
class ExecutorTest$ExecutionException0%   (0/1)0%   (0/1)0%   (0/3)0%   (0/1)
ExecutorTest$ExecutionException (): void 0%   (0/1)0%   (0/3)0%   (0/1)
     
class ExecutorTest$TestListener0%   (0/1)0%   (0/3)0%   (0/10)0%   (0/4)
ExecutorTest$TestListener (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getEvent (): ExceptionEvent 0%   (0/1)0%   (0/3)0%   (0/1)
onException (ExceptionEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/*
2 *  jDTAUS Core Test Suite
3 *  Copyright (C) 2005 Christian Schulte
4 *  <cs@schulte.it>
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the GNU Lesser General Public
8 *  License as published by the Free Software Foundation; either
9 *  version 2.1 of the License, or any later version.
10 *
11 *  This library is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *  Lesser General Public License for more details.
15 *
16 *  You should have received a copy of the GNU Lesser General Public
17 *  License along with this library; if not, write to the Free Software
18 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21package org.jdtaus.core.lang.spi.it;
22 
23import junit.framework.Assert;
24import org.jdtaus.core.lang.ExceptionEvent;
25import org.jdtaus.core.lang.ExceptionEventSource;
26import org.jdtaus.core.lang.ExceptionListener;
27import org.jdtaus.core.lang.it.ExceptionEventSourceTest;
28import org.jdtaus.core.lang.spi.Executor;
29 
30/**
31 * Testcase for {@code Executor} implementations.
32 *
33 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
34 * @version $JDTAUS: ExecutorTest.java 8641 2012-09-27 06:45:17Z schulte $
35 */
36public abstract class ExecutorTest extends ExceptionEventSourceTest
37{
38    //--ExceptionEventSourceTest------------------------------------------------
39 
40    /**
41     * {@inheritDoc}
42     * @see #getExecutor()
43     */
44    public final ExceptionEventSource getExceptionEventSource()
45    {
46        return this.getExecutor();
47    }
48 
49    //------------------------------------------------ExceptionEventSourceTest--
50    //--ExecutorTest------------------------------------------------------------
51 
52    /**
53     * Gets the {@code Executor} implementation tests are performed with.
54     *
55     * @return the {@code Executor} implementation tests are performed with.
56     */
57    public abstract Executor getExecutor();
58 
59    //------------------------------------------------------------ExecutorTest--
60    //--Tests-------------------------------------------------------------------
61 
62    /** Exception expected to be reported. */
63    public static final class ExecutionException extends RuntimeException
64    {
65    }
66 
67    /** {@code Runnable} throwing {@code ExecutionException}. */
68    public static final Runnable runnable = new Runnable()
69    {
70 
71        public void run()
72        {
73            throw new ExecutionException();
74        }
75 
76    };
77 
78    /** {@code ExceptionListener} providing the last reported event. */
79    public static final class TestListener implements ExceptionListener
80    {
81 
82        /** The last reported event. */
83        private ExceptionEvent event;
84 
85        /**
86         * Gets the last reported event.
87         *
88         * @return the last reported event.
89         */
90        public ExceptionEvent getEvent()
91        {
92            return this.event;
93        }
94 
95        public void onException( final ExceptionEvent event )
96        {
97            this.event = event;
98        }
99 
100    }
101 
102    /**
103     * Tests the {@link Executor#executeAsynchronously(Runnable)} method to
104     * handle {@code null} arguments correctly by throwing a corresponding
105     * {@code NullPointerException}.
106     */
107    public void testNullArguments() throws Exception
108    {
109        super.testNullArguments();
110 
111        assert this.getExecutor() != null;
112 
113        try
114        {
115            this.getExecutor().executeAsynchronously( null );
116            throw new AssertionError();
117        }
118        catch ( NullPointerException e )
119        {
120            Assert.assertNotNull( e.getMessage() );
121            System.out.println( e.toString() );
122        }
123 
124    }
125 
126    /**
127     * Tests the {@link Executor#executeAsynchronously(Runnable)} method to
128     * report any exceptions thrown during execution.
129     */
130    public void testOnException() throws Exception
131    {
132        assert this.getExecutor() != null;
133 
134        final TestListener listener = new TestListener();
135        this.getExecutor().addExceptionListener( listener );
136        this.getExecutor().executeAsynchronously( runnable );
137 
138        // Wait 5 seconds and test the listener.
139        Thread.sleep( 5000L );
140 
141        Assert.assertTrue( listener.getEvent().
142                           getException() instanceof ExecutionException );
143 
144    }
145 
146    //-------------------------------------------------------------------Tests--
147}

[all classes][org.jdtaus.core.lang.spi.it]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov