1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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
.tracecompass
.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
.FilenameFilter
;
24 import org
.eclipse
.jdt
.annotation
.NonNull
;
25 import org
.eclipse
.tracecompass
.ctf
.core
.CTFException
;
26 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.IDefinition
;
27 import org
.eclipse
.tracecompass
.ctf
.core
.tests
.shared
.CtfTestTrace
;
28 import org
.eclipse
.tracecompass
.ctf
.core
.trace
.CTFStream
;
29 import org
.eclipse
.tracecompass
.ctf
.core
.trace
.CTFStreamInput
;
30 import org
.junit
.Before
;
31 import org
.junit
.Test
;
34 * The class <code>StreamInputTest</code> contains tests for the class
35 * <code>{@link CTFStreamInput}</code>.
38 * @version $Revision: 1.0 $
40 @SuppressWarnings("javadoc")
41 public class CTFStreamInputTest
{
43 private static final CtfTestTrace testTrace
= CtfTestTrace
.KERNEL
;
45 private CTFStreamInput fixture
;
48 * Perform pre-test initialization.
50 * @throws CTFException
53 public void setUp() throws CTFException
{
54 assumeTrue(testTrace
.exists());
55 fixture
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()), createFile());
56 fixture
.setTimestampEnd(1L);
60 private static File
createFile() {
61 File path
= new File(testTrace
.getPath());
62 final File
[] listFiles
= path
.listFiles(new FilenameFilter() {
64 public boolean accept(File dir
, String name
) {
65 if (name
.contains("hann")) {
71 assertNotNull(listFiles
);
72 final File returnFile
= listFiles
[0];
73 assertNotNull(returnFile
);
78 * Run the StreamInput(Stream,FileChannel,File) constructor test.
81 public void testStreamInput() {
82 assertNotNull(fixture
);
86 * Run the String getFilename() method test.
89 public void testGetFilename() {
90 String result
= fixture
.getFilename();
91 assertNotNull(result
);
95 * Run the String getPath() method test.
98 public void testGetPath() {
99 String result
= fixture
.getScopePath().getPath();
100 assertNotNull(result
);
104 * Run the Stream getStream() method test.
107 public void testGetStream() {
108 CTFStream result
= fixture
.getStream();
109 assertNotNull(result
);
113 * Run the long getTimestampEnd() method test.
116 public void testGetTimestampEnd() {
117 long result
= fixture
.getTimestampEnd();
118 assertTrue(0L < result
);
122 * Run the Definition lookupDefinition(String) method test.
125 public void testLookupDefinition() {
126 IDefinition result
= fixture
.lookupDefinition("id");
131 * Run the void setTimestampEnd(long) method test.
134 public void testSetTimestampEnd() {
135 fixture
.setTimestampEnd(1L);
136 assertEquals(fixture
.getTimestampEnd(), 1L);
143 public void testEquals1() throws CTFException
{
144 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
146 assertFalse(s1
.equals(null));
150 public void testEquals2() throws CTFException
{
151 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
153 assertFalse(s1
.equals(new Long(23L)));
158 public void testEquals3() throws CTFException
{
159 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
161 assertEquals(s1
, s1
);
166 public void testEquals4() throws CTFException
{
167 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
169 s2
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
171 assertEquals(s1
, s2
);
This page took 0.037353 seconds and 5 git commands to generate.