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
.nio
.channels
.FileChannel
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
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
.Stream
;
28 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInput
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
33 * The class <code>StreamInputTest</code> contains tests for the class
34 * <code>{@link StreamInput}</code>.
37 * @version $Revision: 1.0 $
39 @SuppressWarnings("javadoc")
40 public class StreamInputTest
{
42 private static final CtfTestTrace testTrace
= CtfTestTrace
.KERNEL
;
44 private StreamInput fixture
;
47 * Perform pre-test initialization.
49 * @throws CTFReaderException
52 public void setUp() throws CTFReaderException
{
53 assumeTrue(testTrace
.exists());
54 fixture
= new StreamInput(new Stream(testTrace
.getTrace()),
55 (FileChannel
) null, createFile());
56 fixture
.setTimestampEnd(1L);
59 private static File
createFile() {
60 return new File("Tests/traces/trace20m/channel_0");
64 * Run the StreamInput(Stream,FileChannel,File) constructor test.
67 public void testStreamInput() {
68 assertNotNull(fixture
);
72 * Run the FileChannel getFileChannel() method test.
75 public void testGetFileChannel() {
76 FileChannel result
= fixture
.getFileChannel();
81 * Run the String getFilename() method test.
84 public void testGetFilename() {
85 String result
= fixture
.getFilename();
86 assertNotNull(result
);
90 * Run the String getPath() method test.
93 public void testGetPath() {
94 String result
= fixture
.getPath();
95 assertNotNull(result
);
99 * Run the Stream getStream() method test.
102 public void testGetStream() {
103 Stream result
= fixture
.getStream();
104 assertNotNull(result
);
108 * Run the long getTimestampEnd() method test.
111 public void testGetTimestampEnd() {
112 long result
= fixture
.getTimestampEnd();
113 assertTrue(0L < result
);
117 * Run the Definition lookupDefinition(String) method test.
120 public void testLookupDefinition() {
121 Definition result
= fixture
.lookupDefinition("id");
126 * Run the void setTimestampEnd(long) method test.
129 public void testSetTimestampEnd() {
130 fixture
.setTimestampEnd(1L);
131 assertEquals(fixture
.getTimestampEnd(), 1L);
139 public void testEquals1() throws CTFReaderException
{
140 s1
= new StreamInput(new Stream(testTrace
.getTrace()),
141 (FileChannel
) null, createFile());
142 assertFalse(s1
.equals(null));
146 public void testEquals2() throws CTFReaderException
{
147 s1
= new StreamInput(new Stream(testTrace
.getTrace()),
148 (FileChannel
) null, createFile());
149 assertFalse(s1
.equals(new Long(23L)));
153 public void testEquals3() throws CTFReaderException
{
154 s1
= new StreamInput(new Stream(testTrace
.getTrace()),
155 (FileChannel
) null, createFile());
160 public void testEquals4() throws CTFReaderException
{
161 s1
= new StreamInput(new Stream(testTrace
.getTrace()),
162 (FileChannel
) null, createFile());
163 s2
= new StreamInput(new Stream(testTrace
.getTrace()),
164 (FileChannel
) null, createFile());
This page took 0.036592 seconds and 5 git commands to generate.