1 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
3 import static org
.junit
.Assert
.*;
5 import java
.io
.FileNotFoundException
;
7 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfIterator
;
8 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
9 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
10 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
11 import org
.junit
.After
;
12 import org
.junit
.Before
;
13 import org
.junit
.Test
;
16 * The class <code>CTFEventTest</code> contains tests for the class
17 * <code>{@link CTFEvent}</code>.
20 * @version $Revision: 1.0 $
22 public class CtfTmfEventTest
{
24 private CtfTmfEvent fixture
;
30 * the command line arguments
32 public static void main(String
[] args
) {
33 new org
.junit
.runner
.JUnitCore().run(CtfTmfEventTest
.class);
37 * Perform pre-test initialization.
39 * @throws FileNotFoundException
42 public void setUp() throws FileNotFoundException
{
43 CtfTmfTrace trace
= TestParams
.createTrace();
44 CtfIterator tr
= new CtfIterator(trace
);
46 fixture
= tr
.getCurrentEvent();
50 * Perform post-test clean-up.
53 public void tearDown() {
54 // Add additional tear down code here
58 * Run the CTFEvent(EventDefinition,StreamInputReader) constructor test.
61 public void testCTFEvent_read() {
62 assertNotNull(fixture
);
66 * Run the int getCPU() method test.
69 public void testGetCPU() {
70 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
71 int result
= nullEvent
.getCPU();
73 assertEquals(-1, result
);
77 * Run the String getChannelName() method test.
80 public void testGetChannelName() {
81 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
82 String result
= nullEvent
.getChannelName();
84 assertEquals("No stream", result
); //$NON-NLS-1$
88 * Run the String getEventName() method test.
91 public void testGetEventName() {
92 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
93 String result
= nullEvent
.getEventName();
95 assertEquals("Empty CTF event", result
); //$NON-NLS-1$
99 * Run the ArrayList<String> getFieldNames() method test.
102 public void testGetFieldNames() {
103 String
[] result
= fixture
.getContent().getFieldNames();
104 assertNotNull(result
);
108 * Run the Object getFieldValue(String) method test.
111 public void testGetFieldValue() {
112 String fieldName
= "id"; //$NON-NLS-1$
113 Object result
= fixture
.getContent().getField(fieldName
).getValue();
115 assertNotNull(result
);
119 * Run the HashMap<String, CTFEventField> getFields() method test.
122 public void testGetFields() {
123 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
124 ITmfEventField
[] fields
= nullEvent
.getContent().getFields();
126 assertArrayEquals(null, fields
);
130 * Run the long getID() method test.
133 public void testGetID() {
134 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
135 long result
= nullEvent
.getID();
137 assertEquals(-1L, result
);
142 * Run the CTFEvent getNullEvent() method test.
145 public void testGetNullEvent() {
146 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
148 assertNotNull(nullEvent
);
149 assertEquals(-1, nullEvent
.getCPU());
150 assertEquals("Empty CTF event", nullEvent
.getEventName()); //$NON-NLS-1$
151 assertEquals("No stream", nullEvent
.getChannelName()); //$NON-NLS-1$
152 assertArrayEquals(null, nullEvent
.getContent().getFields());
153 assertEquals(-1L, nullEvent
.getID());
154 assertEquals(-1L, nullEvent
.getTimestampValue());
158 * Run the long getTimestamp() method test.
162 public void testGetTimestamp() {
163 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
164 long result
= nullEvent
.getTimestampValue();
166 assertEquals(-1L, result
);
This page took 0.045972 seconds and 6 git commands to generate.