Commit | Line | Data |
---|---|---|
d18dd09b | 1 | /******************************************************************************* |
61759503 | 2 | * Copyright (c) 2009, 2013 Ericsson |
54a7a54c | 3 | * |
d18dd09b ASL |
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 | |
54a7a54c | 8 | * |
d18dd09b ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
39f9eadb | 11 | * Francois Chouinard - Adjusted for new Event Model |
6e1886bc | 12 | * Alexandre Montplaisir - Port to JUnit4 |
d18dd09b ASL |
13 | *******************************************************************************/ |
14 | ||
6c13869b | 15 | package org.eclipse.linuxtools.tmf.core.tests.event; |
d18dd09b | 16 | |
6e1886bc AM |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertFalse; | |
19 | import static org.junit.Assert.assertNotNull; | |
20 | import static org.junit.Assert.assertNull; | |
21 | import static org.junit.Assert.assertTrue; | |
22 | import static org.junit.Assert.fail; | |
23 | ||
39f9eadb FC |
24 | import java.io.File; |
25 | import java.io.IOException; | |
26 | import java.net.URISyntaxException; | |
27 | import java.net.URL; | |
28 | ||
39f9eadb FC |
29 | import org.eclipse.core.runtime.FileLocator; |
30 | import org.eclipse.core.runtime.Path; | |
31 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; | |
4c564a2d | 32 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; |
7b477cc3 | 33 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventType; |
6c13869b | 34 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
4c564a2d | 35 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField; |
6c13869b | 36 | import org.eclipse.linuxtools.tmf.core.event.TmfEventType; |
b4f71e4a | 37 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; |
39f9eadb | 38 | import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; |
9c4d52ee | 39 | import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace; |
3bd46eef | 40 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; |
9b749023 | 41 | import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; |
39f9eadb | 42 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
4918b8f2 | 43 | import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub; |
6e1886bc | 44 | import org.junit.Test; |
d18dd09b ASL |
45 | |
46 | /** | |
cbd4ad82 | 47 | * Test suite for the TmfEvent class. |
d18dd09b | 48 | */ |
cad06250 | 49 | @SuppressWarnings("javadoc") |
6e1886bc | 50 | public class TmfEventTest { |
d18dd09b | 51 | |
39f9eadb FC |
52 | // ------------------------------------------------------------------------ |
53 | // Variables | |
54 | // ------------------------------------------------------------------------ | |
55 | ||
56 | private final String fSource = "Source"; | |
57 | ||
9b749023 | 58 | private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID; |
39f9eadb FC |
59 | private final String fTypeId = "TestType"; |
60 | private final String fLabel1 = "AString"; | |
61 | private final String fLabel2 = "AnInteger"; | |
62 | private final String[] fLabels = new String[] { fLabel1, fLabel2 }; | |
63 | private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels)); | |
64 | ||
65 | private final Object fValue1a = "Some string"; | |
66 | private final Object fValue1b = Integer.valueOf(10); | |
214cc822 AM |
67 | private final ITmfEventField fField1a = new TmfEventField(fLabel1, fValue1a, null); |
68 | private final ITmfEventField fField1b = new TmfEventField(fLabel2, fValue1b, null); | |
39f9eadb FC |
69 | private final ITmfEventField[] fFields1 = new ITmfEventField[] { fField1a, fField1b }; |
70 | private final String fRawContent1 = fField1a.toString() + fField1b.toString(); | |
214cc822 | 71 | private final ITmfEventField fContent1 = new TmfEventField(fRawContent1, null, fFields1); |
39f9eadb FC |
72 | private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, 2, 5); |
73 | private final String fReference1 = "Some reference"; | |
de126dbb | 74 | private final ITmfEvent fEvent1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
39f9eadb FC |
75 | |
76 | private final Object fValue2a = "Another string"; | |
77 | private final Object fValue2b = Integer.valueOf(-4); | |
214cc822 AM |
78 | private final ITmfEventField fField2a = new TmfEventField(fLabel1, fValue2a, null); |
79 | private final ITmfEventField fField2b = new TmfEventField(fLabel2, fValue2b, null); | |
39f9eadb FC |
80 | private final ITmfEventField[] fFields2 = new ITmfEventField[] { fField2a, fField2b }; |
81 | private final String fRawContent2 = fField2a.toString() + fField2b.toString(); | |
214cc822 | 82 | private final ITmfEventField fContent2 = new TmfEventField(fRawContent2, null, fFields2); |
39f9eadb FC |
83 | private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, 2, 5); |
84 | private final String fReference2 = "Some other reference"; | |
de126dbb | 85 | private final ITmfEvent fEvent2 = new TmfEvent(null, 1, fTimestamp2, fSource, fType, fContent2, fReference2); |
39f9eadb | 86 | |
39f9eadb FC |
87 | // ------------------------------------------------------------------------ |
88 | // Helper functions | |
89 | // ------------------------------------------------------------------------ | |
90 | ||
9b749023 | 91 | private static TmfTraceStub openTrace() { |
39f9eadb FC |
92 | TmfTraceStub trace = null; |
93 | try { | |
9c4d52ee | 94 | final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TmfTestTrace.A_TEST_10K.getFullPath()), null); |
085d898f | 95 | final File test = new File(FileLocator.toFileURL(location).toURI()); |
ab186fbb | 96 | trace = new TmfTraceStub(test.toURI().getPath(), 500, false, null); |
b4f71e4a FC |
97 | } catch (final TmfTraceException e) { |
98 | e.printStackTrace(); | |
085d898f | 99 | } catch (final URISyntaxException e) { |
39f9eadb | 100 | e.printStackTrace(); |
085d898f | 101 | } catch (final IOException e) { |
39f9eadb FC |
102 | e.printStackTrace(); |
103 | } | |
104 | return trace; | |
105 | } | |
106 | ||
107 | // ------------------------------------------------------------------------ | |
108 | // Constructors | |
109 | // ------------------------------------------------------------------------ | |
110 | ||
6e1886bc | 111 | @Test |
39f9eadb | 112 | public void testDefaultConstructor() { |
085d898f | 113 | final ITmfEvent event = new TmfEvent(); |
39f9eadb | 114 | assertNull("getTrace", event.getTrace()); |
9b749023 | 115 | assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank()); |
39f9eadb FC |
116 | assertNull("getTimestamp", event.getTimestamp()); |
117 | assertNull("getSource", event.getSource()); | |
118 | assertNull("getType", event.getType()); | |
119 | assertNull("getContent", event.getContent()); | |
120 | assertNull("getReference", event.getReference()); | |
121 | } | |
122 | ||
6e1886bc | 123 | @Test |
39f9eadb FC |
124 | public void testFullConstructor() { |
125 | assertNull("getTrace", fEvent1.getTrace()); | |
126 | assertEquals("getRank", 0, fEvent1.getRank()); | |
127 | assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp()); | |
128 | assertEquals("getSource", fSource, fEvent1.getSource()); | |
129 | assertEquals("getType", fType, fEvent1.getType()); | |
130 | assertEquals("getContent", fContent1, fEvent1.getContent()); | |
131 | assertEquals("getReference", fReference1, fEvent1.getReference()); | |
132 | ||
133 | assertNull("getTrace", fEvent2.getTrace()); | |
134 | assertEquals("getRank", 1, fEvent2.getRank()); | |
135 | assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp()); | |
136 | assertEquals("getSource", fSource, fEvent2.getSource()); | |
137 | assertEquals("getType", fType, fEvent2.getType()); | |
138 | assertEquals("getContent", fContent2, fEvent2.getContent()); | |
139 | assertEquals("getReference", fReference2, fEvent2.getReference()); | |
140 | } | |
141 | ||
6e1886bc | 142 | @Test |
39f9eadb | 143 | public void testNoRankConstructor() { |
2771b032 | 144 | final ITmfEvent event = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference1); |
39f9eadb | 145 | assertNull("getTrace", event.getTrace()); |
9b749023 | 146 | assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank()); |
39f9eadb FC |
147 | assertEquals("getTimestamp", fTimestamp1, event.getTimestamp()); |
148 | assertEquals("getSource", fSource, event.getSource()); | |
149 | assertEquals("getType", fType, event.getType()); | |
150 | assertEquals("getContent", fContent1, event.getContent()); | |
151 | assertEquals("getReference", fReference1, event.getReference()); | |
152 | } | |
153 | ||
6e1886bc | 154 | @Test |
39f9eadb | 155 | public void testConstructorWithTrace() { |
6256d8ad | 156 | final ITmfTrace trace = openTrace(); |
2771b032 | 157 | final ITmfEvent event = new TmfEvent(trace, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
39f9eadb FC |
158 | assertNotNull("getTrace", event.getTrace()); |
159 | assertEquals("getRank", 0, event.getRank()); | |
160 | assertEquals("getTimestamp", fTimestamp1, event.getTimestamp()); | |
161 | assertEquals("getSource", fSource, event.getSource()); | |
162 | assertEquals("getType", fType, event.getType()); | |
163 | assertEquals("getContent", fContent1, event.getContent()); | |
164 | assertEquals("getReference", fReference1, event.getReference()); | |
165 | trace.dispose(); | |
166 | } | |
167 | ||
6e1886bc | 168 | @Test |
39f9eadb | 169 | public void testTmfEventCopy() { |
2771b032 | 170 | final ITmfEvent event = new TmfEvent(fEvent1); |
39f9eadb FC |
171 | assertNull("getTrace", event.getTrace()); |
172 | assertEquals("getRank", 0, event.getRank()); | |
173 | assertEquals("getTimestamp", fTimestamp1, event.getTimestamp()); | |
174 | assertEquals("getSource", fSource, event.getSource()); | |
175 | assertEquals("getType", fType, event.getType()); | |
176 | assertEquals("getContent", fContent1, event.getContent()); | |
177 | assertEquals("getReference", fReference1, event.getReference()); | |
178 | } | |
179 | ||
6e1886bc | 180 | @Test |
54a7a54c | 181 | public void testEventCopy2() { |
39f9eadb FC |
182 | try { |
183 | new TmfEvent(null); | |
184 | fail("null copy"); | |
085d898f | 185 | } catch (final IllegalArgumentException e) { |
39f9eadb FC |
186 | // Success |
187 | } | |
188 | } | |
189 | ||
39f9eadb FC |
190 | // ------------------------------------------------------------------------ |
191 | // hashCode | |
192 | // ------------------------------------------------------------------------ | |
193 | ||
6e1886bc | 194 | @Test |
54a7a54c | 195 | public void testHashCode() { |
2771b032 AM |
196 | ITmfEvent event1 = new TmfEvent(); |
197 | ITmfEvent event2 = new TmfEvent(); | |
085d898f | 198 | |
39f9eadb FC |
199 | assertTrue("hashCode", event1.hashCode() == event2.hashCode()); |
200 | ||
6256d8ad | 201 | final ITmfTrace trace = openTrace(); |
39f9eadb FC |
202 | event1 = new TmfEvent(trace, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
203 | event2 = new TmfEvent(trace, 1, fTimestamp2, fSource, fType, fContent2, fReference2); | |
2771b032 AM |
204 | final ITmfEvent event1b = new TmfEvent(event1); |
205 | final ITmfEvent event2b = new TmfEvent(event2); | |
39f9eadb FC |
206 | |
207 | assertTrue("hashCode", event1.hashCode() == event1b.hashCode()); | |
208 | assertTrue("hashCode", event2.hashCode() == event2b.hashCode()); | |
209 | ||
210 | assertTrue("hashCode", event1.hashCode() != event2.hashCode()); | |
211 | assertTrue("hashCode", event2.hashCode() != event1.hashCode()); | |
085d898f | 212 | |
39f9eadb FC |
213 | trace.dispose(); |
214 | } | |
215 | ||
216 | // ------------------------------------------------------------------------ | |
217 | // equals | |
218 | // ------------------------------------------------------------------------ | |
219 | ||
6e1886bc | 220 | @Test |
54a7a54c | 221 | public void testEqualsReflexivity() { |
39f9eadb FC |
222 | assertTrue("equals", fEvent1.equals(fEvent1)); |
223 | assertTrue("equals", fEvent2.equals(fEvent2)); | |
224 | ||
225 | assertFalse("equals", fEvent1.equals(fEvent2)); | |
226 | assertFalse("equals", fEvent2.equals(fEvent1)); | |
227 | } | |
228 | ||
6e1886bc | 229 | @Test |
54a7a54c | 230 | public void testEqualsSymmetry() { |
2771b032 AM |
231 | final ITmfEvent event1 = new TmfEvent(fEvent1); |
232 | final ITmfEvent event2 = new TmfEvent(fEvent2); | |
39f9eadb FC |
233 | |
234 | assertTrue("equals", event1.equals(fEvent1)); | |
235 | assertTrue("equals", fEvent1.equals(event1)); | |
236 | ||
237 | assertTrue("equals", event2.equals(fEvent2)); | |
238 | assertTrue("equals", fEvent2.equals(event2)); | |
239 | } | |
240 | ||
6e1886bc | 241 | @Test |
54a7a54c | 242 | public void testEqualsTransivity() { |
2771b032 AM |
243 | final ITmfEvent event1 = new TmfEvent(fEvent1); |
244 | final ITmfEvent event2 = new TmfEvent(fEvent1); | |
245 | final ITmfEvent event3 = new TmfEvent(fEvent1); | |
39f9eadb FC |
246 | |
247 | assertTrue("equals", event1.equals(event2)); | |
248 | assertTrue("equals", event2.equals(event3)); | |
249 | assertTrue("equals", event1.equals(event3)); | |
250 | } | |
251 | ||
6e1886bc | 252 | @Test |
54a7a54c | 253 | public void testEqualsNull() { |
39f9eadb FC |
254 | assertFalse("equals", fEvent1.equals(null)); |
255 | assertFalse("equals", fEvent2.equals(null)); | |
256 | } | |
257 | ||
6e1886bc | 258 | @Test |
54a7a54c | 259 | public void testNonEqualClasses() { |
39f9eadb FC |
260 | assertFalse("equals", fEvent1.equals(fEvent1.getType())); |
261 | assertFalse("equals", fEvent1.equals(null)); | |
262 | } | |
085d898f | 263 | |
6e1886bc | 264 | @Test |
54a7a54c | 265 | public void testNonEqualTraces() { |
6256d8ad AM |
266 | final ITmfTrace trace1 = openTrace(); |
267 | final ITmfTrace trace2 = openTrace(); | |
39f9eadb | 268 | |
2771b032 AM |
269 | final ITmfEvent event1 = new TmfEvent(trace1, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
270 | ITmfEvent event2 = new TmfEvent(trace1, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
271 | assertTrue("equals", event1.equals(event2)); |
272 | assertTrue("equals", event2.equals(event1)); | |
273 | ||
274 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
275 | assertFalse("equals", event1.equals(event2)); | |
276 | assertFalse("equals", event2.equals(event1)); | |
085d898f | 277 | |
39f9eadb FC |
278 | event2 = new TmfEvent(trace2, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
279 | assertFalse("equals", event1.equals(event2)); | |
280 | assertFalse("equals", event2.equals(event1)); | |
281 | ||
282 | trace1.dispose(); | |
283 | trace2.dispose(); | |
284 | } | |
085d898f | 285 | |
6e1886bc | 286 | @Test |
54a7a54c | 287 | public void testNonEqualRanks() { |
2771b032 AM |
288 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
289 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
290 | assertTrue("equals", event1.equals(event2)); |
291 | assertTrue("equals", event2.equals(event1)); | |
292 | ||
293 | event2 = new TmfEvent(null, 1, fTimestamp1, fSource, fType, fContent1, fReference1); | |
294 | assertFalse("equals", event1.equals(event2)); | |
295 | assertFalse("equals", event2.equals(event1)); | |
296 | } | |
085d898f | 297 | |
6e1886bc | 298 | @Test |
54a7a54c | 299 | public void testNonEqualTimestamps() { |
2771b032 AM |
300 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
301 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
302 | assertTrue("equals", event1.equals(event2)); |
303 | assertTrue("equals", event2.equals(event1)); | |
304 | ||
305 | event2 = new TmfEvent(null, 0, fTimestamp2, fSource, fType, fContent1, fReference1); | |
306 | assertFalse("equals", event1.equals(event2)); | |
307 | assertFalse("equals", event2.equals(event1)); | |
308 | ||
309 | event2 = new TmfEvent(null, 0, null, fSource, fType, fContent1, fReference1); | |
310 | assertFalse("equals", event1.equals(event2)); | |
311 | assertFalse("equals", event2.equals(event1)); | |
312 | } | |
085d898f | 313 | |
6e1886bc | 314 | @Test |
54a7a54c | 315 | public void testNonEqualSources() { |
2771b032 AM |
316 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
317 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
318 | assertTrue("equals", event1.equals(event2)); |
319 | assertTrue("equals", event2.equals(event1)); | |
320 | ||
321 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource + "x", fType, fContent1, fReference1); | |
322 | assertFalse("equals", event1.equals(event2)); | |
323 | assertFalse("equals", event2.equals(event1)); | |
324 | ||
325 | event2 = new TmfEvent(null, 0, fTimestamp1, null, fType, fContent1, fReference1); | |
326 | assertFalse("equals", event1.equals(event2)); | |
327 | assertFalse("equals", event2.equals(event1)); | |
328 | } | |
085d898f | 329 | |
6e1886bc | 330 | @Test |
54a7a54c | 331 | public void testNonEqualTypes() { |
2771b032 AM |
332 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
333 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
334 | assertTrue("equals", event1.equals(event2)); |
335 | assertTrue("equals", event2.equals(event1)); | |
336 | ||
085d898f FC |
337 | final String typeId = "OtherTestType"; |
338 | final String[] labels = new String[] { fLabel2, fLabel1 }; | |
339 | final TmfEventType newType = new TmfEventType(fContext, typeId, TmfEventField.makeRoot(labels)); | |
39f9eadb FC |
340 | |
341 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, newType, fContent1, fReference1); | |
342 | assertFalse("equals", event1.equals(event2)); | |
343 | assertFalse("equals", event2.equals(event1)); | |
344 | ||
345 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, null, fContent1, fReference1); | |
346 | assertFalse("equals", event1.equals(event2)); | |
347 | assertFalse("equals", event2.equals(event1)); | |
348 | } | |
085d898f | 349 | |
6e1886bc | 350 | @Test |
54a7a54c | 351 | public void testNonEqualContents() { |
2771b032 AM |
352 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
353 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
354 | assertTrue("equals", event1.equals(event2)); |
355 | assertTrue("equals", event2.equals(event1)); | |
356 | ||
357 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent2, fReference1); | |
358 | assertFalse("equals", event1.equals(event2)); | |
359 | assertFalse("equals", event2.equals(event1)); | |
360 | ||
361 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, null, fReference1); | |
362 | assertFalse("equals", event1.equals(event2)); | |
363 | assertFalse("equals", event2.equals(event1)); | |
364 | } | |
085d898f | 365 | |
6e1886bc | 366 | @Test |
54a7a54c | 367 | public void testNonEqualReferences() { |
2771b032 AM |
368 | final ITmfEvent event1 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); |
369 | ITmfEvent event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference1); | |
39f9eadb FC |
370 | assertTrue("equals", event1.equals(event2)); |
371 | assertTrue("equals", event2.equals(event1)); | |
372 | ||
373 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, fReference2); | |
374 | assertFalse("equals", event1.equals(event2)); | |
375 | assertFalse("equals", event2.equals(event1)); | |
376 | ||
377 | event2 = new TmfEvent(null, 0, fTimestamp1, fSource, fType, fContent1, null); | |
378 | assertFalse("equals", event1.equals(event2)); | |
379 | assertFalse("equals", event2.equals(event1)); | |
380 | } | |
085d898f | 381 | |
39f9eadb FC |
382 | // ------------------------------------------------------------------------ |
383 | // toString | |
384 | // ------------------------------------------------------------------------ | |
385 | ||
6e1886bc | 386 | @Test |
39f9eadb | 387 | public void testToString() { |
085d898f | 388 | final String expected1 = "TmfEvent [fTimestamp=" + fTimestamp1 + ", fTrace=null, fRank=0, fSource=" + fSource |
39f9eadb FC |
389 | + ", fType=" + fType + ", fContent=" + fContent1 + ", fReference=" + fReference1 + "]"; |
390 | assertEquals("toString", expected1, fEvent1.toString()); | |
391 | ||
085d898f | 392 | final String expected2 = "TmfEvent [fTimestamp=" + fTimestamp2 + ", fTrace=null, fRank=1, fSource=" + fSource |
39f9eadb FC |
393 | + ", fType=" + fType + ", fContent=" + fContent2 + ", fReference=" + fReference2 + "]"; |
394 | assertEquals("toString", expected2, fEvent2.toString()); | |
395 | } | |
d18dd09b | 396 | |
bd54d363 AM |
397 | /** |
398 | * Test the .toString() with extended classes. | |
399 | * It should print the correct class name. | |
400 | */ | |
401 | @Test | |
402 | public void testToStringExtended() { | |
403 | class ExtendedEvent extends TmfEvent { | |
404 | ExtendedEvent(ITmfEvent event) { | |
405 | super(event); | |
406 | } | |
407 | } | |
408 | ExtendedEvent event = new ExtendedEvent(fEvent1); | |
409 | String expected = "ExtendedEvent [fTimestamp=" + fTimestamp1 | |
410 | + ", fTrace=null, fRank=0, fSource=" + fSource | |
411 | + ", fType=" + fType + ", fContent=" + fContent1 | |
412 | + ", fReference=" + fReference1 + "]"; | |
413 | ||
414 | assertEquals(expected, event.toString()); | |
415 | } | |
416 | ||
d18dd09b | 417 | } |