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 | */ |
21 | package org.jdtaus.core.monitor.it; |
22 | |
23 | import junit.framework.Assert; |
24 | import junit.framework.TestCase; |
25 | import org.jdtaus.core.monitor.TaskEventSource; |
26 | import org.jdtaus.core.monitor.TaskListener; |
27 | |
28 | /** |
29 | * Testcase for {@code TaskEventSource} implementations. |
30 | * |
31 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
32 | * @version $JDTAUS: TaskEventSourceTest.java 8743 2012-10-07 03:06:20Z schulte $ |
33 | */ |
34 | public class TaskEventSourceTest extends TestCase |
35 | { |
36 | //--TaskEventSourceTest----------------------------------------------------- |
37 | |
38 | /** Implementation to test. */ |
39 | private TaskEventSource source; |
40 | |
41 | /** Creates a new {@code TaskEventSourceTest} instance. */ |
42 | public TaskEventSourceTest() |
43 | { |
44 | super(); |
45 | } |
46 | |
47 | /** |
48 | * Gets the {@code TaskEventSource} implementation tests are performed with. |
49 | * |
50 | * @return the {@code TaskEventSource} implementation tests are performed |
51 | * with. |
52 | */ |
53 | public TaskEventSource getTaskEventSource() |
54 | { |
55 | return this.source; |
56 | } |
57 | |
58 | /** |
59 | * Sets the {@code TaskEventSource} implementation tests are performed with. |
60 | * |
61 | * @param value the {@code TaskEventSource} implementation to perform tests |
62 | * with. |
63 | */ |
64 | public final void setTaskEventSource( final TaskEventSource value ) |
65 | { |
66 | this.source = value; |
67 | } |
68 | |
69 | //-----------------------------------------------------TaskEventSourceTest-- |
70 | //--Tests------------------------------------------------------------------- |
71 | |
72 | /** |
73 | * Tests the {@link TaskEventSource#addTaskListener(TaskListener)} method to |
74 | * handle {@code null} listener values correctly by throwing a corresponding |
75 | * {@code NullPointerException}. |
76 | */ |
77 | public void testAddTaskListener() throws Exception |
78 | { |
79 | assert this.getTaskEventSource() != null; |
80 | |
81 | try |
82 | { |
83 | this.getTaskEventSource().addTaskListener( null ); |
84 | throw new AssertionError(); |
85 | } |
86 | catch ( final NullPointerException e ) |
87 | { |
88 | Assert.assertNotNull( e.getMessage() ); |
89 | System.out.println( e.toString() ); |
90 | } |
91 | |
92 | } |
93 | |
94 | /** |
95 | * Tests the {@link TaskEventSource#removeTaskListener(TaskListener)} method |
96 | * to handle {@code null} listener values correctly by throwing a |
97 | * corresponding {@code NullPointerException}. |
98 | */ |
99 | public void testRemoveTaskListener() throws Exception |
100 | { |
101 | assert this.getTaskEventSource() != null; |
102 | |
103 | try |
104 | { |
105 | this.getTaskEventSource().removeTaskListener( null ); |
106 | throw new AssertionError(); |
107 | } |
108 | catch ( final NullPointerException e ) |
109 | { |
110 | Assert.assertNotNull( e.getMessage() ); |
111 | System.out.println( e.toString() ); |
112 | } |
113 | |
114 | } |
115 | |
116 | /** |
117 | * Tests the {@link TaskEventSource#getTaskListeners()} method to not |
118 | * return a {@code null} value instead of an empty array when no listeners |
119 | * are registered. |
120 | */ |
121 | public void testGetTaskListeners() throws Exception |
122 | { |
123 | assert this.getTaskEventSource() != null; |
124 | |
125 | Assert.assertNotNull( this.getTaskEventSource().getTaskListeners() ); |
126 | } |
127 | |
128 | //-------------------------------------------------------------------Tests-- |
129 | } |