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
.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
.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
;
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 boolean eventContextIsSet() method test.
94 public void testEventContextIsSet() {
95 assertTrue(fixture
.isEventContextSet());
98 * Run the boolean eventContextIsSet() method test.
101 public void testToString() {
102 assertNotNull(fixture
.toString());
106 * Run the boolean eventHeaderIsSet() method test.
109 public void testEventHeaderIsSet() {
110 assertTrue(fixture
.isEventHeaderSet());
114 * Run the StructDeclaration getEventContextDecl() method test.
117 public void testGetEventContextDecl() {
118 assertNotNull(fixture
.getEventContextDecl());
122 * Run the StructDeclaration getEventHeaderDecl() method test.
125 public void testGetEventHeaderDecl() {
126 assertNotNull(fixture
.getEventHeaderDecl());
130 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
133 public void testGetEvents() {
134 HashMap
<Long
, EventDeclaration
> result
= fixture
.getEvents();
135 assertNotNull(result
);
139 * Run the Long getId() method test.
142 public void testGetId() {
143 Long result
= fixture
.getId();
144 assertNotNull(result
);
148 * Run the StructDeclaration getPacketContextDecl() method test.
151 public void testGetPacketContextDecl() {
152 StructDeclaration result
= fixture
.getPacketContextDecl();
153 assertNotNull(result
);
157 * Run the Set<StreamInput> getStreamInputs() method test.
160 public void testGetStreamInputs() {
161 Set
<StreamInput
> result
= fixture
.getStreamInputs();
162 assertNotNull(result
);
166 * Run the CTFTrace getTrace() method test.
169 public void testGetTrace() {
170 CTFTrace result
= fixture
.getTrace();
171 assertNotNull(result
);
175 * Run the boolean idIsSet() method test.
178 public void testIdIsSet() {
179 boolean result
= fixture
.isIdSet();
184 * Run the boolean packetContextIsSet() method test.
187 public void testPacketContextIsSet() {
188 boolean result
= fixture
.isPacketContextSet();
194 * Run the void setEventContext(StructDeclaration) method test.
197 public void testSetEventContext() {
198 StructDeclaration eventContext
= new StructDeclaration(1L);
199 fixture
.setEventContext(eventContext
);
203 * Run the void setEventHeader(StructDeclaration) method test.
206 public void testSetEventHeader() {
207 StructDeclaration eventHeader
= new StructDeclaration(1L);
208 fixture
.setEventHeader(eventHeader
);
212 * Run the void setId(long) method test.
215 public void testSetId() {
221 * Run the void setPacketContext(StructDeclaration) method test.
224 public void testSetPacketContext() {
225 StructDeclaration packetContext
= new StructDeclaration(1L);
226 fixture
.setPacketContext(packetContext
);