5cd34a7ce9df5c0e6e0ea659f9cabc71a943f66a
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
.event
.ITmfEventType
;
14 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
15 import org
.junit
.After
;
16 import org
.junit
.Before
;
17 import org
.junit
.Test
;
20 * The class <code>CTFEventTest</code> contains tests for the class
21 * <code>{@link CTFEvent}</code>.
24 * @version $Revision: 1.0 $
26 public class CtfTmfEventTest
{
28 private CtfTmfEvent fixture
;
34 * the command line arguments
36 public static void main(String
[] args
) {
37 new org
.junit
.runner
.JUnitCore().run(CtfTmfEventTest
.class);
41 * Perform pre-test initialization.
43 * @throws FileNotFoundException
46 public void setUp() throws TmfTraceException
{
47 CtfTmfTrace trace
= TestParams
.createTrace();
48 CtfIterator tr
= new CtfIterator(trace
);
50 fixture
= tr
.getCurrentEvent();
54 * Perform post-test clean-up.
57 public void tearDown() {
58 // Add additional tear down code here
62 * Run the CTFEvent(EventDefinition,StreamInputReader) constructor test.
65 public void testCTFEvent_read() {
66 assertNotNull(fixture
);
70 * Run the int getCPU() method test.
73 public void testGetCPU() {
74 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
75 int result
= nullEvent
.getCPU();
77 assertEquals(-1, result
);
81 * Run the String getChannelName() method test.
84 public void testGetChannelName() {
85 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
86 String result
= nullEvent
.getChannelName();
88 assertEquals("No stream", result
); //$NON-NLS-1$
92 * Run the String getEventName() method test.
95 public void testGetEventName() {
96 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
97 String result
= nullEvent
.getEventName();
99 assertEquals("Empty CTF event", result
); //$NON-NLS-1$
103 * Run the ArrayList<String> getFieldNames() method test.
106 public void testGetFieldNames() {
107 String
[] result
= fixture
.getContent().getFieldNames();
108 assertNotNull(result
);
112 * Run the Object getFieldValue(String) method test.
115 public void testGetFieldValue() {
116 String fieldName
= "ret"; //$NON-NLS-1$
117 Object result
= fixture
.getContent().getField(fieldName
).getValue();
119 assertNotNull(result
);
123 * Run the HashMap<String, CTFEventField> getFields() method test.
126 public void testGetFields() {
127 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
128 ITmfEventField
[] fields
= nullEvent
.getContent().getFields();
129 ITmfEventField
[] fields2
= new ITmfEventField
[0];
130 assertArrayEquals(fields2
, fields
);
134 * Run the long getID() method test.
137 public void testGetID() {
138 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
139 long result
= nullEvent
.getID();
141 assertEquals(-1L, result
);
145 public void testClone() {
146 CtfTmfEvent other
= CtfTmfEvent
.getNullEvent().clone();
147 assertNotNull(other
);
151 * Run the CTFEvent getNullEvent() method test.
154 public void testGetNullEvent() {
155 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
157 assertNotNull(nullEvent
);
158 assertEquals(-1, nullEvent
.getCPU());
159 assertEquals("Empty CTF event", nullEvent
.getEventName()); //$NON-NLS-1$
160 assertEquals("No stream", nullEvent
.getChannelName()); //$NON-NLS-1$
161 assertArrayEquals(new ITmfEventField
[0], nullEvent
.getContent().getFields());
162 assertEquals(-1L, nullEvent
.getID());
163 assertEquals(-1L, nullEvent
.getTimestampValue());
167 * Run the long getTimestamp() method test.
171 public void testGetTimestamp() {
172 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
173 long result
= nullEvent
.getTimestampValue();
175 assertEquals(-1L, result
);
179 public void testRankTraceRefSourceType() {
180 long rank
= fixture
.getRank();
181 CtfTmfTrace trace
= fixture
.getTrace();
182 String channelName
= fixture
.getChannelName();
183 String reference
= fixture
.getReference();
184 String source
= fixture
.getSource();
185 ITmfEventType type
= fixture
.getType();
186 assertEquals(rank
, 0);
187 assertEquals(trace
.getName(), "kernel"); //$NON-NLS-1$
188 assertEquals(channelName
, "channel0_1"); //$NON-NLS-1$
189 assertEquals(reference
,"channel0_1"); //$NON-NLS-1$
190 assertEquals(source
, "1"); //$NON-NLS-1$
191 assertEquals(type
.toString(), "exit_syscall"); //$NON-NLS-1$
195 public void testToString() {
196 String s
= fixture
.getContent().toString();
197 assertEquals("ret=4132", s
); //$NON-NLS-1$
This page took 0.217056 seconds and 5 git commands to generate.