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 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
);
102 assertNotNull(fixture
);
106 * Run the boolean eventContextIsSet() method test.
109 public void testEventContextIsSet() {
110 assertTrue(fixture
.eventContextIsSet());
113 * Run the boolean eventContextIsSet() method test.
116 public void testToString() {
117 assertNotNull(fixture
.toString());
121 * Run the boolean eventHeaderIsSet() method test.
124 public void testEventHeaderIsSet() {
125 assertTrue(fixture
.eventHeaderIsSet());
129 * Run the StructDeclaration getEventContextDecl() method test.
132 public void testGetEventContextDecl() {
133 assertNotNull(fixture
.getEventContextDecl());
137 * Run the StructDeclaration getEventHeaderDecl() method test.
140 public void testGetEventHeaderDecl() {
141 assertNotNull(fixture
.getEventHeaderDecl());
145 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
148 public void testGetEvents() {
149 HashMap
<Long
, EventDeclaration
> result
= fixture
.getEvents();
150 assertNotNull(result
);
154 * Run the Long getId() method test.
157 public void testGetId() {
158 Long result
= fixture
.getId();
159 assertNotNull(result
);
163 * Run the StructDeclaration getPacketContextDecl() method test.
166 public void testGetPacketContextDecl() {
167 StructDeclaration result
= fixture
.getPacketContextDecl();
168 assertNotNull(result
);
172 * Run the Set<StreamInput> getStreamInputs() method test.
175 public void testGetStreamInputs() {
176 Set
<StreamInput
> result
= fixture
.getStreamInputs();
177 assertNotNull(result
);
181 * Run the CTFTrace getTrace() method test.
184 public void testGetTrace() {
185 CTFTrace result
= fixture
.getTrace();
186 assertNotNull(result
);
190 * Run the boolean idIsSet() method test.
193 public void testIdIsSet() {
194 boolean result
= fixture
.idIsSet();
199 * Run the boolean packetContextIsSet() method test.
202 public void testPacketContextIsSet() {
203 boolean result
= fixture
.packetContextIsSet();
209 * Run the void setEventContext(StructDeclaration) method test.
212 public void testSetEventContext() {
213 StructDeclaration eventContext
= new StructDeclaration(1L);
214 fixture
.setEventContext(eventContext
);
218 * Run the void setEventHeader(StructDeclaration) method test.
221 public void testSetEventHeader() {
222 StructDeclaration eventHeader
= new StructDeclaration(1L);
223 fixture
.setEventHeader(eventHeader
);
227 * Run the void setId(long) method test.
230 public void testSetId() {
236 * Run the void setPacketContext(StructDeclaration) method test.
239 public void testSetPacketContext() {
240 StructDeclaration packetContext
= new StructDeclaration(1L);
241 fixture
.setPacketContext(packetContext
);