Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
b0318660 | 3 | * |
eb1bab5b BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
b0318660 AM |
8 | * |
9 | * Contributors: | |
eb1bab5b BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
9315aeee | 12 | package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl; |
eb1bab5b | 13 | |
d4514365 BH |
14 | import java.util.LinkedList; |
15 | import java.util.List; | |
16 | ||
eb1bab5b BH |
17 | import junit.framework.TestCase; |
18 | ||
9315aeee | 19 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
d4514365 | 20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; |
9315aeee BH |
21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; |
22 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
23 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo; | |
d4514365 | 24 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo; |
eb1bab5b BH |
25 | |
26 | /** | |
27 | * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>. | |
28 | */ | |
b0318660 | 29 | @SuppressWarnings({"nls", "javadoc"}) |
eb1bab5b BH |
30 | public class BaseEventInfoTest extends TestCase { |
31 | ||
32 | // ------------------------------------------------------------------------ | |
33 | // Test data | |
34 | // ------------------------------------------------------------------------ | |
35 | private IBaseEventInfo fEventInfo1 = null; | |
36 | private IBaseEventInfo fEventInfo2 = null; | |
b0318660 | 37 | |
eb1bab5b BH |
38 | // ------------------------------------------------------------------------ |
39 | // Housekeeping | |
40 | // ------------------------------------------------------------------------ | |
41 | /** | |
42 | * Perform pre-test initialization. | |
43 | * | |
44 | * @throws Exception if the initialization fails for some reason | |
45 | * | |
46 | */ | |
47 | @Override | |
48 | public void setUp() throws Exception { | |
49 | super.setUp(); | |
b0318660 | 50 | ModelImplFactory factory = new ModelImplFactory(); |
eb1bab5b BH |
51 | fEventInfo1 = factory.getBaseEventInfo1(); |
52 | fEventInfo2 = factory.getBaseEventInfo2(); | |
53 | } | |
54 | ||
55 | /** | |
56 | * Perform post-test clean-up. | |
57 | * | |
58 | * @throws Exception if the clean-up fails for some reason | |
59 | * | |
60 | */ | |
61 | @Override | |
62 | public void tearDown() throws Exception { | |
63 | } | |
64 | ||
65 | // ------------------------------------------------------------------------ | |
66 | // Tests | |
67 | // ------------------------------------------------------------------------ | |
68 | ||
69 | /** | |
70 | * Run the BaseEventInfo() constructor test. | |
71 | * | |
72 | */ | |
73 | public void testBaseEventInfo() { | |
74 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
75 | assertNotNull(fixture); | |
b0318660 | 76 | |
eb1bab5b | 77 | TraceEventType result = fixture.getEventType(); |
b0318660 | 78 | |
eb1bab5b BH |
79 | assertEquals("event", fixture.getName()); |
80 | assertEquals("unknown", result.getInName()); | |
81 | assertEquals("UNKNOWN", result.name()); | |
82 | assertEquals("UNKNOWN", result.toString()); | |
ccc66d01 | 83 | assertEquals(3, result.ordinal()); |
b0318660 | 84 | |
eb1bab5b | 85 | TraceLogLevel level = fixture.getLogLevel(); |
4775bcbf BH |
86 | assertEquals("TRACE_DEBUG", level.getInName()); |
87 | assertEquals("TRACE_DEBUG", level.name()); | |
88 | assertEquals("TRACE_DEBUG", level.toString()); | |
89 | assertEquals(14, level.ordinal()); | |
eb1bab5b BH |
90 | } |
91 | ||
92 | /** | |
93 | * Test Copy Constructor | |
94 | */ | |
95 | public void testEventInfoCopy() { | |
96 | BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
b0318660 | 97 | |
eb1bab5b BH |
98 | assertEquals(fEventInfo1.getName(), info.getName()); |
99 | assertEquals(fEventInfo1.getEventType(), info.getEventType()); | |
100 | assertEquals(fEventInfo1.getLogLevel(), info.getLogLevel()); | |
d4514365 BH |
101 | assertEquals(fEventInfo1.getFilterExpression(), info.getFilterExpression()); |
102 | ||
103 | IFieldInfo[] orignalFields = fEventInfo1.getFields(); | |
104 | IFieldInfo[] copiedFields = info.getFields(); | |
105 | assertEquals(orignalFields.length, copiedFields.length); | |
106 | ||
107 | for (int i = 0; i < copiedFields.length; i++) { | |
108 | assertEquals(orignalFields[i], copiedFields[i]); | |
109 | } | |
eb1bab5b BH |
110 | } |
111 | ||
112 | /** | |
113 | * Test Copy Constructor | |
114 | */ | |
115 | public void testEventCopy2() { | |
116 | try { | |
117 | BaseEventInfo info = null; | |
118 | new BaseEventInfo(info); | |
119 | fail("null copy"); | |
120 | } | |
121 | catch (IllegalArgumentException e) { | |
122 | // Success | |
123 | } | |
124 | } | |
b0318660 | 125 | |
eb1bab5b BH |
126 | /** |
127 | * Run the TraceEventType getEventType() method test. | |
128 | * | |
129 | * @throws Exception | |
130 | * | |
131 | */ | |
132 | public void testGetEventType_1() { | |
133 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
134 | fixture.setEventType("unknown"); | |
135 | ||
136 | TraceEventType result = fixture.getEventType(); | |
137 | ||
138 | assertNotNull(result); | |
139 | assertEquals("unknown", result.getInName()); | |
140 | assertEquals("UNKNOWN", result.name()); | |
141 | assertEquals("UNKNOWN", result.toString()); | |
ccc66d01 | 142 | assertEquals(3, result.ordinal()); |
b0318660 | 143 | |
eb1bab5b BH |
144 | fixture.setEventType(""); |
145 | result = fixture.getEventType(); | |
146 | assertEquals("unknown", result.getInName()); | |
147 | assertEquals("UNKNOWN", result.name()); | |
148 | assertEquals("UNKNOWN", result.toString()); | |
ccc66d01 | 149 | assertEquals(3, result.ordinal()); |
b0318660 | 150 | |
eb1bab5b BH |
151 | fixture.setEventType("tracepoint"); |
152 | result = fixture.getEventType(); | |
153 | assertNotNull(result); | |
154 | assertEquals("tracepoint", result.getInName()); | |
155 | assertEquals("TRACEPOINT", result.name()); | |
156 | assertEquals("TRACEPOINT", result.toString()); | |
157 | assertEquals(0, result.ordinal()); | |
b0318660 | 158 | |
ccc66d01 BH |
159 | fixture.setEventType("syscall"); |
160 | result = fixture.getEventType(); | |
161 | assertNotNull(result); | |
162 | assertEquals("syscall", result.getInName()); | |
163 | assertEquals("SYSCALL", result.name()); | |
164 | assertEquals("SYSCALL", result.toString()); | |
165 | assertEquals(1, result.ordinal()); | |
b0318660 | 166 | |
ccc66d01 BH |
167 | fixture.setEventType("probe"); |
168 | result = fixture.getEventType(); | |
169 | assertNotNull(result); | |
170 | assertEquals("probe", result.getInName()); | |
171 | assertEquals("PROBE", result.name()); | |
172 | assertEquals("PROBE", result.toString()); | |
173 | assertEquals(2, result.ordinal()); | |
174 | ||
eb1bab5b BH |
175 | } |
176 | ||
177 | /** | |
178 | * Run the void setEventType(TraceEventType) method test. | |
179 | * | |
180 | */ | |
181 | public void testSetEventType_2() { | |
182 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
183 | fixture.setEventType(TraceEventType.TRACEPOINT); | |
b0318660 | 184 | |
eb1bab5b | 185 | TraceEventType result = fixture.getEventType(); |
b0318660 | 186 | |
eb1bab5b BH |
187 | assertNotNull(result); |
188 | assertEquals("tracepoint", result.getInName()); | |
189 | assertEquals("TRACEPOINT", result.name()); | |
190 | assertEquals("TRACEPOINT", result.toString()); | |
191 | assertEquals(0, result.ordinal()); | |
b0318660 | 192 | |
eb1bab5b BH |
193 | fixture.setEventType(TraceEventType.UNKNOWN); |
194 | result = fixture.getEventType(); | |
b0318660 | 195 | |
eb1bab5b BH |
196 | assertNotNull(result); |
197 | assertEquals("unknown", result.getInName()); | |
198 | assertEquals("UNKNOWN", result.name()); | |
199 | assertEquals("UNKNOWN", result.toString()); | |
ccc66d01 | 200 | assertEquals(3, result.ordinal()); |
b0318660 | 201 | |
ccc66d01 BH |
202 | fixture.setEventType(TraceEventType.SYSCALL); |
203 | result = fixture.getEventType(); | |
204 | assertNotNull(result); | |
205 | assertEquals("syscall", result.getInName()); | |
206 | assertEquals("SYSCALL", result.name()); | |
207 | assertEquals("SYSCALL", result.toString()); | |
208 | assertEquals(1, result.ordinal()); | |
b0318660 | 209 | |
ccc66d01 BH |
210 | fixture.setEventType(TraceEventType.PROBE); |
211 | result = fixture.getEventType(); | |
212 | assertNotNull(result); | |
213 | assertEquals("probe", result.getInName()); | |
214 | assertEquals("PROBE", result.name()); | |
215 | assertEquals("PROBE", result.toString()); | |
9d8a90ad | 216 | assertEquals(2, result.ordinal()); |
ccc66d01 | 217 | |
eb1bab5b | 218 | } |
b0318660 | 219 | |
eb1bab5b BH |
220 | /** |
221 | * Run the void setLogLevel(TraceLogLevel) method test. | |
222 | * Run the TraceLogLevel getLogLevel() method test | |
b0318660 | 223 | * |
eb1bab5b BH |
224 | */ |
225 | public void testSetLogLevel1() { | |
226 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
227 | fixture.setEventType(TraceEventType.TRACEPOINT); | |
228 | fixture.setLogLevel(TraceLogLevel.TRACE_CRIT); | |
b0318660 | 229 | |
eb1bab5b BH |
230 | // 2 set/get-operations are enough to test the method |
231 | TraceLogLevel result = fixture.getLogLevel(); | |
232 | assertNotNull(result); | |
4775bcbf | 233 | assertEquals("TRACE_CRIT", result.getInName()); |
eb1bab5b BH |
234 | assertEquals("TRACE_CRIT", result.name()); |
235 | assertEquals("TRACE_CRIT", result.toString()); | |
236 | assertEquals(2, result.ordinal()); | |
237 | ||
4775bcbf | 238 | fixture.setLogLevel(TraceLogLevel.TRACE_DEBUG_FUNCTION); |
b0318660 | 239 | |
eb1bab5b BH |
240 | result = fixture.getLogLevel(); |
241 | assertNotNull(result); | |
4775bcbf BH |
242 | assertEquals("TRACE_DEBUG_FUNCTION", result.getInName()); |
243 | assertEquals("TRACE_DEBUG_FUNCTION", result.name()); | |
244 | assertEquals("TRACE_DEBUG_FUNCTION", result.toString()); | |
eb1bab5b BH |
245 | assertEquals(12, result.ordinal()); |
246 | } | |
b0318660 | 247 | |
eb1bab5b BH |
248 | /** |
249 | * Run the void setLogLevel(String) method test. | |
250 | * Run the TraceLogLevel getLogLevel() method test | |
b0318660 | 251 | * |
eb1bab5b BH |
252 | */ |
253 | public void testSetLogLevel2() { | |
254 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
255 | fixture.setEventType(TraceEventType.TRACEPOINT); | |
4775bcbf | 256 | fixture.setLogLevel("TRACE_EMERG"); |
b0318660 | 257 | |
eb1bab5b BH |
258 | TraceLogLevel result = fixture.getLogLevel(); |
259 | assertNotNull(result); | |
4775bcbf | 260 | assertEquals("TRACE_EMERG", result.getInName()); |
eb1bab5b BH |
261 | assertEquals("TRACE_EMERG", result.name()); |
262 | assertEquals(0, result.ordinal()); | |
263 | ||
264 | //------------------------ | |
4775bcbf | 265 | fixture.setLogLevel("TRACE_ALERT"); |
b0318660 | 266 | |
eb1bab5b BH |
267 | result = fixture.getLogLevel(); |
268 | assertNotNull(result); | |
4775bcbf | 269 | assertEquals("TRACE_ALERT", result.getInName()); |
eb1bab5b BH |
270 | assertEquals("TRACE_ALERT", result.name()); |
271 | assertEquals(1, result.ordinal()); | |
b0318660 | 272 | |
eb1bab5b | 273 | //------------------------ |
4775bcbf | 274 | fixture.setLogLevel("TRACE_CRIT"); |
b0318660 | 275 | |
eb1bab5b BH |
276 | result = fixture.getLogLevel(); |
277 | assertNotNull(result); | |
4775bcbf | 278 | assertEquals("TRACE_CRIT", result.getInName()); |
eb1bab5b BH |
279 | assertEquals("TRACE_CRIT", result.name()); |
280 | assertEquals(2, result.ordinal()); | |
281 | ||
282 | //------------------------ | |
4775bcbf | 283 | fixture.setLogLevel("TRACE_ERR"); |
b0318660 | 284 | |
eb1bab5b BH |
285 | result = fixture.getLogLevel(); |
286 | assertNotNull(result); | |
4775bcbf | 287 | assertEquals("TRACE_ERR", result.getInName()); |
eb1bab5b BH |
288 | assertEquals("TRACE_ERR", result.name()); |
289 | assertEquals(3, result.ordinal()); | |
290 | ||
291 | //------------------------ | |
4775bcbf | 292 | fixture.setLogLevel("TRACE_WARNING"); |
b0318660 | 293 | |
eb1bab5b BH |
294 | result = fixture.getLogLevel(); |
295 | assertNotNull(result); | |
4775bcbf | 296 | assertEquals("TRACE_WARNING", result.getInName()); |
eb1bab5b BH |
297 | assertEquals("TRACE_WARNING", result.name()); |
298 | assertEquals(4, result.ordinal()); | |
299 | ||
300 | //------------------------ | |
4775bcbf | 301 | fixture.setLogLevel("TRACE_NOTICE"); |
b0318660 | 302 | |
eb1bab5b BH |
303 | result = fixture.getLogLevel(); |
304 | assertNotNull(result); | |
4775bcbf | 305 | assertEquals("TRACE_NOTICE", result.getInName()); |
eb1bab5b BH |
306 | assertEquals("TRACE_NOTICE", result.name()); |
307 | assertEquals(5, result.ordinal()); | |
308 | ||
309 | //------------------------ | |
4775bcbf | 310 | fixture.setLogLevel("TRACE_INFO"); |
b0318660 | 311 | |
eb1bab5b BH |
312 | result = fixture.getLogLevel(); |
313 | assertNotNull(result); | |
4775bcbf | 314 | assertEquals("TRACE_INFO", result.getInName()); |
eb1bab5b BH |
315 | assertEquals("TRACE_INFO", result.name()); |
316 | assertEquals(6, result.ordinal()); | |
317 | ||
318 | //------------------------ | |
4775bcbf | 319 | fixture.setLogLevel("TRACE_DEBUG_SYSTEM"); |
b0318660 | 320 | |
eb1bab5b BH |
321 | result = fixture.getLogLevel(); |
322 | assertNotNull(result); | |
4775bcbf BH |
323 | assertEquals("TRACE_DEBUG_SYSTEM", result.getInName()); |
324 | assertEquals("TRACE_DEBUG_SYSTEM", result.name()); | |
eb1bab5b BH |
325 | assertEquals(7, result.ordinal()); |
326 | ||
327 | //------------------------ | |
4775bcbf | 328 | fixture.setLogLevel("TRACE_DEBUG_PROGRAM"); |
b0318660 | 329 | |
eb1bab5b BH |
330 | result = fixture.getLogLevel(); |
331 | assertNotNull(result); | |
4775bcbf BH |
332 | assertEquals("TRACE_DEBUG_PROGRAM", result.getInName()); |
333 | assertEquals("TRACE_DEBUG_PROGRAM", result.name()); | |
eb1bab5b BH |
334 | assertEquals(8, result.ordinal()); |
335 | ||
336 | //------------------------ | |
4775bcbf | 337 | fixture.setLogLevel("TRACE_DEBUG_PROCESS"); |
b0318660 | 338 | |
eb1bab5b BH |
339 | result = fixture.getLogLevel(); |
340 | assertNotNull(result); | |
4775bcbf BH |
341 | assertEquals("TRACE_DEBUG_PROCESS", result.getInName()); |
342 | assertEquals("TRACE_DEBUG_PROCESS", result.name()); | |
eb1bab5b BH |
343 | assertEquals(9, result.ordinal()); |
344 | ||
345 | //------------------------ | |
4775bcbf | 346 | fixture.setLogLevel("TRACE_DEBUG_MODULE"); |
b0318660 | 347 | |
eb1bab5b BH |
348 | result = fixture.getLogLevel(); |
349 | assertNotNull(result); | |
4775bcbf BH |
350 | assertEquals("TRACE_DEBUG_MODULE", result.getInName()); |
351 | assertEquals("TRACE_DEBUG_MODULE", result.name()); | |
eb1bab5b BH |
352 | assertEquals(10, result.ordinal()); |
353 | ||
354 | //------------------------ | |
4775bcbf | 355 | fixture.setLogLevel("TRACE_DEBUG_UNIT"); |
b0318660 | 356 | |
eb1bab5b BH |
357 | result = fixture.getLogLevel(); |
358 | assertNotNull(result); | |
4775bcbf BH |
359 | assertEquals("TRACE_DEBUG_UNIT", result.getInName()); |
360 | assertEquals("TRACE_DEBUG_UNIT", result.name()); | |
eb1bab5b BH |
361 | assertEquals(11, result.ordinal()); |
362 | ||
363 | //------------------------ | |
4775bcbf | 364 | fixture.setLogLevel("TRACE_DEBUG_FUNCTION"); |
b0318660 | 365 | |
eb1bab5b BH |
366 | result = fixture.getLogLevel(); |
367 | assertNotNull(result); | |
4775bcbf BH |
368 | assertEquals("TRACE_DEBUG_FUNCTION", result.getInName()); |
369 | assertEquals("TRACE_DEBUG_FUNCTION", result.name()); | |
eb1bab5b BH |
370 | assertEquals(12, result.ordinal()); |
371 | ||
372 | //------------------------ | |
4775bcbf | 373 | fixture.setLogLevel("TRACE_DEBUG_LINE"); |
b0318660 | 374 | |
eb1bab5b BH |
375 | result = fixture.getLogLevel(); |
376 | assertNotNull(result); | |
4775bcbf BH |
377 | assertEquals("TRACE_DEBUG_LINE", result.getInName()); |
378 | assertEquals("TRACE_DEBUG_LINE", result.name()); | |
eb1bab5b BH |
379 | assertEquals(13, result.ordinal()); |
380 | ||
381 | //------------------------ | |
4775bcbf | 382 | fixture.setLogLevel("TRACE_DEBUG"); |
b0318660 | 383 | |
eb1bab5b BH |
384 | result = fixture.getLogLevel(); |
385 | assertNotNull(result); | |
4775bcbf BH |
386 | assertEquals("TRACE_DEBUG", result.getInName()); |
387 | assertEquals("TRACE_DEBUG", result.name()); | |
eb1bab5b BH |
388 | assertEquals(14, result.ordinal()); |
389 | ||
4775bcbf BH |
390 | //------------------------- |
391 | fixture.setLogLevel("LEVEL_UNKNOWN"); | |
b0318660 | 392 | |
eb1bab5b BH |
393 | result = fixture.getLogLevel(); |
394 | assertNotNull(result); | |
4775bcbf BH |
395 | assertEquals("LEVEL_UNKNOWN", result.getInName()); |
396 | assertEquals("LEVEL_UNKNOWN", result.name()); | |
eb1bab5b | 397 | assertEquals(15, result.ordinal()); |
b0318660 | 398 | |
4775bcbf | 399 | fixture.setLogLevel("garbage"); |
b0318660 | 400 | |
eb1bab5b BH |
401 | result = fixture.getLogLevel(); |
402 | assertNotNull(result); | |
4775bcbf BH |
403 | assertEquals("TRACE_DEBUG", result.getInName()); |
404 | assertEquals("TRACE_DEBUG", result.name()); | |
405 | assertEquals(14, result.ordinal()); | |
eb1bab5b | 406 | } |
b0318660 | 407 | |
d4514365 BH |
408 | /** |
409 | * test filter expression | |
410 | */ | |
411 | public void testSetFields() { | |
412 | BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); | |
413 | info.setFilterExpression("stringfield==test"); | |
414 | assertEquals("stringfield==test", info.getFilterExpression()); | |
415 | } | |
416 | ||
417 | ||
418 | /** | |
419 | * test add field | |
420 | */ | |
421 | public void testAddField() { | |
422 | BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); | |
423 | ||
424 | IFieldInfo field = new FieldInfo("intfield"); | |
425 | field.setFieldType("int"); | |
426 | ||
427 | info.addField(field); | |
428 | ||
429 | // Verify the stored events | |
430 | IFieldInfo[] result = info.getFields(); | |
431 | ||
432 | assertNotNull(result); | |
433 | assertEquals(1, result.length); | |
434 | assertNotNull(result[0]); | |
435 | assertTrue(field.equals(result[0])); | |
436 | } | |
437 | ||
438 | /** | |
439 | * test set fields | |
440 | */ | |
441 | public void testFields() { | |
442 | BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2); | |
443 | ||
444 | IFieldInfo field1 = new FieldInfo("intfield"); | |
445 | field1.setFieldType("int"); | |
446 | ||
447 | IFieldInfo field2 = new FieldInfo("stringfield"); | |
448 | field2.setFieldType("string"); | |
449 | ||
450 | List<IFieldInfo> fields = new LinkedList<IFieldInfo>(); | |
451 | fields.add(field1); | |
452 | fields.add(field2); | |
453 | info.setFields(fields); | |
454 | ||
455 | // Verify the stored events | |
456 | IFieldInfo[] result = info.getFields(); | |
457 | ||
458 | assertNotNull(result); | |
459 | assertEquals(2, result.length); | |
460 | ||
461 | for (int i = 0; i < result.length; i++) { | |
462 | assertNotNull(result[i]); | |
463 | assertTrue(fields.get(i).equals(result[i])); | |
464 | } | |
465 | } | |
eb1bab5b BH |
466 | |
467 | /** | |
468 | * Run the String toString() method test. | |
469 | * | |
470 | */ | |
471 | public void testToString_1() { | |
472 | BaseEventInfo fixture = new BaseEventInfo("event"); | |
473 | fixture.setName("testName"); | |
474 | fixture.setEventType(TraceEventType.TRACEPOINT); | |
475 | fixture.setLogLevel(TraceLogLevel.TRACE_ERR); | |
476 | ||
477 | String result = fixture.toString(); | |
478 | ||
479 | // add additional test code here | |
480 | assertEquals("[BaseEventInfo([TraceInfo(Name=testName)],type=TRACEPOINT,level=TRACE_ERR)]", result); | |
481 | } | |
482 | ||
483 | // ------------------------------------------------------------------------ | |
484 | // equals | |
485 | // ------------------------------------------------------------------------ | |
486 | ||
487 | public void testEqualsReflexivity() { | |
488 | assertTrue("equals", fEventInfo1.equals(fEventInfo1)); | |
489 | assertTrue("equals", fEventInfo2.equals(fEventInfo2)); | |
490 | ||
491 | assertTrue("equals", !fEventInfo1.equals(fEventInfo2)); | |
492 | assertTrue("equals", !fEventInfo2.equals(fEventInfo1)); | |
493 | } | |
b0318660 | 494 | |
eb1bab5b BH |
495 | public void testEqualsSymmetry() { |
496 | BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
497 | BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2); | |
498 | ||
499 | assertTrue("equals", info1.equals(fEventInfo1)); | |
500 | assertTrue("equals", fEventInfo1.equals(info1)); | |
501 | ||
502 | assertTrue("equals", info2.equals(fEventInfo2)); | |
503 | assertTrue("equals", fEventInfo2.equals(info2)); | |
504 | } | |
b0318660 | 505 | |
eb1bab5b BH |
506 | public void testEqualsTransivity() { |
507 | BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
508 | BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
509 | BaseEventInfo info3 = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
510 | ||
511 | assertTrue("equals", info1.equals(info2)); | |
512 | assertTrue("equals", info2.equals(info3)); | |
513 | assertTrue("equals", info1.equals(info3)); | |
514 | } | |
b0318660 | 515 | |
eb1bab5b BH |
516 | public void testEqualsNull() { |
517 | assertTrue("equals", !fEventInfo1.equals(null)); | |
518 | assertTrue("equals", !fEventInfo2.equals(null)); | |
519 | } | |
b0318660 | 520 | |
eb1bab5b BH |
521 | // ------------------------------------------------------------------------ |
522 | // hashCode | |
523 | // ------------------------------------------------------------------------ | |
524 | ||
525 | public void testHashCode() { | |
526 | BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1); | |
527 | BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2); | |
528 | ||
529 | assertTrue("hashCode", fEventInfo1.hashCode() == info1.hashCode()); | |
530 | assertTrue("hashCode", fEventInfo2.hashCode() == info2.hashCode()); | |
531 | ||
532 | assertTrue("hashCode", fEventInfo1.hashCode() != info2.hashCode()); | |
533 | assertTrue("hashCode", fEventInfo2.hashCode() != info1.hashCode()); | |
534 | } | |
535 | } |