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
.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
.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
.junit
.After
;
19 import org
.junit
.Before
;
20 import org
.junit
.Test
;
23 * The class <code>StreamTest</code> contains tests for the class
24 * <code>{@link Stream}</code>.
27 * @version $Revision: 1.0 $
29 public class StreamTest
{
31 private Stream fixture
;
37 * the command line arguments
39 public static void main(String
[] args
) {
40 new org
.junit
.runner
.JUnitCore().run(StreamTest
.class);
44 * Perform pre-test initialization.
46 * @throws CTFReaderException
49 public void setUp() throws CTFReaderException
{
50 fixture
= new Stream(TestParams
.createTrace());
51 fixture
.setEventContext(new StructDeclaration(1L));
52 fixture
.setPacketContext(new StructDeclaration(1L));
53 fixture
.setEventHeader(new StructDeclaration(1L));
55 fixture
.addInput(new StreamInput(new Stream(TestParams
.createTrace()),
56 (FileChannel
) null, TestParams
.getEmptyFile()));
60 * Perform post-test clean-up.
63 public void tearDown() {
64 // Add additional tear down code here
68 * Run the Stream(CTFTrace) constructor test.
70 * @throws CTFReaderException
73 public void testStream() throws CTFReaderException
{
74 CTFTrace trace
= TestParams
.createTrace();
75 Stream result
= new Stream(trace
);
76 assertNotNull(result
);
80 * Run the void addEvent(EventDeclaration) method test with the basic
82 * @throws ParseException
85 public void testAddEvent_base() throws ParseException
{
86 EventDeclaration event
= new EventDeclaration();
87 fixture
.addEvent(event
);
91 * Run the void addEvent(EventDeclaration) method test with an event
92 * of which we modified the id.
93 * @throws ParseException
95 * @throws ParseException
98 public void testAddEvent_modifiedEvent() throws ParseException
{
99 EventDeclaration event
= new EventDeclaration();
101 fixture
.addEvent(event
);
105 * Run the boolean eventContextIsSet() method test.
108 public void testEventContextIsSet() {
109 assertTrue(fixture
.eventContextIsSet());
113 * Run the boolean eventHeaderIsSet() method test.
116 public void testEventHeaderIsSet() {
117 assertTrue(fixture
.eventHeaderIsSet());
121 * Run the StructDeclaration getEventContextDecl() method test.
124 public void testGetEventContextDecl() {
125 assertNotNull(fixture
.getEventContextDecl());
129 * Run the StructDeclaration getEventHeaderDecl() method test.
132 public void testGetEventHeaderDecl() {
133 assertNotNull(fixture
.getEventHeaderDecl());
137 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
140 public void testGetEvents() {
141 HashMap
<Long
, EventDeclaration
> result
= fixture
.getEvents();
142 assertNotNull(result
);
146 * Run the Long getId() method test.
149 public void testGetId() {
150 Long result
= fixture
.getId();
151 assertNotNull(result
);
155 * Run the StructDeclaration getPacketContextDecl() method test.
158 public void testGetPacketContextDecl() {
159 StructDeclaration result
= fixture
.getPacketContextDecl();
160 assertNotNull(result
);
164 * Run the Set<StreamInput> getStreamInputs() method test.
167 public void testGetStreamInputs() {
168 Set
<StreamInput
> result
= fixture
.getStreamInputs();
169 assertNotNull(result
);
173 * Run the CTFTrace getTrace() method test.
176 public void testGetTrace() {
177 CTFTrace result
= fixture
.getTrace();
178 assertNotNull(result
);
182 * Run the boolean idIsSet() method test.
185 public void testIdIsSet() {
186 boolean result
= fixture
.idIsSet();
191 * Run the boolean packetContextIsSet() method test.
194 public void testPacketContextIsSet() {
195 boolean result
= fixture
.packetContextIsSet();
201 * Run the void setEventContext(StructDeclaration) method test.
204 public void testSetEventContext() {
205 StructDeclaration eventContext
= new StructDeclaration(1L);
206 fixture
.setEventContext(eventContext
);
210 * Run the void setEventHeader(StructDeclaration) method test.
213 public void testSetEventHeader() {
214 StructDeclaration eventHeader
= new StructDeclaration(1L);
215 fixture
.setEventHeader(eventHeader
);
219 * Run the void setId(long) method test.
222 public void testSetId() {
228 * Run the void setPacketContext(StructDeclaration) method test.
231 public void testSetPacketContext() {
232 StructDeclaration packetContext
= new StructDeclaration(1L);
233 fixture
.setPacketContext(packetContext
);