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; | |
866e5b51 FC |
11 | import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; |
12 | import org.eclipse.linuxtools.ctf.core.tests.TestParams; | |
13be1a8f | 13 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
866e5b51 | 14 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; |
ce2388e0 FC |
15 | import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException; |
16 | import org.eclipse.linuxtools.internal.ctf.core.trace.Stream; | |
17 | import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInput; | |
866e5b51 FC |
18 | import org.junit.After; |
19 | import org.junit.Before; | |
20 | import org.junit.Test; | |
21 | ||
22 | /** | |
23 | * The class <code>StreamTest</code> contains tests for the class | |
24 | * <code>{@link Stream}</code>. | |
e291b8c8 | 25 | * |
866e5b51 FC |
26 | * @author ematkho |
27 | * @version $Revision: 1.0 $ | |
28 | */ | |
29 | public class StreamTest { | |
30 | ||
31 | private Stream fixture; | |
32 | ||
33 | /** | |
34 | * Launch the test. | |
e291b8c8 | 35 | * |
866e5b51 FC |
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. | |
788ddcbc MK |
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. | |
788ddcbc MK |
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. | |
e291b8c8 | 82 | * @throws ParseException |
866e5b51 FC |
83 | */ |
84 | @Test | |
85 | public void testAddEvent_base() throws ParseException { | |
86 | EventDeclaration event = new EventDeclaration(); | |
87 | fixture.addEvent(event); | |
88 | } | |
89 | ||
866e5b51 FC |
90 | /** |
91 | * Run the boolean eventContextIsSet() method test. | |
92 | */ | |
93 | @Test | |
94 | public void testEventContextIsSet() { | |
95 | assertTrue(fixture.eventContextIsSet()); | |
96 | } | |
e291b8c8 MK |
97 | /** |
98 | * Run the boolean eventContextIsSet() method test. | |
99 | */ | |
100 | @Test | |
101 | public void testToString() { | |
102 | assertNotNull(fixture.toString()); | |
103 | } | |
866e5b51 FC |
104 | |
105 | /** | |
106 | * Run the boolean eventHeaderIsSet() method test. | |
107 | */ | |
108 | @Test | |
109 | public void testEventHeaderIsSet() { | |
110 | assertTrue(fixture.eventHeaderIsSet()); | |
111 | } | |
112 | ||
113 | /** | |
114 | * Run the StructDeclaration getEventContextDecl() method test. | |
115 | */ | |
116 | @Test | |
117 | public void testGetEventContextDecl() { | |
118 | assertNotNull(fixture.getEventContextDecl()); | |
119 | } | |
120 | ||
121 | /** | |
122 | * Run the StructDeclaration getEventHeaderDecl() method test. | |
123 | */ | |
124 | @Test | |
125 | public void testGetEventHeaderDecl() { | |
126 | assertNotNull(fixture.getEventHeaderDecl()); | |
127 | } | |
128 | ||
129 | /** | |
130 | * Run the HashMap<Long, EventDeclaration> getEvents() method test. | |
131 | */ | |
132 | @Test | |
133 | public void testGetEvents() { | |
134 | HashMap<Long, EventDeclaration> result = fixture.getEvents(); | |
135 | assertNotNull(result); | |
136 | } | |
137 | ||
138 | /** | |
139 | * Run the Long getId() method test. | |
140 | */ | |
141 | @Test | |
142 | public void testGetId() { | |
143 | Long result = fixture.getId(); | |
144 | assertNotNull(result); | |
145 | } | |
146 | ||
147 | /** | |
148 | * Run the StructDeclaration getPacketContextDecl() method test. | |
149 | */ | |
150 | @Test | |
151 | public void testGetPacketContextDecl() { | |
152 | StructDeclaration result = fixture.getPacketContextDecl(); | |
153 | assertNotNull(result); | |
154 | } | |
155 | ||
156 | /** | |
157 | * Run the Set<StreamInput> getStreamInputs() method test. | |
158 | */ | |
159 | @Test | |
160 | public void testGetStreamInputs() { | |
161 | Set<StreamInput> result = fixture.getStreamInputs(); | |
162 | assertNotNull(result); | |
163 | } | |
164 | ||
165 | /** | |
166 | * Run the CTFTrace getTrace() method test. | |
167 | */ | |
168 | @Test | |
169 | public void testGetTrace() { | |
170 | CTFTrace result = fixture.getTrace(); | |
171 | assertNotNull(result); | |
172 | } | |
173 | ||
174 | /** | |
175 | * Run the boolean idIsSet() method test. | |
176 | */ | |
177 | @Test | |
178 | public void testIdIsSet() { | |
179 | boolean result = fixture.idIsSet(); | |
180 | assertTrue(result); | |
181 | } | |
182 | ||
183 | /** | |
184 | * Run the boolean packetContextIsSet() method test. | |
185 | */ | |
186 | @Test | |
187 | public void testPacketContextIsSet() { | |
188 | boolean result = fixture.packetContextIsSet(); | |
189 | assertTrue(result); | |
190 | } | |
191 | ||
192 | ||
193 | /** | |
194 | * Run the void setEventContext(StructDeclaration) method test. | |
195 | */ | |
196 | @Test | |
197 | public void testSetEventContext() { | |
198 | StructDeclaration eventContext = new StructDeclaration(1L); | |
199 | fixture.setEventContext(eventContext); | |
200 | } | |
201 | ||
202 | /** | |
203 | * Run the void setEventHeader(StructDeclaration) method test. | |
204 | */ | |
205 | @Test | |
206 | public void testSetEventHeader() { | |
207 | StructDeclaration eventHeader = new StructDeclaration(1L); | |
208 | fixture.setEventHeader(eventHeader); | |
209 | } | |
210 | ||
211 | /** | |
212 | * Run the void setId(long) method test. | |
213 | */ | |
214 | @Test | |
215 | public void testSetId() { | |
216 | long id = 1L; | |
217 | fixture.setId(id); | |
218 | } | |
219 | ||
220 | /** | |
221 | * Run the void setPacketContext(StructDeclaration) method test. | |
222 | */ | |
223 | @Test | |
224 | public void testSetPacketContext() { | |
225 | StructDeclaration packetContext = new StructDeclaration(1L); | |
226 | fixture.setPacketContext(packetContext); | |
227 | } | |
228 | } |