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
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
16 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
17 import org
.junit
.After
;
18 import org
.junit
.Before
;
19 import org
.junit
.Test
;
22 * The class <code>EventDeclarationTest</code> contains tests for the class
23 * <code>{@link EventDeclaration}</code>.
26 * @version $Revision: 1.0 $
28 @SuppressWarnings("javadoc")
29 public class EventDeclarationTest
{
31 private EventDeclaration fixture
;
37 * the command line arguments
39 public static void main(String
[] args
) {
40 new org
.junit
.runner
.JUnitCore().run(EventDeclarationTest
.class);
44 * Perform pre-test initialization.
46 * @throws CTFReaderException
49 public void setUp() throws CTFReaderException
{
50 fixture
= new EventDeclaration();
51 fixture
.setContext(new StructDeclaration(1L));
53 fixture
.setFields(new StructDeclaration(1L));
54 fixture
.setStream(new Stream(TestParams
.createTrace()));
55 fixture
.setName(""); //$NON-NLS-1$
59 * Perform post-test clean-up.
62 public void tearDown() {
63 // Add additional tear down code here
67 * Run the EventDeclaration() constructor test.
70 public void testEventDeclaration() {
71 EventDeclaration result
= new EventDeclaration();
72 assertNotNull(result
);
76 * Run the boolean contextIsSet() method test.
79 public void testContextIsSet() {
80 boolean result
= fixture
.contextIsSet();
85 * Run the boolean contextIsSet() method test.
88 public void testContextIsSet_null() {
89 fixture
.setContext((StructDeclaration
) null);
91 boolean result
= fixture
.contextIsSet();
96 * Run the boolean equals(Object) method test.
98 * @throws CTFReaderException
101 public void testEquals() throws CTFReaderException
{
102 EventDeclaration obj
= new EventDeclaration();
103 obj
.setContext(new StructDeclaration(1L));
105 obj
.setFields(new StructDeclaration(1L));
106 obj
.setStream(new Stream(TestParams
.createTrace()));
107 obj
.setName(""); //$NON-NLS-1$
109 assertTrue(fixture
.equals(fixture
));
110 boolean result
= fixture
.equals(obj
);
115 * Run the boolean equals(Object) method test.
118 public void testEquals_null() {
121 boolean result
= fixture
.equals(obj
);
126 * Run the boolean equals(Object) method test.
129 public void testEquals_emptyObject() {
130 Object obj
= new Object();
132 boolean result
= fixture
.equals(obj
);
137 * Run the boolean equals(Object) method test.
140 public void testEquals_other1() {
141 EventDeclaration obj
= new EventDeclaration();
142 obj
.setContext(fixture
.getContext());
144 boolean result
= fixture
.equals(obj
);
149 * Run the boolean equals(Object) method test.
152 public void testEquals_other2() {
153 EventDeclaration obj
= new EventDeclaration();
154 obj
.setContext(new StructDeclaration(1L));
155 obj
.setFields(new StructDeclaration(1L));
157 boolean result
= fixture
.equals(obj
);
162 * Run the boolean equals(Object) method test.
165 public void testEquals_other3() {
166 EventDeclaration obj
= new EventDeclaration();
167 obj
.setContext(new StructDeclaration(1L));
169 obj
.setFields(new StructDeclaration(1L));
171 boolean result
= fixture
.equals(obj
);
176 * Run the boolean equals(Object) method test.
179 public void testEquals_other4() {
180 EventDeclaration obj
= new EventDeclaration();
181 obj
.setContext(new StructDeclaration(1L));
183 obj
.setFields(new StructDeclaration(1L));
184 obj
.setName(""); //$NON-NLS-1$
186 boolean result
= fixture
.equals(obj
);
191 * Run the boolean fieldsIsSet() method test.
194 public void testFieldsIsSet() {
195 boolean result
= fixture
.fieldsIsSet();
200 * Run the boolean fieldsIsSet() method test.
203 public void testFieldsIsSet_null() {
204 fixture
.setFields((StructDeclaration
) null);
206 boolean result
= fixture
.fieldsIsSet();
211 * Run the StructDeclaration getFields() method test.
214 public void testGetFields() {
215 StructDeclaration result
= fixture
.getFields();
216 assertNotNull(result
);
220 * Run the Long getId() method test.
223 public void testGetId() {
224 Long result
= fixture
.getId();
225 assertNotNull(result
);
229 * Run the String getName() method test.
232 public void testGetName() {
233 String result
= fixture
.getName();
234 assertNotNull(result
);
238 * Run the Stream getStream() method test.
241 public void testGetStream() {
242 Stream result
= fixture
.getStream();
243 assertNotNull(result
);
247 * Run the int hashCode() method test.
250 public void testHashCode() {
251 int result
= fixture
.hashCode();
252 assertTrue(0 != result
);
256 * Run the int hashCode() method test.
259 public void testHashCode_null() {
260 fixture
.setStream((Stream
) null);
261 fixture
.setName((String
) null);
263 int result
= fixture
.hashCode();
264 assertTrue(0 != result
);
268 * Run the boolean idIsSet() method test.
271 public void testIdIsSet() {
272 boolean result
= fixture
.idIsSet();
277 * Run the boolean nameIsSet() method test.
280 public void testNameIsSet() {
281 boolean result
= fixture
.nameIsSet();
286 * Run the boolean nameIsSet() method test.
289 public void testNameIsSet_null() {
290 fixture
.setName((String
) null);
292 boolean result
= fixture
.nameIsSet();
297 * Run the boolean streamIsSet() method test.
300 public void testStreamIsSet() {
301 boolean result
= fixture
.streamIsSet();
306 * Run the boolean streamIsSet() method test.
309 public void testStreamIsSet_null() {
310 fixture
.setStream((Stream
) null);
312 boolean result
= fixture
.streamIsSet();
313 assertEquals(false, result
);
317 * Test for the EventDefinition class
319 * @throws CTFReaderException
322 public void testEventDefinition() throws CTFReaderException
{
323 CTFTrace trace
= TestParams
.createTrace();
324 CTFTraceReader tr
= new CTFTraceReader(trace
);
326 EventDefinition ed
= new EventDefinition(null, null);
327 ed
= tr
.getCurrentEventDef();
329 assertNotNull(ed
.getPath());
330 assertNotNull(ed
.getDeclaration());
331 assertNotNull(ed
.getFields());
332 assertNull(ed
.getContext());
333 assertNotNull(ed
.getPacketContext());
334 assertNotNull(ed
.getCPU());
335 assertNotNull(ed
.getPacketContext());
336 assertNotNull(ed
.getStreamInputReader());
337 assertNull(ed
.lookupDefinition("context")); //$NON-NLS-1$
338 assertNotNull(ed
.lookupDefinition("fields")); //$NON-NLS-1$
339 assertNull(ed
.lookupDefinition("other")); //$NON-NLS-1$
340 assertNotNull(ed
.toString());
341 ed
.setContext( ed
.getFields());
342 assertNotNull(ed
.toString());
350 public void testEquals1(){
351 e1
= new EventDeclaration();
352 assertFalse(e1
.equals(null));
356 public void testEquals2(){
357 e1
= EventDeclaration
.getLostEventDeclaration();
358 assertFalse(e1
.equals(new Long(23L)));
362 public void testEquals3(){
363 e1
= EventDeclaration
.getLostEventDeclaration();
368 public void testEquals4(){
369 e1
= EventDeclaration
.getLostEventDeclaration();
370 e2
= EventDeclaration
.getLostEventDeclaration();
375 public void testEquals5(){
376 e1
= EventDeclaration
.getLostEventDeclaration();
377 e2
= new EventDeclaration();
378 assertFalse(e1
.equals(e2
));
This page took 0.039669 seconds and 6 git commands to generate.