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
;
19 import java
.nio
.channels
.FileChannel
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.event
.IEventDeclaration
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
25 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTrace
;
26 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
27 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
28 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
29 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInput
;
30 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.EventDeclaration
;
31 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.metadata
.exceptions
.ParseException
;
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 CtfTestTrace testTrace
= CtfTestTrace
.KERNEL
;
47 private Stream fixture
;
50 * Perform pre-test initialization.
52 * @throws CTFReaderException
55 public void setUp() throws CTFReaderException
{
56 assumeTrue(testTrace
.exists());
57 fixture
= new Stream(testTrace
.getTrace());
58 fixture
.setEventContext(new StructDeclaration(1L));
59 fixture
.setPacketContext(new StructDeclaration(1L));
60 fixture
.setEventHeader(new StructDeclaration(1L));
62 fixture
.addInput(new StreamInput(new Stream(testTrace
.getTrace()),
63 (FileChannel
) null, new File("")));
67 * Run the Stream(CTFTrace) constructor test.
69 * @throws CTFReaderException
72 public void testStream() throws CTFReaderException
{
73 CTFTrace trace
= testTrace
.getTrace();
74 Stream result
= new Stream(trace
);
75 assertNotNull(result
);
79 * Run the void addEvent(EventDeclaration) method test with the basic
81 * @throws ParseException
84 public void testAddEvent_base() throws ParseException
{
85 EventDeclaration event
= new EventDeclaration();
86 fixture
.addEvent(event
);
90 * Run the boolean eventContextIsSet() method test.
93 public void testEventContextIsSet() {
94 assertTrue(fixture
.isEventContextSet());
97 * Run the boolean eventContextIsSet() method test.
100 public void testToString() {
101 assertNotNull(fixture
.toString());
105 * Run the boolean eventHeaderIsSet() method test.
108 public void testEventHeaderIsSet() {
109 assertTrue(fixture
.isEventHeaderSet());
113 * Run the StructDeclaration getEventContextDecl() method test.
116 public void testGetEventContextDecl() {
117 assertNotNull(fixture
.getEventContextDecl());
121 * Run the StructDeclaration getEventHeaderDecl() method test.
124 public void testGetEventHeaderDecl() {
125 assertNotNull(fixture
.getEventHeaderDecl());
129 * Run the HashMap<Long, EventDeclaration> getEvents() method test.
132 public void testGetEvents() {
133 Map
<Long
, IEventDeclaration
> result
= fixture
.getEvents();
134 assertNotNull(result
);
138 * Run the Long getId() method test.
141 public void testGetId() {
142 Long result
= fixture
.getId();
143 assertNotNull(result
);
147 * Run the StructDeclaration getPacketContextDecl() method test.
150 public void testGetPacketContextDecl() {
151 StructDeclaration result
= fixture
.getPacketContextDecl();
152 assertNotNull(result
);
156 * Run the Set<StreamInput> getStreamInputs() method test.
159 public void testGetStreamInputs() {
160 Set
<StreamInput
> result
= fixture
.getStreamInputs();
161 assertNotNull(result
);
165 * Run the CTFTrace getTrace() method test.
168 public void testGetTrace() {
169 CTFTrace result
= fixture
.getTrace();
170 assertNotNull(result
);
174 * Run the boolean idIsSet() method test.
177 public void testIdIsSet() {
178 boolean result
= fixture
.isIdSet();
183 * Run the boolean packetContextIsSet() method test.
186 public void testPacketContextIsSet() {
187 boolean result
= fixture
.isPacketContextSet();
193 * Run the void setEventContext(StructDeclaration) method test.
196 public void testSetEventContext() {
197 StructDeclaration eventContext
= new StructDeclaration(1L);
198 fixture
.setEventContext(eventContext
);
202 * Run the void setEventHeader(StructDeclaration) method test.
205 public void testSetEventHeader() {
206 StructDeclaration eventHeader
= new StructDeclaration(1L);
207 fixture
.setEventHeader(eventHeader
);
211 * Run the void setId(long) method test.
214 public void testSetId() {
220 * Run the void setPacketContext(StructDeclaration) method test.
223 public void testSetPacketContext() {
224 StructDeclaration packetContext
= new StructDeclaration(1L);
225 fixture
.setPacketContext(packetContext
);