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
;
21 import java
.io
.FilenameFilter
;
23 import org
.eclipse
.jdt
.annotation
.NonNull
;
24 import org
.eclipse
.tracecompass
.ctf
.core
.CTFException
;
25 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.IDefinition
;
26 import org
.eclipse
.tracecompass
.ctf
.core
.tests
.shared
.CtfTestTraceUtils
;
27 import org
.eclipse
.tracecompass
.ctf
.core
.trace
.CTFStream
;
28 import org
.eclipse
.tracecompass
.ctf
.core
.trace
.CTFStreamInput
;
29 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
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 fixture
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)), createFile());
55 fixture
.setTimestampEnd(1L);
58 private static @NonNull File
createFile() throws CTFException
{
59 File path
= new File(CtfTestTraceUtils
.getTrace(testTrace
).getPath());
60 final File
[] listFiles
= path
.listFiles(new FilenameFilter() {
62 public boolean accept(File dir
, String name
) {
63 if (name
.contains("hann")) {
69 assertNotNull(listFiles
);
70 final File returnFile
= listFiles
[0];
71 assertNotNull(returnFile
);
76 * Run the StreamInput(Stream,FileChannel,File) constructor test.
79 public void testStreamInput() {
80 assertNotNull(fixture
);
84 * Run the String getFilename() method test.
87 public void testGetFilename() {
88 String result
= fixture
.getFilename();
89 assertNotNull(result
);
93 * Run the String getPath() method test.
96 public void testGetPath() {
97 String result
= fixture
.getScopePath().getPath();
98 assertNotNull(result
);
102 * Run the Stream getStream() method test.
105 public void testGetStream() {
106 CTFStream result
= fixture
.getStream();
107 assertNotNull(result
);
111 * Run the long getTimestampEnd() method test.
114 public void testGetTimestampEnd() {
115 long result
= fixture
.getTimestampEnd();
116 assertTrue(0L < result
);
120 * Run the Definition lookupDefinition(String) method test.
123 public void testLookupDefinition() {
124 IDefinition result
= fixture
.lookupDefinition("id");
129 * Run the void setTimestampEnd(long) method test.
132 public void testSetTimestampEnd() {
133 fixture
.setTimestampEnd(1L);
134 assertEquals(fixture
.getTimestampEnd(), 1L);
141 public void testEquals1() throws CTFException
{
142 s1
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)),
144 assertFalse(s1
.equals(null));
148 public void testEquals2() throws CTFException
{
149 s1
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)),
151 assertFalse(s1
.equals(new Long(23L)));
156 public void testEquals3() throws CTFException
{
157 s1
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)),
159 assertEquals(s1
, s1
);
164 public void testEquals4() throws CTFException
{
165 s1
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)),
167 s2
= new CTFStreamInput(new CTFStream(CtfTestTraceUtils
.getTrace(testTrace
)),
169 assertEquals(s1
, s2
);
This page took 0.034935 seconds and 5 git commands to generate.