8388fcd6f204fd7f29a73e01f3513081b2bb4a49
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
= "pid"; //$NON-NLS-1$
117 ITmfEventField result
= fixture
.getContent().getField(fieldName
);
119 assertNotNull(result
);
120 assertNotNull(result
.getValue());
124 * Run the HashMap<String, CTFEventField> getFields() method test.
127 public void testGetFields() {
128 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
129 ITmfEventField
[] fields
= nullEvent
.getContent().getFields();
130 ITmfEventField
[] fields2
= new ITmfEventField
[0];
131 assertArrayEquals(fields2
, fields
);
135 * Run the long getID() method test.
138 public void testGetID() {
139 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
140 long result
= nullEvent
.getID();
142 assertEquals(-1L, result
);
146 public void testClone() {
147 CtfTmfEvent other
= CtfTmfEvent
.getNullEvent().clone();
148 assertNotNull(other
);
152 * Run the CTFEvent getNullEvent() method test.
155 public void testGetNullEvent() {
156 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
158 assertNotNull(nullEvent
);
159 assertEquals(-1, nullEvent
.getCPU());
160 assertEquals("Empty CTF event", nullEvent
.getEventName()); //$NON-NLS-1$
161 assertEquals("No stream", nullEvent
.getChannelName()); //$NON-NLS-1$
162 assertArrayEquals(new ITmfEventField
[0], nullEvent
.getContent().getFields());
163 assertEquals(-1L, nullEvent
.getID());
164 assertEquals(-1L, nullEvent
.getTimestampValue());
168 * Run the long getTimestamp() method test.
172 public void testGetTimestamp() {
173 CtfTmfEvent nullEvent
= CtfTmfEvent
.getNullEvent();
174 long result
= nullEvent
.getTimestampValue();
176 assertEquals(-1L, result
);
180 public void testRankTraceRefSourceType() {
181 long rank
= fixture
.getRank();
182 CtfTmfTrace trace
= fixture
.getTrace();
183 String channelName
= fixture
.getChannelName();
184 String reference
= fixture
.getReference();
185 String source
= fixture
.getSource();
186 ITmfEventType type
= fixture
.getType();
187 assertEquals(rank
, 0);
188 assertEquals(trace
.getName(), "test"); //$NON-NLS-1$
189 assertEquals(channelName
, "channel0_1"); //$NON-NLS-1$
190 assertEquals(reference
,"channel0_1"); //$NON-NLS-1$
191 assertEquals(source
, "1"); //$NON-NLS-1$
192 assertEquals(type
.toString(), "lttng_statedump_vm_map"); //$NON-NLS-1$
196 public void testToString() {
197 String s
= fixture
.getContent().toString();
198 assertEquals("pid=1922, inode=917738, flags=134217845, end=3074342912, start=3074334720, pgoff=0", s
); //$NON-NLS-1$
This page took 0.113527 seconds and 5 git commands to generate.