1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.trace
;
3 import static org
.junit
.Assert
.assertNotNull
;
4 import static org
.junit
.Assert
.assertTrue
;
5 import static org
.junit
.Assume
.assumeTrue
;
7 import java
.nio
.channels
.FileChannel
;
8 import java
.util
.HashMap
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.IEventDeclaration
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTraces
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInput
;
18 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
19 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.metadata
.exceptions
.ParseException
;
20 import org
.junit
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * The class <code>StreamTest</code> contains tests for the class
26 * <code>{@link Stream}</code>.
29 * @version $Revision: 1.0 $
31 @SuppressWarnings("javadoc")
32 public class StreamTest
{
34 private static final int TRACE_INDEX
= 0;
36 private Stream fixture
;
42 * the command line arguments
44 public static void main(String
[] args
) {
45 new org
.junit
.runner
.JUnitCore().run(StreamTest
.class);
49 * Perform pre-test initialization.
51 * @throws CTFReaderException
54 public void setUp() throws CTFReaderException
{
55 assumeTrue(CtfTestTraces
.tracesExist());
56 fixture
= new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
));
57 fixture
.setEventContext(new StructDeclaration(1L));
58 fixture
.setPacketContext(new StructDeclaration(1L));
59 fixture
.setEventHeader(new StructDeclaration(1L));
61 fixture
.addInput(new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
62 (FileChannel
) null, CtfTestTraces
.getEmptyFile()));
66 * Perform post-test clean-up.
69 public void tearDown() {
70 // Add additional tear down code here
74 * Run the Stream(CTFTrace) constructor test.
76 * @throws CTFReaderException
79 public void testStream() throws CTFReaderException
{
80 CTFTrace trace
= CtfTestTraces
.getTestTrace(TRACE_INDEX
);
81 Stream result
= new Stream(trace
);
82 assertNotNull(result
);
86 * Run the void addEvent(EventDeclaration) method test with the basic
88 * @throws ParseException
91 public void testAddEvent_base() throws ParseException
{
92 EventDeclaration event
= new EventDeclaration();
93 fixture
.addEvent(event
);
97 * Run the boolean eventContextIsSet() method test.
100 public void testEventContextIsSet() {
101 assertTrue(fixture
.isEventContextSet());
104 * Run the boolean eventContextIsSet() method test.
107 public void testToString() {
108 assertNotNull(fixture
.toString());
112 * Run the boolean eventHeaderIsSet() method test.
115 public void testEventHeaderIsSet() {
116 assertTrue(fixture
.isEventHeaderSet());
120 * Run the StructDeclaration getEventContextDecl() method test.
123 public void testGetEventContextDecl() {
124 assertNotNull(fixture
.getEventContextDecl());
128 * Run the StructDeclaration getEventHeaderDecl() method test.
131 public void testGetEventHeaderDecl() {
132 assertNotNull(fixture
.getEventHeaderDecl());
136 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
139 public void testGetEvents() {
140 HashMap
<Long
, IEventDeclaration
> result
= fixture
.getEvents();
141 assertNotNull(result
);
145 * Run the Long getId() method test.
148 public void testGetId() {
149 Long result
= fixture
.getId();
150 assertNotNull(result
);
154 * Run the StructDeclaration getPacketContextDecl() method test.
157 public void testGetPacketContextDecl() {
158 StructDeclaration result
= fixture
.getPacketContextDecl();
159 assertNotNull(result
);
163 * Run the Set<StreamInput> getStreamInputs() method test.
166 public void testGetStreamInputs() {
167 Set
<StreamInput
> result
= fixture
.getStreamInputs();
168 assertNotNull(result
);
172 * Run the CTFTrace getTrace() method test.
175 public void testGetTrace() {
176 CTFTrace result
= fixture
.getTrace();
177 assertNotNull(result
);
181 * Run the boolean idIsSet() method test.
184 public void testIdIsSet() {
185 boolean result
= fixture
.isIdSet();
190 * Run the boolean packetContextIsSet() method test.
193 public void testPacketContextIsSet() {
194 boolean result
= fixture
.isPacketContextSet();
200 * Run the void setEventContext(StructDeclaration) method test.
203 public void testSetEventContext() {
204 StructDeclaration eventContext
= new StructDeclaration(1L);
205 fixture
.setEventContext(eventContext
);
209 * Run the void setEventHeader(StructDeclaration) method test.
212 public void testSetEventHeader() {
213 StructDeclaration eventHeader
= new StructDeclaration(1L);
214 fixture
.setEventHeader(eventHeader
);
218 * Run the void setId(long) method test.
221 public void testSetId() {
227 * Run the void setPacketContext(StructDeclaration) method test.
230 public void testSetPacketContext() {
231 StructDeclaration packetContext
= new StructDeclaration(1L);
232 fixture
.setPacketContext(packetContext
);