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
.Before
;
32 import org
.junit
.Test
;
35 * The class <code>StreamTest</code> contains tests for the class
36 * <code>{@link Stream}</code>.
39 * @version $Revision: 1.0 $
41 @SuppressWarnings("javadoc")
42 public class StreamTest
{
44 private static final int TRACE_INDEX
= 0;
46 private Stream fixture
;
49 * Perform pre-test initialization.
51 * @throws CTFReaderException
54 public void setUp() throws CTFReaderException
{
55 assumeTrue(CtfTestTraces
.tracesExist());
56 fixture
= new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
));
57 fixture
.setEventContext(new StructDeclaration(1L));
58 fixture
.setPacketContext(new StructDeclaration(1L));
59 fixture
.setEventHeader(new StructDeclaration(1L));
61 fixture
.addInput(new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
62 (FileChannel
) null, CtfTestTraces
.getEmptyFile()));
66 * Run the Stream(CTFTrace) constructor test.
68 * @throws CTFReaderException
71 public void testStream() throws CTFReaderException
{
72 CTFTrace trace
= CtfTestTraces
.getTestTrace(TRACE_INDEX
);
73 Stream result
= new Stream(trace
);
74 assertNotNull(result
);
78 * Run the void addEvent(EventDeclaration) method test with the basic
80 * @throws ParseException
83 public void testAddEvent_base() throws ParseException
{
84 EventDeclaration event
= new EventDeclaration();
85 fixture
.addEvent(event
);
89 * Run the boolean eventContextIsSet() method test.
92 public void testEventContextIsSet() {
93 assertTrue(fixture
.isEventContextSet());
96 * Run the boolean eventContextIsSet() method test.
99 public void testToString() {
100 assertNotNull(fixture
.toString());
104 * Run the boolean eventHeaderIsSet() method test.
107 public void testEventHeaderIsSet() {
108 assertTrue(fixture
.isEventHeaderSet());
112 * Run the StructDeclaration getEventContextDecl() method test.
115 public void testGetEventContextDecl() {
116 assertNotNull(fixture
.getEventContextDecl());
120 * Run the StructDeclaration getEventHeaderDecl() method test.
123 public void testGetEventHeaderDecl() {
124 assertNotNull(fixture
.getEventHeaderDecl());
128 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
131 public void testGetEvents() {
132 HashMap
<Long
, IEventDeclaration
> result
= fixture
.getEvents();
133 assertNotNull(result
);
137 * Run the Long getId() method test.
140 public void testGetId() {
141 Long result
= fixture
.getId();
142 assertNotNull(result
);
146 * Run the StructDeclaration getPacketContextDecl() method test.
149 public void testGetPacketContextDecl() {
150 StructDeclaration result
= fixture
.getPacketContextDecl();
151 assertNotNull(result
);
155 * Run the Set<StreamInput> getStreamInputs() method test.
158 public void testGetStreamInputs() {
159 Set
<StreamInput
> result
= fixture
.getStreamInputs();
160 assertNotNull(result
);
164 * Run the CTFTrace getTrace() method test.
167 public void testGetTrace() {
168 CTFTrace result
= fixture
.getTrace();
169 assertNotNull(result
);
173 * Run the boolean idIsSet() method test.
176 public void testIdIsSet() {
177 boolean result
= fixture
.isIdSet();
182 * Run the boolean packetContextIsSet() method test.
185 public void testPacketContextIsSet() {
186 boolean result
= fixture
.isPacketContextSet();
192 * Run the void setEventContext(StructDeclaration) method test.
195 public void testSetEventContext() {
196 StructDeclaration eventContext
= new StructDeclaration(1L);
197 fixture
.setEventContext(eventContext
);
201 * Run the void setEventHeader(StructDeclaration) method test.
204 public void testSetEventHeader() {
205 StructDeclaration eventHeader
= new StructDeclaration(1L);
206 fixture
.setEventHeader(eventHeader
);
210 * Run the void setId(long) method test.
213 public void testSetId() {
219 * Run the void setPacketContext(StructDeclaration) method test.
222 public void testSetPacketContext() {
223 StructDeclaration packetContext
= new StructDeclaration(1L);
224 fixture
.setPacketContext(packetContext
);