1 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
3 import static org
.junit
.Assert
.assertArrayEquals
;
4 import static org
.junit
.Assert
.assertEquals
;
5 import static org
.junit
.Assert
.assertNotNull
;
7 import java
.io
.FileNotFoundException
;
9 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfIterator
;
10 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
11 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
12 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
13 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
14 import org
.junit
.After
;
15 import org
.junit
.Before
;
16 import org
.junit
.Test
;
19 * The class <code>CTFEventTest</code> contains tests for the class
20 * <code>{@link CTFEvent}</code>.
23 * @version $Revision: 1.0 $
25 public class CtfTmfEventTest
{
27 private CtfTmfEvent fixture
;
33 * the command line arguments
35 public static void main(String
[] args
) {
36 new org
.junit
.runner
.JUnitCore().run(CtfTmfEventTest
.class);
40 * Perform pre-test initialization.
42 * @throws FileNotFoundException
45 public void setUp() throws TmfTraceException
{
46 CtfTmfTrace trace
= TestParams
.createTrace();
47 CtfIterator tr
= new CtfIterator(trace
);
49 fixture
= tr
.getCurrentEvent();
53 * Perform post-test clean-up.
56 public void tearDown() {
57 // Add additional tear down code here
61 * Run the CTFEvent(EventDefinition,StreamInputReader) constructor test.
64 public void testCTFEvent_read() {
65 assertNotNull(fixture
);
69 * Run the int getCPU() method test.
72 public void testGetCPU() {
73 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
74 int result
= nullEvent
.getCPU();
76 assertEquals(-1, result
);
80 * Run the String getChannelName() method test.
83 public void testGetChannelName() {
84 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
85 String result
= nullEvent
.getChannelName();
87 assertEquals("No stream", result
); //$NON-NLS-1$
91 * Run the String getEventName() method test.
94 public void testGetEventName() {
95 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
96 String result
= nullEvent
.getEventName();
98 assertEquals("Empty CTF event", result
); //$NON-NLS-1$
102 * Run the ArrayList<String> getFieldNames() method test.
105 public void testGetFieldNames() {
106 String
[] result
= fixture
.getContent().getFieldNames();
107 assertNotNull(result
);
111 * Run the Object getFieldValue(String) method test.
114 public void testGetFieldValue() {
115 String fieldName
= "id"; //$NON-NLS-1$
116 Object result
= fixture
.getContent().getField(fieldName
).getValue();
118 assertNotNull(result
);
122 * Run the HashMap<String, CTFEventField> getFields() method test.
125 public void testGetFields() {
126 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
127 ITmfEventField
[] fields
= nullEvent
.getContent().getFields();
129 assertArrayEquals(null, fields
);
133 * Run the long getID() method test.
136 public void testGetID() {
137 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
138 long result
= nullEvent
.getID();
140 assertEquals(-1L, result
);
145 * Run the CTFEvent getNullEvent() method test.
148 public void testGetNullEvent() {
149 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
151 assertNotNull(nullEvent
);
152 assertEquals(-1, nullEvent
.getCPU());
153 assertEquals("Empty CTF event", nullEvent
.getEventName()); //$NON-NLS-1$
154 assertEquals("No stream", nullEvent
.getChannelName()); //$NON-NLS-1$
155 assertArrayEquals(null, nullEvent
.getContent().getFields());
156 assertEquals(-1L, nullEvent
.getID());
157 assertEquals(-1L, nullEvent
.getTimestampValue());
161 * Run the long getTimestamp() method test.
165 public void testGetTimestamp() {
166 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
167 long result
= nullEvent
.getTimestampValue();
169 assertEquals(-1L, result
);
This page took 0.034448 seconds and 6 git commands to generate.