1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.trace
;
14 import static org
.junit
.Assert
.assertNotNull
;
15 import static org
.junit
.Assert
.assertTrue
;
16 import static org
.junit
.Assume
.assumeTrue
;
18 import java
.nio
.channels
.FileChannel
;
19 import java
.util
.HashMap
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.IEventDeclaration
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTraces
;
25 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
26 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
27 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
28 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInput
;
29 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
30 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.metadata
.exceptions
.ParseException
;
31 import org
.junit
.After
;
32 import org
.junit
.Before
;
33 import org
.junit
.Test
;
36 * The class <code>StreamTest</code> contains tests for the class
37 * <code>{@link Stream}</code>.
40 * @version $Revision: 1.0 $
42 @SuppressWarnings("javadoc")
43 public class StreamTest
{
45 private static final int TRACE_INDEX
= 0;
47 private Stream fixture
;
53 * the command line arguments
55 public static void main(String
[] args
) {
56 new org
.junit
.runner
.JUnitCore().run(StreamTest
.class);
60 * Perform pre-test initialization.
62 * @throws CTFReaderException
65 public void setUp() throws CTFReaderException
{
66 assumeTrue(CtfTestTraces
.tracesExist());
67 fixture
= new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
));
68 fixture
.setEventContext(new StructDeclaration(1L));
69 fixture
.setPacketContext(new StructDeclaration(1L));
70 fixture
.setEventHeader(new StructDeclaration(1L));
72 fixture
.addInput(new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
73 (FileChannel
) null, CtfTestTraces
.getEmptyFile()));
77 * Perform post-test clean-up.
80 public void tearDown() {
81 // Add additional tear down code here
85 * Run the Stream(CTFTrace) constructor test.
87 * @throws CTFReaderException
90 public void testStream() throws CTFReaderException
{
91 CTFTrace trace
= CtfTestTraces
.getTestTrace(TRACE_INDEX
);
92 Stream result
= new Stream(trace
);
93 assertNotNull(result
);
97 * Run the void addEvent(EventDeclaration) method test with the basic
99 * @throws ParseException
102 public void testAddEvent_base() throws ParseException
{
103 EventDeclaration event
= new EventDeclaration();
104 fixture
.addEvent(event
);
108 * Run the boolean eventContextIsSet() method test.
111 public void testEventContextIsSet() {
112 assertTrue(fixture
.isEventContextSet());
115 * Run the boolean eventContextIsSet() method test.
118 public void testToString() {
119 assertNotNull(fixture
.toString());
123 * Run the boolean eventHeaderIsSet() method test.
126 public void testEventHeaderIsSet() {
127 assertTrue(fixture
.isEventHeaderSet());
131 * Run the StructDeclaration getEventContextDecl() method test.
134 public void testGetEventContextDecl() {
135 assertNotNull(fixture
.getEventContextDecl());
139 * Run the StructDeclaration getEventHeaderDecl() method test.
142 public void testGetEventHeaderDecl() {
143 assertNotNull(fixture
.getEventHeaderDecl());
147 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
150 public void testGetEvents() {
151 HashMap
<Long
, IEventDeclaration
> result
= fixture
.getEvents();
152 assertNotNull(result
);
156 * Run the Long getId() method test.
159 public void testGetId() {
160 Long result
= fixture
.getId();
161 assertNotNull(result
);
165 * Run the StructDeclaration getPacketContextDecl() method test.
168 public void testGetPacketContextDecl() {
169 StructDeclaration result
= fixture
.getPacketContextDecl();
170 assertNotNull(result
);
174 * Run the Set<StreamInput> getStreamInputs() method test.
177 public void testGetStreamInputs() {
178 Set
<StreamInput
> result
= fixture
.getStreamInputs();
179 assertNotNull(result
);
183 * Run the CTFTrace getTrace() method test.
186 public void testGetTrace() {
187 CTFTrace result
= fixture
.getTrace();
188 assertNotNull(result
);
192 * Run the boolean idIsSet() method test.
195 public void testIdIsSet() {
196 boolean result
= fixture
.isIdSet();
201 * Run the boolean packetContextIsSet() method test.
204 public void testPacketContextIsSet() {
205 boolean result
= fixture
.isPacketContextSet();
211 * Run the void setEventContext(StructDeclaration) method test.
214 public void testSetEventContext() {
215 StructDeclaration eventContext
= new StructDeclaration(1L);
216 fixture
.setEventContext(eventContext
);
220 * Run the void setEventHeader(StructDeclaration) method test.
223 public void testSetEventHeader() {
224 StructDeclaration eventHeader
= new StructDeclaration(1L);
225 fixture
.setEventHeader(eventHeader
);
229 * Run the void setId(long) method test.
232 public void testSetId() {
238 * Run the void setPacketContext(StructDeclaration) method test.
241 public void testSetPacketContext() {
242 StructDeclaration packetContext
= new StructDeclaration(1L);
243 fixture
.setPacketContext(packetContext
);