CTF: Add support for custom attributes in an event
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.trace;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5
6 import java.nio.channels.FileChannel;
7 import java.util.HashMap;
8 import java.util.Set;
9
10 import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
11 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
12 import org.eclipse.linuxtools.ctf.core.tests.TestParams;
13 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
14 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
15 import org.eclipse.linuxtools.ctf.core.trace.Stream;
16 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
17 import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
18 import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
19 import org.junit.After;
20 import org.junit.Before;
21 import org.junit.Test;
22
23 /**
24 * The class <code>StreamTest</code> contains tests for the class
25 * <code>{@link Stream}</code>.
26 *
27 * @author ematkho
28 * @version $Revision: 1.0 $
29 */
30 @SuppressWarnings("javadoc")
31 public class StreamTest {
32
33 private Stream fixture;
34
35 /**
36 * Launch the test.
37 *
38 * @param args
39 * the command line arguments
40 */
41 public static void main(String[] args) {
42 new org.junit.runner.JUnitCore().run(StreamTest.class);
43 }
44
45 /**
46 * Perform pre-test initialization.
47 *
48 * @throws CTFReaderException
49 */
50 @Before
51 public void setUp() throws CTFReaderException {
52 fixture = new Stream(TestParams.createTrace());
53 fixture.setEventContext(new StructDeclaration(1L));
54 fixture.setPacketContext(new StructDeclaration(1L));
55 fixture.setEventHeader(new StructDeclaration(1L));
56 fixture.setId(1L);
57 fixture.addInput(new StreamInput(new Stream(TestParams.createTrace()),
58 (FileChannel) null, TestParams.getEmptyFile()));
59 }
60
61 /**
62 * Perform post-test clean-up.
63 */
64 @After
65 public void tearDown() {
66 // Add additional tear down code here
67 }
68
69 /**
70 * Run the Stream(CTFTrace) constructor test.
71 *
72 * @throws CTFReaderException
73 */
74 @Test
75 public void testStream() throws CTFReaderException {
76 CTFTrace trace = TestParams.createTrace();
77 Stream result = new Stream(trace);
78 assertNotNull(result);
79 }
80
81 /**
82 * Run the void addEvent(EventDeclaration) method test with the basic
83 * event.
84 * @throws ParseException
85 */
86 @Test
87 public void testAddEvent_base() throws ParseException {
88 EventDeclaration event = new EventDeclaration();
89 fixture.addEvent(event);
90 }
91
92 /**
93 * Run the boolean eventContextIsSet() method test.
94 */
95 @Test
96 public void testEventContextIsSet() {
97 assertTrue(fixture.isEventContextSet());
98 }
99 /**
100 * Run the boolean eventContextIsSet() method test.
101 */
102 @Test
103 public void testToString() {
104 assertNotNull(fixture.toString());
105 }
106
107 /**
108 * Run the boolean eventHeaderIsSet() method test.
109 */
110 @Test
111 public void testEventHeaderIsSet() {
112 assertTrue(fixture.isEventHeaderSet());
113 }
114
115 /**
116 * Run the StructDeclaration getEventContextDecl() method test.
117 */
118 @Test
119 public void testGetEventContextDecl() {
120 assertNotNull(fixture.getEventContextDecl());
121 }
122
123 /**
124 * Run the StructDeclaration getEventHeaderDecl() method test.
125 */
126 @Test
127 public void testGetEventHeaderDecl() {
128 assertNotNull(fixture.getEventHeaderDecl());
129 }
130
131 /**
132 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
133 */
134 @Test
135 public void testGetEvents() {
136 HashMap<Long, IEventDeclaration> result = fixture.getEvents();
137 assertNotNull(result);
138 }
139
140 /**
141 * Run the Long getId() method test.
142 */
143 @Test
144 public void testGetId() {
145 Long result = fixture.getId();
146 assertNotNull(result);
147 }
148
149 /**
150 * Run the StructDeclaration getPacketContextDecl() method test.
151 */
152 @Test
153 public void testGetPacketContextDecl() {
154 StructDeclaration result = fixture.getPacketContextDecl();
155 assertNotNull(result);
156 }
157
158 /**
159 * Run the Set<StreamInput> getStreamInputs() method test.
160 */
161 @Test
162 public void testGetStreamInputs() {
163 Set<StreamInput> result = fixture.getStreamInputs();
164 assertNotNull(result);
165 }
166
167 /**
168 * Run the CTFTrace getTrace() method test.
169 */
170 @Test
171 public void testGetTrace() {
172 CTFTrace result = fixture.getTrace();
173 assertNotNull(result);
174 }
175
176 /**
177 * Run the boolean idIsSet() method test.
178 */
179 @Test
180 public void testIdIsSet() {
181 boolean result = fixture.isIdSet();
182 assertTrue(result);
183 }
184
185 /**
186 * Run the boolean packetContextIsSet() method test.
187 */
188 @Test
189 public void testPacketContextIsSet() {
190 boolean result = fixture.isPacketContextSet();
191 assertTrue(result);
192 }
193
194
195 /**
196 * Run the void setEventContext(StructDeclaration) method test.
197 */
198 @Test
199 public void testSetEventContext() {
200 StructDeclaration eventContext = new StructDeclaration(1L);
201 fixture.setEventContext(eventContext);
202 }
203
204 /**
205 * Run the void setEventHeader(StructDeclaration) method test.
206 */
207 @Test
208 public void testSetEventHeader() {
209 StructDeclaration eventHeader = new StructDeclaration(1L);
210 fixture.setEventHeader(eventHeader);
211 }
212
213 /**
214 * Run the void setId(long) method test.
215 */
216 @Test
217 public void testSetId() {
218 long id = 1L;
219 fixture.setId(id);
220 }
221
222 /**
223 * Run the void setPacketContext(StructDeclaration) method test.
224 */
225 @Test
226 public void testSetPacketContext() {
227 StructDeclaration packetContext = new StructDeclaration(1L);
228 fixture.setPacketContext(packetContext);
229 }
230 }
This page took 0.04208 seconds and 6 git commands to generate.