Commit | Line | Data |
---|---|---|
866e5b51 FC |
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.EventDeclaration; | |
11 | import org.eclipse.linuxtools.ctf.core.event.metadata.exceptions.ParseException; | |
12 | import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; | |
13 | import org.eclipse.linuxtools.ctf.core.tests.TestParams; | |
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.junit.After; | |
18 | import org.junit.Before; | |
19 | import org.junit.Test; | |
20 | ||
21 | /** | |
22 | * The class <code>StreamTest</code> contains tests for the class | |
23 | * <code>{@link Stream}</code>. | |
24 | * | |
25 | * @author ematkho | |
26 | * @version $Revision: 1.0 $ | |
27 | */ | |
28 | public class StreamTest { | |
29 | ||
30 | private Stream fixture; | |
31 | ||
32 | /** | |
33 | * Launch the test. | |
34 | * | |
35 | * @param args | |
36 | * the command line arguments | |
37 | */ | |
38 | public static void main(String[] args) { | |
39 | new org.junit.runner.JUnitCore().run(StreamTest.class); | |
40 | } | |
41 | ||
42 | /** | |
43 | * Perform pre-test initialization. | |
44 | */ | |
45 | @Before | |
46 | public void setUp() { | |
47 | fixture = new Stream(TestParams.createTrace()); | |
48 | fixture.setEventContext(new StructDeclaration(1L)); | |
49 | fixture.setPacketContext(new StructDeclaration(1L)); | |
50 | fixture.setEventHeader(new StructDeclaration(1L)); | |
51 | fixture.setId(1L); | |
52 | fixture.addInput(new StreamInput(new Stream(TestParams.createTrace()), | |
53 | (FileChannel) null, TestParams.getEmptyFile())); | |
54 | } | |
55 | ||
56 | /** | |
57 | * Perform post-test clean-up. | |
58 | */ | |
59 | @After | |
60 | public void tearDown() { | |
61 | // Add additional tear down code here | |
62 | } | |
63 | ||
64 | /** | |
65 | * Run the Stream(CTFTrace) constructor test. | |
66 | */ | |
67 | @Test | |
68 | public void testStream() { | |
69 | CTFTrace trace = TestParams.createTrace(); | |
70 | Stream result = new Stream(trace); | |
71 | assertNotNull(result); | |
72 | } | |
73 | ||
74 | /** | |
75 | * Run the void addEvent(EventDeclaration) method test with the basic | |
76 | * event. | |
77 | * @throws ParseException | |
78 | */ | |
79 | @Test | |
80 | public void testAddEvent_base() throws ParseException { | |
81 | EventDeclaration event = new EventDeclaration(); | |
82 | fixture.addEvent(event); | |
83 | } | |
84 | ||
85 | /** | |
86 | * Run the void addEvent(EventDeclaration) method test with an event | |
87 | * of which we modified the id. | |
88 | * @throws ParseException | |
89 | * | |
90 | * @throws ParseException | |
91 | */ | |
92 | @Test | |
93 | public void testAddEvent_modifiedEvent() throws ParseException { | |
94 | EventDeclaration event = new EventDeclaration(); | |
95 | event.setId(1L); | |
96 | fixture.addEvent(event); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Run the boolean eventContextIsSet() method test. | |
101 | */ | |
102 | @Test | |
103 | public void testEventContextIsSet() { | |
104 | assertTrue(fixture.eventContextIsSet()); | |
105 | } | |
106 | ||
107 | /** | |
108 | * Run the boolean eventHeaderIsSet() method test. | |
109 | */ | |
110 | @Test | |
111 | public void testEventHeaderIsSet() { | |
112 | assertTrue(fixture.eventHeaderIsSet()); | |
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, EventDeclaration> 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.idIsSet(); | |
182 | assertTrue(result); | |
183 | } | |
184 | ||
185 | /** | |
186 | * Run the boolean packetContextIsSet() method test. | |
187 | */ | |
188 | @Test | |
189 | public void testPacketContextIsSet() { | |
190 | boolean result = fixture.packetContextIsSet(); | |
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 | } |