Lines 43-52
Link Here
|
43 |
|
43 |
|
44 |
import java.awt.event.ActionEvent; |
44 |
import java.awt.event.ActionEvent; |
45 |
import java.awt.event.ActionListener; |
45 |
import java.awt.event.ActionListener; |
|
|
46 |
import java.net.URL; |
47 |
import javax.swing.Action; |
46 |
import junit.framework.*; |
48 |
import junit.framework.*; |
47 |
import org.netbeans.junit.*; |
49 |
import org.netbeans.junit.*; |
48 |
import org.netbeans.modules.tasklist.trampoline.TaskGroupFactory; |
50 |
import org.netbeans.modules.tasklist.trampoline.TaskGroupFactory; |
49 |
import org.openide.filesystems.FileObject; |
51 |
import org.openide.filesystems.FileObject; |
|
|
52 |
import org.openide.filesystems.FileStateInvalidException; |
50 |
import org.openide.filesystems.FileUtil; |
53 |
import org.openide.filesystems.FileUtil; |
51 |
|
54 |
|
52 |
|
55 |
|
Lines 92-98
Link Here
|
92 |
return suite; |
95 |
return suite; |
93 |
} |
96 |
} |
94 |
|
97 |
|
95 |
public void testGetters() { |
98 |
public void testGetters() throws FileStateInvalidException { |
96 |
String description = "task description"; |
99 |
String description = "task description"; |
97 |
int lineNo = 123; |
100 |
int lineNo = 123; |
98 |
FileObject resource = FileUtil.getConfigRoot(); |
101 |
FileObject resource = FileUtil.getConfigRoot(); |
Lines 101-109
Link Here
|
101 |
|
104 |
|
102 |
assertEquals( description, t.getDescription() ); |
105 |
assertEquals( description, t.getDescription() ); |
103 |
assertEquals( lineNo, t.getLine() ); |
106 |
assertEquals( lineNo, t.getLine() ); |
104 |
assertEquals( resource, t.getResource() ); |
107 |
assertEquals( resource, t.getFile() ); |
|
|
108 |
assertNull( t.getURL() ); |
109 |
assertNull( t.getActions() ); |
105 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
110 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
106 |
assertNull( t.getActionListener() ); |
111 |
assertNull( t.getDefaultAction() ); |
107 |
|
112 |
|
108 |
ActionListener al = new ActionListener() { |
113 |
ActionListener al = new ActionListener() { |
109 |
public void actionPerformed(ActionEvent arg0) { |
114 |
public void actionPerformed(ActionEvent arg0) { |
Lines 115-132
Link Here
|
115 |
|
120 |
|
116 |
assertEquals( description, t.getDescription() ); |
121 |
assertEquals( description, t.getDescription() ); |
117 |
assertEquals( -1, t.getLine() ); |
122 |
assertEquals( -1, t.getLine() ); |
118 |
assertEquals( resource, t.getResource() ); |
123 |
assertEquals( resource, t.getFile() ); |
|
|
124 |
assertNull( t.getURL() ); |
125 |
assertNull( t.getActions() ); |
119 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
126 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
120 |
assertEquals( al, t.getActionListener() ); |
127 |
assertEquals( al, t.getDefaultAction() ); |
|
|
128 |
|
129 |
URL url = resource.getURL(); |
130 |
|
131 |
t = Task.create(url, TASK_GROUP_NAME, description ); |
132 |
|
133 |
assertEquals( description, t.getDescription() ); |
134 |
assertEquals( -1, t.getLine() ); |
135 |
assertEquals( url, t.getURL() ); |
136 |
assertNull( t.getFile() ); |
137 |
assertNull( t.getActions() ); |
138 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
139 |
assertNull( t.getDefaultAction() ); |
140 |
|
141 |
Action[] actions = new Action[1]; |
142 |
t = Task.create(url, TASK_GROUP_NAME, description, al, actions ); |
143 |
|
144 |
assertEquals( description, t.getDescription() ); |
145 |
assertEquals( -1, t.getLine() ); |
146 |
assertEquals( url, t.getURL() ); |
147 |
assertNull( t.getFile() ); |
148 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
149 |
assertEquals( al, t.getDefaultAction() ); |
150 |
assertSame( actions, t.getActions() ); |
121 |
} |
151 |
} |
122 |
|
152 |
|
123 |
public void testNullValues() { |
153 |
public void testNullValues() { |
124 |
String description = "task description"; |
154 |
String description = "task description"; |
125 |
int lineNo = 123; |
155 |
int lineNo = 123; |
126 |
FileObject resource = FileUtil.getConfigRoot(); |
156 |
FileObject resource = FileUtil.getConfigRoot(); |
127 |
|
157 |
|
128 |
try { |
158 |
try { |
129 |
Task.create(null, TASK_GROUP_NAME, description, lineNo ); |
159 |
Task.create((FileObject)null, TASK_GROUP_NAME, description, lineNo ); |
|
|
160 |
fail( "resource cannot be null" ); |
161 |
} catch( AssertionError e ) { |
162 |
//that's what we want |
163 |
} |
164 |
|
165 |
try { |
166 |
Task.create((URL)null, TASK_GROUP_NAME, description ); |
130 |
fail( "resource cannot be null" ); |
167 |
fail( "resource cannot be null" ); |
131 |
} catch( AssertionError e ) { |
168 |
} catch( AssertionError e ) { |
132 |
//that's what we want |
169 |
//that's what we want |
Lines 147-153
Link Here
|
147 |
} |
184 |
} |
148 |
} |
185 |
} |
149 |
|
186 |
|
150 |
public void testNegativeLineNumberAllowed() { |
187 |
public void testNegativeLineNumberAllowed() throws FileStateInvalidException { |
151 |
String description = "task description"; |
188 |
String description = "task description"; |
152 |
int lineNo = -1; |
189 |
int lineNo = -1; |
153 |
FileObject resource = FileUtil.getConfigRoot(); |
190 |
FileObject resource = FileUtil.getConfigRoot(); |
Lines 156-166
Link Here
|
156 |
|
193 |
|
157 |
assertEquals( description, t.getDescription() ); |
194 |
assertEquals( description, t.getDescription() ); |
158 |
assertEquals( lineNo, t.getLine() ); |
195 |
assertEquals( lineNo, t.getLine() ); |
159 |
assertEquals( resource, t.getResource() ); |
196 |
assertEquals( resource, t.getFile() ); |
160 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
197 |
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() ); |
161 |
} |
198 |
} |
162 |
|
199 |
|
163 |
public void testUnknownTaskGroup() { |
200 |
public void testUnknownTaskGroup() throws FileStateInvalidException { |
164 |
String description = "task description"; |
201 |
String description = "task description"; |
165 |
int lineNo = 123; |
202 |
int lineNo = 123; |
166 |
FileObject resource = FileUtil.getConfigRoot(); |
203 |
FileObject resource = FileUtil.getConfigRoot(); |
Lines 169-186
Link Here
|
169 |
|
206 |
|
170 |
assertEquals( description, t.getDescription() ); |
207 |
assertEquals( description, t.getDescription() ); |
171 |
assertEquals( lineNo, t.getLine() ); |
208 |
assertEquals( lineNo, t.getLine() ); |
172 |
assertEquals( resource, t.getResource() ); |
209 |
assertEquals( resource, t.getFile() ); |
173 |
assertEquals( TaskGroupFactory.getDefault().getDefaultGroup(), t.getGroup() ); |
210 |
assertEquals( TaskGroupFactory.getDefault().getDefaultGroup(), t.getGroup() ); |
174 |
} |
211 |
} |
175 |
|
212 |
|
176 |
public void testEquals() { |
213 |
public void testEquals() throws FileStateInvalidException { |
177 |
String description = "task description"; |
214 |
String description = "task description"; |
178 |
int lineNo = 123; |
215 |
int lineNo = 123; |
179 |
FileObject resource = FileUtil.getConfigRoot(); |
216 |
FileObject resource = FileUtil.getConfigRoot(); |
180 |
|
217 |
|
181 |
Task t1 = Task.create(resource, TASK_GROUP_NAME, description, lineNo ); |
218 |
Task t1 = Task.create(resource, TASK_GROUP_NAME, description, lineNo ); |
182 |
Task t2 = Task.create(resource, TASK_GROUP_NAME, description, lineNo ); |
219 |
Task t2 = Task.create(resource, TASK_GROUP_NAME, description, lineNo ); |
183 |
|
220 |
|
|
|
221 |
assertEquals( t1, t2 ); |
222 |
assertEquals( t1.hashCode(), t2.hashCode() ); |
223 |
|
224 |
URL url = FileUtil.getConfigRoot().getURL(); |
225 |
|
226 |
t1 = Task.create(url, TASK_GROUP_NAME, description ); |
227 |
t2 = Task.create(url, TASK_GROUP_NAME, description ); |
228 |
|
184 |
assertEquals( t1, t2 ); |
229 |
assertEquals( t1, t2 ); |
185 |
assertEquals( t1.hashCode(), t2.hashCode() ); |
230 |
assertEquals( t1.hashCode(), t2.hashCode() ); |
186 |
} |
231 |
} |