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