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 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
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventType
;
12 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
13 import org
.junit
.After
;
14 import org
.junit
.Before
;
15 import org
.junit
.Test
;
18 * The class <code>CTFEventTest</code> contains tests for the class
19 * <code>{@link CTFEvent}</code>.
22 * @version $Revision: 1.0 $
24 public class CtfTmfEventTest
{
26 private CtfTmfEvent fixture
;
32 * the command line arguments
34 public static void main(String
[] args
) {
35 new org
.junit
.runner
.JUnitCore().run(CtfTmfEventTest
.class);
39 * Perform pre-test initialization.
41 * @throws FileNotFoundException
44 public void setUp() throws TmfTraceException
{
45 CtfTmfTrace trace
= TestParams
.createTrace();
46 CtfIterator tr
= new CtfIterator(trace
);
48 fixture
= tr
.getCurrentEvent();
52 * Perform post-test clean-up.
55 public void tearDown() {
56 // Add additional tear down code here
60 * Run the CTFEvent(EventDefinition,StreamInputReader) constructor test.
63 public void testCTFEvent_read() {
64 assertNotNull(fixture
);
68 * Run the int getCPU() method test.
71 public void testGetCPU() {
72 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
73 int result
= nullEvent
.getCPU();
75 assertEquals(-1, result
);
79 * Run the String getChannelName() method test.
82 public void testGetChannelName() {
83 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
84 String result
= nullEvent
.getChannelName();
86 assertEquals("No stream", result
); //$NON-NLS-1$
90 * Run the String getEventName() method test.
93 public void testGetEventName() {
94 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
95 String result
= nullEvent
.getEventName();
97 assertEquals("Empty CTF event", result
); //$NON-NLS-1$
101 * Run the ArrayList<String> getFieldNames() method test.
104 public void testGetFieldNames() {
105 String
[] result
= fixture
.getContent().getFieldNames();
106 assertNotNull(result
);
110 * Run the Object getFieldValue(String) method test.
113 public void testGetFieldValue() {
114 String fieldName
= "pid"; //$NON-NLS-1$
115 ITmfEventField result
= fixture
.getContent().getField(fieldName
);
117 assertNotNull(result
);
118 assertNotNull(result
.getValue());
122 * Run the HashMap<String, CTFEventField> getFields() method test.
125 public void testGetFields() {
126 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
127 ITmfEventField
[] fields
= nullEvent
.getContent().getFields();
128 ITmfEventField
[] fields2
= new ITmfEventField
[0];
129 assertArrayEquals(fields2
, 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
);
144 public void testClone() {
145 CtfTmfEvent other
= CtfTmfEvent
.getNullEvent().clone();
146 assertNotNull(other
);
150 * Run the CTFEvent getNullEvent() method test.
153 public void testGetNullEvent() {
154 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
156 assertNotNull(nullEvent
);
157 assertEquals(-1, nullEvent
.getCPU());
158 assertEquals("Empty CTF event", nullEvent
.getEventName()); //$NON-NLS-1$
159 assertEquals("No stream", nullEvent
.getChannelName()); //$NON-NLS-1$
160 assertArrayEquals(new ITmfEventField
[0], nullEvent
.getContent().getFields());
161 assertEquals(-1L, nullEvent
.getID());
162 assertEquals(-1L, nullEvent
.getTimestampValue());
166 * Run the long getTimestamp() method test.
170 public void testGetTimestamp() {
171 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
172 long result
= nullEvent
.getTimestampValue();
174 assertEquals(-1L, result
);
178 public void testRankTraceRefSourceType() {
179 long rank
= fixture
.getRank();
180 CtfTmfTrace trace
= fixture
.getTrace();
181 String channelName
= fixture
.getChannelName();
182 String reference
= fixture
.getReference();
183 String source
= fixture
.getSource();
184 ITmfEventType type
= fixture
.getType();
185 assertEquals(rank
, 0);
186 assertEquals(trace
.getName(), "test"); //$NON-NLS-1$
187 assertEquals(channelName
, "channel0_1"); //$NON-NLS-1$
188 assertEquals(reference
,"channel0_1"); //$NON-NLS-1$
189 assertEquals(source
, "1"); //$NON-NLS-1$
190 assertEquals(type
.toString(), "lttng_statedump_vm_map"); //$NON-NLS-1$
194 public void testToString() {
195 String s
= fixture
.getContent().toString();
196 assertEquals("pid=1922, inode=917738, flags=134217845, end=3074342912, start=3074334720, pgoff=0", s
); //$NON-NLS-1$
This page took 0.036269 seconds and 6 git commands to generate.