1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertFalse
;
5 import static org
.junit
.Assert
.assertNotNull
;
6 import static org
.junit
.Assert
.assertNull
;
7 import static org
.junit
.Assert
.assertTrue
;
8 import static org
.junit
.Assume
.assumeTrue
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTraces
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
17 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
18 import org
.junit
.After
;
19 import org
.junit
.Before
;
20 import org
.junit
.Test
;
23 * The class <code>EventDeclarationTest</code> contains tests for the class
24 * <code>{@link EventDeclaration}</code>.
27 * @version $Revision: 1.0 $
29 @SuppressWarnings("javadoc")
30 public class EventDeclarationTest
{
32 private static final int TRACE_INDEX
= 0;
34 private EventDeclaration fixture
;
40 * the command line arguments
42 public static void main(String
[] args
) {
43 new org
.junit
.runner
.JUnitCore().run(EventDeclarationTest
.class);
47 * Perform pre-test initialization.
49 * @throws CTFReaderException
52 public void setUp() throws CTFReaderException
{
53 assumeTrue(CtfTestTraces
.tracesExist());
54 fixture
= new EventDeclaration();
55 fixture
.setContext(new StructDeclaration(1L));
57 fixture
.setFields(new StructDeclaration(1L));
58 fixture
.setStream(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)));
59 fixture
.setName(""); //$NON-NLS-1$
63 * Perform post-test clean-up.
66 public void tearDown() {
67 // Add additional tear down code here
71 * Run the EventDeclaration() constructor test.
74 public void testEventDeclaration() {
75 EventDeclaration result
= new EventDeclaration();
76 assertNotNull(result
);
80 * Run the boolean contextIsSet() method test.
83 public void testContextIsSet() {
84 boolean result
= fixture
.contextIsSet();
89 * Run the boolean contextIsSet() method test.
92 public void testContextIsSet_null() {
93 fixture
.setContext((StructDeclaration
) null);
95 boolean result
= fixture
.contextIsSet();
100 * Run the boolean equals(Object) method test.
102 * @throws CTFReaderException
105 public void testEquals() throws CTFReaderException
{
106 EventDeclaration obj
= new EventDeclaration();
107 obj
.setContext(new StructDeclaration(1L));
109 obj
.setFields(new StructDeclaration(1L));
110 obj
.setStream(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)));
111 obj
.setName(""); //$NON-NLS-1$
113 assertTrue(fixture
.equals(fixture
));
114 boolean result
= fixture
.equals(obj
);
119 * Run the boolean equals(Object) method test.
122 public void testEquals_null() {
125 boolean result
= fixture
.equals(obj
);
130 * Run the boolean equals(Object) method test.
133 public void testEquals_emptyObject() {
134 Object obj
= new Object();
136 boolean result
= fixture
.equals(obj
);
141 * Run the boolean equals(Object) method test.
144 public void testEquals_other1() {
145 EventDeclaration obj
= new EventDeclaration();
146 obj
.setContext(fixture
.getContext());
148 boolean result
= fixture
.equals(obj
);
153 * Run the boolean equals(Object) method test.
156 public void testEquals_other2() {
157 EventDeclaration obj
= new EventDeclaration();
158 obj
.setContext(new StructDeclaration(1L));
159 obj
.setFields(new StructDeclaration(1L));
161 boolean result
= fixture
.equals(obj
);
166 * Run the boolean equals(Object) method test.
169 public void testEquals_other3() {
170 EventDeclaration obj
= new EventDeclaration();
171 obj
.setContext(new StructDeclaration(1L));
173 obj
.setFields(new StructDeclaration(1L));
175 boolean result
= fixture
.equals(obj
);
180 * Run the boolean equals(Object) method test.
183 public void testEquals_other4() {
184 EventDeclaration obj
= new EventDeclaration();
185 obj
.setContext(new StructDeclaration(1L));
187 obj
.setFields(new StructDeclaration(1L));
188 obj
.setName(""); //$NON-NLS-1$
190 boolean result
= fixture
.equals(obj
);
195 * Run the boolean fieldsIsSet() method test.
198 public void testFieldsIsSet() {
199 boolean result
= fixture
.fieldsIsSet();
204 * Run the boolean fieldsIsSet() method test.
207 public void testFieldsIsSet_null() {
208 fixture
.setFields((StructDeclaration
) null);
210 boolean result
= fixture
.fieldsIsSet();
215 * Run the StructDeclaration getFields() method test.
218 public void testGetFields() {
219 StructDeclaration result
= fixture
.getFields();
220 assertNotNull(result
);
224 * Run the Long getId() method test.
227 public void testGetId() {
228 Long result
= fixture
.getId();
229 assertNotNull(result
);
233 * Run the String getName() method test.
236 public void testGetName() {
237 String result
= fixture
.getName();
238 assertNotNull(result
);
242 * Run the Stream getStream() method test.
245 public void testGetStream() {
246 Stream result
= fixture
.getStream();
247 assertNotNull(result
);
251 * Run the int hashCode() method test.
254 public void testHashCode() {
255 int result
= fixture
.hashCode();
256 assertTrue(0 != result
);
260 * Run the int hashCode() method test.
263 public void testHashCode_null() {
264 fixture
.setStream((Stream
) null);
265 fixture
.setName((String
) null);
267 int result
= fixture
.hashCode();
268 assertTrue(0 != result
);
272 * Run the boolean idIsSet() method test.
275 public void testIdIsSet() {
276 boolean result
= fixture
.idIsSet();
281 * Run the boolean nameIsSet() method test.
284 public void testNameIsSet() {
285 boolean result
= fixture
.nameIsSet();
290 * Run the boolean nameIsSet() method test.
293 public void testNameIsSet_null() {
294 fixture
.setName((String
) null);
296 boolean result
= fixture
.nameIsSet();
301 * Run the boolean streamIsSet() method test.
304 public void testStreamIsSet() {
305 boolean result
= fixture
.streamIsSet();
310 * Run the boolean streamIsSet() method test.
313 public void testStreamIsSet_null() {
314 fixture
.setStream((Stream
) null);
316 boolean result
= fixture
.streamIsSet();
317 assertEquals(false, result
);
321 * Test for the EventDefinition class
323 * @throws CTFReaderException
326 public void testEventDefinition() throws CTFReaderException
{
327 CTFTrace trace
= CtfTestTraces
.getTestTrace(TRACE_INDEX
);
328 CTFTraceReader tr
= new CTFTraceReader(trace
);
330 EventDefinition ed
= new EventDefinition(null, null);
331 ed
= tr
.getCurrentEventDef();
333 assertNotNull(ed
.getPath());
334 assertNotNull(ed
.getDeclaration());
335 assertNotNull(ed
.getFields());
336 assertNull(ed
.getContext());
337 assertNotNull(ed
.getPacketContext());
338 assertNotNull(ed
.getCPU());
339 assertNotNull(ed
.getPacketContext());
340 assertNotNull(ed
.getStreamInputReader());
341 assertNull(ed
.lookupDefinition("context")); //$NON-NLS-1$
342 assertNotNull(ed
.lookupDefinition("fields")); //$NON-NLS-1$
343 assertNull(ed
.lookupDefinition("other")); //$NON-NLS-1$
344 assertNotNull(ed
.toString());
345 ed
.setContext( ed
.getFields());
346 assertNotNull(ed
.toString());
354 public void testEquals1(){
355 e1
= new EventDeclaration();
356 assertFalse(e1
.equals(null));
360 public void testEquals2(){
361 e1
= EventDeclaration
.getLostEventDeclaration();
362 assertFalse(e1
.equals(new Long(23L)));
366 public void testEquals3(){
367 e1
= EventDeclaration
.getLostEventDeclaration();
372 public void testEquals4(){
373 e1
= EventDeclaration
.getLostEventDeclaration();
374 e2
= EventDeclaration
.getLostEventDeclaration();
379 public void testEquals5(){
380 e1
= EventDeclaration
.getLostEventDeclaration();
381 e2
= new EventDeclaration();
382 assertFalse(e1
.equals(e2
));
This page took 0.039975 seconds and 6 git commands to generate.