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
.assertEquals
;
15 import static org
.junit
.Assert
.assertFalse
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertNull
;
18 import static org
.junit
.Assert
.assertTrue
;
19 import static org
.junit
.Assume
.assumeTrue
;
22 import java
.io
.IOException
;
23 import java
.nio
.channels
.FileChannel
;
25 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
26 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTraces
;
27 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
28 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Stream
;
29 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInput
;
30 import org
.junit
.Before
;
31 import org
.junit
.Test
;
34 * The class <code>StreamInputTest</code> contains tests for the class
35 * <code>{@link StreamInput}</code>.
38 * @version $Revision: 1.0 $
40 @SuppressWarnings("javadoc")
41 public class StreamInputTest
{
43 private static final int TRACE_INDEX
= 0;
45 private StreamInput fixture
;
48 * Perform pre-test initialization.
50 * @throws CTFReaderException
53 public void setUp() throws CTFReaderException
{
54 assumeTrue(CtfTestTraces
.tracesExist());
55 fixture
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
56 (FileChannel
) null, createFile());
57 fixture
.setTimestampEnd(1L);
60 private static File
createFile() {
61 return new File("Tests/traces/trace20m/channel_0");
65 * Run the StreamInput(Stream,FileChannel,File) constructor test.
68 public void testStreamInput() {
69 assertNotNull(fixture
);
73 * Run the FileChannel getFileChannel() method test.
78 public void testGetFileChannel() throws IOException
{
79 FileChannel result
= fixture
.getFileChannel();
87 * Run the String getFilename() method test.
90 public void testGetFilename() {
91 String result
= fixture
.getFilename();
92 assertNotNull(result
);
96 * Run the String getPath() method test.
99 public void testGetPath() {
100 String result
= fixture
.getPath();
101 assertNotNull(result
);
105 * Run the Stream getStream() method test.
108 public void testGetStream() {
109 Stream result
= fixture
.getStream();
110 assertNotNull(result
);
114 * Run the long getTimestampEnd() method test.
117 public void testGetTimestampEnd() {
118 long result
= fixture
.getTimestampEnd();
119 assertTrue(0L < result
);
123 * Run the Definition lookupDefinition(String) method test.
126 public void testLookupDefinition() {
127 Definition result
= fixture
.lookupDefinition("id");
132 * Run the void setTimestampEnd(long) method test.
135 public void testSetTimestampEnd() {
136 fixture
.setTimestampEnd(1L);
137 assertEquals(fixture
.getTimestampEnd(), 1L);
145 public void testEquals1() throws CTFReaderException
{
146 s1
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
147 (FileChannel
) null, createFile());
148 assertFalse(s1
.equals(null));
152 public void testEquals2() throws CTFReaderException
{
153 s1
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
154 (FileChannel
) null, createFile());
155 assertFalse(s1
.equals(new Long(23L)));
159 public void testEquals3() throws CTFReaderException
{
160 s1
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
161 (FileChannel
) null, createFile());
166 public void testEquals4() throws CTFReaderException
{
167 s1
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
168 (FileChannel
) null, createFile());
169 s2
= new StreamInput(new Stream(CtfTestTraces
.getTestTrace(TRACE_INDEX
)),
170 (FileChannel
) null, createFile());
This page took 0.034783 seconds and 5 git commands to generate.