1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
14 import static org
.junit
.Assert
.assertEquals
;
15 import static org
.junit
.Assert
.assertFalse
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertNull
;
18 import static org
.junit
.Assert
.assertTrue
;
19 import static org
.junit
.Assume
.assumeTrue
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTrace
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
25 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
26 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
27 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
28 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
33 * The class <code>EventDeclarationTest</code> contains tests for the class
34 * <code>{@link EventDeclaration}</code>.
37 * @version $Revision: 1.0 $
39 @SuppressWarnings("javadoc")
40 public class EventDeclarationTest
{
42 private static final CtfTestTrace testTrace
= CtfTestTrace
.KERNEL
;
44 private EventDeclaration fixture
;
47 * Perform pre-test initialization.
49 * @throws CTFReaderException
52 public void setUp() throws CTFReaderException
{
53 assumeTrue(testTrace
.exists());
54 fixture
= new EventDeclaration();
55 fixture
.setContext(new StructDeclaration(1L));
57 fixture
.setFields(new StructDeclaration(1L));
58 fixture
.setStream(new Stream(testTrace
.getTrace()));
63 * Run the EventDeclaration() constructor test.
66 public void testEventDeclaration() {
67 EventDeclaration result
= new EventDeclaration();
68 assertNotNull(result
);
72 * Run the boolean contextIsSet() method test.
75 public void testContextIsSet() {
76 boolean result
= fixture
.contextIsSet();
81 * Run the boolean contextIsSet() method test.
84 public void testContextIsSet_null() {
85 fixture
.setContext((StructDeclaration
) null);
87 boolean result
= fixture
.contextIsSet();
92 * Run the boolean equals(Object) method test.
94 * @throws CTFReaderException
97 public void testEquals() throws CTFReaderException
{
98 EventDeclaration obj
= new EventDeclaration();
99 obj
.setContext(new StructDeclaration(1L));
101 obj
.setFields(new StructDeclaration(1L));
102 obj
.setStream(new Stream(testTrace
.getTrace()));
105 assertTrue(fixture
.equals(fixture
));
106 boolean result
= fixture
.equals(obj
);
111 * Run the boolean equals(Object) method test.
114 public void testEquals_null() {
117 boolean result
= fixture
.equals(obj
);
122 * Run the boolean equals(Object) method test.
125 public void testEquals_emptyObject() {
126 Object obj
= new Object();
128 boolean result
= fixture
.equals(obj
);
133 * Run the boolean equals(Object) method test.
136 public void testEquals_other1() {
137 EventDeclaration obj
= new EventDeclaration();
138 obj
.setContext(fixture
.getContext());
140 boolean result
= fixture
.equals(obj
);
145 * Run the boolean equals(Object) method test.
148 public void testEquals_other2() {
149 EventDeclaration obj
= new EventDeclaration();
150 obj
.setContext(new StructDeclaration(1L));
151 obj
.setFields(new StructDeclaration(1L));
153 boolean result
= fixture
.equals(obj
);
158 * Run the boolean equals(Object) method test.
161 public void testEquals_other3() {
162 EventDeclaration obj
= new EventDeclaration();
163 obj
.setContext(new StructDeclaration(1L));
165 obj
.setFields(new StructDeclaration(1L));
167 boolean result
= fixture
.equals(obj
);
172 * Run the boolean equals(Object) method test.
175 public void testEquals_other4() {
176 EventDeclaration obj
= new EventDeclaration();
177 obj
.setContext(new StructDeclaration(1L));
179 obj
.setFields(new StructDeclaration(1L));
182 boolean result
= fixture
.equals(obj
);
187 * Run the boolean fieldsIsSet() method test.
190 public void testFieldsIsSet() {
191 boolean result
= fixture
.fieldsIsSet();
196 * Run the boolean fieldsIsSet() method test.
199 public void testFieldsIsSet_null() {
200 fixture
.setFields((StructDeclaration
) null);
202 boolean result
= fixture
.fieldsIsSet();
207 * Run the StructDeclaration getFields() method test.
210 public void testGetFields() {
211 StructDeclaration result
= fixture
.getFields();
212 assertNotNull(result
);
216 * Run the Long getId() method test.
219 public void testGetId() {
220 Long result
= fixture
.getId();
221 assertNotNull(result
);
225 * Run the String getName() method test.
228 public void testGetName() {
229 String result
= fixture
.getName();
230 assertNotNull(result
);
234 * Run the Stream getStream() method test.
237 public void testGetStream() {
238 Stream result
= fixture
.getStream();
239 assertNotNull(result
);
243 * Run the int hashCode() method test.
246 public void testHashCode() {
247 int result
= fixture
.hashCode();
248 assertTrue(0 != result
);
252 * Run the int hashCode() method test.
255 public void testHashCode_null() {
256 fixture
.setStream((Stream
) null);
257 fixture
.setName((String
) null);
259 int result
= fixture
.hashCode();
260 assertTrue(0 != result
);
264 * Run the boolean idIsSet() method test.
267 public void testIdIsSet() {
268 boolean result
= fixture
.idIsSet();
273 * Run the boolean nameIsSet() method test.
276 public void testNameIsSet() {
277 boolean result
= fixture
.nameIsSet();
282 * Run the boolean nameIsSet() method test.
285 public void testNameIsSet_null() {
286 fixture
.setName((String
) null);
288 boolean result
= fixture
.nameIsSet();
293 * Run the boolean streamIsSet() method test.
296 public void testStreamIsSet() {
297 boolean result
= fixture
.streamIsSet();
302 * Run the boolean streamIsSet() method test.
305 public void testStreamIsSet_null() {
306 fixture
.setStream((Stream
) null);
308 boolean result
= fixture
.streamIsSet();
309 assertEquals(false, result
);
313 * Test for the EventDefinition class
315 * @throws CTFReaderException
318 public void testEventDefinition() throws CTFReaderException
{
319 CTFTrace trace
= testTrace
.getTrace();
320 CTFTraceReader tr
= new CTFTraceReader(trace
);
322 EventDefinition ed
= new EventDefinition(null, null);
323 ed
= tr
.getCurrentEventDef();
325 assertNotNull(ed
.getPath());
326 assertNotNull(ed
.getDeclaration());
327 assertNotNull(ed
.getFields());
328 assertNull(ed
.getContext());
329 assertNotNull(ed
.getPacketContext());
330 assertNotNull(ed
.getCPU());
331 assertNotNull(ed
.getPacketContext());
332 assertNotNull(ed
.getStreamInputReader());
333 assertNull(ed
.lookupDefinition("context"));
334 assertNotNull(ed
.lookupDefinition("fields"));
335 assertNull(ed
.lookupDefinition("other"));
336 assertNotNull(ed
.toString());
337 ed
.setContext( ed
.getFields());
338 assertNotNull(ed
.toString());
346 public void testEquals1(){
347 e1
= new EventDeclaration();
348 assertFalse(e1
.equals(null));
352 public void testEquals2(){
353 e1
= EventDeclaration
.getLostEventDeclaration();
354 assertFalse(e1
.equals(new Long(23L)));
358 public void testEquals3(){
359 e1
= EventDeclaration
.getLostEventDeclaration();
364 public void testEquals4(){
365 e1
= EventDeclaration
.getLostEventDeclaration();
366 e2
= EventDeclaration
.getLostEventDeclaration();
371 public void testEquals5(){
372 e1
= EventDeclaration
.getLostEventDeclaration();
373 e2
= new EventDeclaration();
374 assertFalse(e1
.equals(e2
));
This page took 0.038826 seconds and 6 git commands to generate.