1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.trace
;
3 import static org
.junit
.Assert
.assertNotNull
;
4 import static org
.junit
.Assert
.assertTrue
;
6 import java
.nio
.channels
.FileChannel
;
7 import java
.util
.HashMap
;
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
;
24 * The class <code>StreamTest</code> contains tests for the class
25 * <code>{@link Stream}</code>.
28 * @version $Revision: 1.0 $
30 @SuppressWarnings("javadoc")
31 public class StreamTest
{
33 private Stream fixture
;
39 * the command line arguments
41 public static void main(String
[] args
) {
42 new org
.junit
.runner
.JUnitCore().run(StreamTest
.class);
46 * Perform pre-test initialization.
48 * @throws CTFReaderException
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));
57 fixture
.addInput(new StreamInput(new Stream(TestParams
.createTrace()),
58 (FileChannel
) null, TestParams
.getEmptyFile()));
62 * Perform post-test clean-up.
65 public void tearDown() {
66 // Add additional tear down code here
70 * Run the Stream(CTFTrace) constructor test.
72 * @throws CTFReaderException
75 public void testStream() throws CTFReaderException
{
76 CTFTrace trace
= TestParams
.createTrace();
77 Stream result
= new Stream(trace
);
78 assertNotNull(result
);
82 * Run the void addEvent(EventDeclaration) method test with the basic
84 * @throws ParseException
87 public void testAddEvent_base() throws ParseException
{
88 EventDeclaration event
= new EventDeclaration();
89 fixture
.addEvent(event
);
93 * Run the boolean eventContextIsSet() method test.
96 public void testEventContextIsSet() {
97 assertTrue(fixture
.isEventContextSet());
100 * Run the boolean eventContextIsSet() method test.
103 public void testToString() {
104 assertNotNull(fixture
.toString());
108 * Run the boolean eventHeaderIsSet() method test.
111 public void testEventHeaderIsSet() {
112 assertTrue(fixture
.isEventHeaderSet());
116 * Run the StructDeclaration getEventContextDecl() method test.
119 public void testGetEventContextDecl() {
120 assertNotNull(fixture
.getEventContextDecl());
124 * Run the StructDeclaration getEventHeaderDecl() method test.
127 public void testGetEventHeaderDecl() {
128 assertNotNull(fixture
.getEventHeaderDecl());
132 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
135 public void testGetEvents() {
136 HashMap
<Long
, IEventDeclaration
> result
= fixture
.getEvents();
137 assertNotNull(result
);
141 * Run the Long getId() method test.
144 public void testGetId() {
145 Long result
= fixture
.getId();
146 assertNotNull(result
);
150 * Run the StructDeclaration getPacketContextDecl() method test.
153 public void testGetPacketContextDecl() {
154 StructDeclaration result
= fixture
.getPacketContextDecl();
155 assertNotNull(result
);
159 * Run the Set<StreamInput> getStreamInputs() method test.
162 public void testGetStreamInputs() {
163 Set
<StreamInput
> result
= fixture
.getStreamInputs();
164 assertNotNull(result
);
168 * Run the CTFTrace getTrace() method test.
171 public void testGetTrace() {
172 CTFTrace result
= fixture
.getTrace();
173 assertNotNull(result
);
177 * Run the boolean idIsSet() method test.
180 public void testIdIsSet() {
181 boolean result
= fixture
.isIdSet();
186 * Run the boolean packetContextIsSet() method test.
189 public void testPacketContextIsSet() {
190 boolean result
= fixture
.isPacketContextSet();
196 * Run the void setEventContext(StructDeclaration) method test.
199 public void testSetEventContext() {
200 StructDeclaration eventContext
= new StructDeclaration(1L);
201 fixture
.setEventContext(eventContext
);
205 * Run the void setEventHeader(StructDeclaration) method test.
208 public void testSetEventHeader() {
209 StructDeclaration eventHeader
= new StructDeclaration(1L);
210 fixture
.setEventHeader(eventHeader
);
214 * Run the void setId(long) method test.
217 public void testSetId() {
223 * Run the void setPacketContext(StructDeclaration) method test.
226 public void testSetPacketContext() {
227 StructDeclaration packetContext
= new StructDeclaration(1L);
228 fixture
.setPacketContext(packetContext
);