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
.FilenameFilter
;
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
.CTFStream
;
28 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFStreamInput
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
33 * The class <code>StreamInputTest</code> contains tests for the class
34 * <code>{@link CTFStreamInput}</code>.
37 * @version $Revision: 1.0 $
39 @SuppressWarnings("javadoc")
40 public class CTFStreamInputTest
{
42 private static final CtfTestTrace testTrace
= CtfTestTrace
.KERNEL
;
44 private CTFStreamInput fixture
;
47 * Perform pre-test initialization.
49 * @throws CTFReaderException
52 public void setUp() throws CTFReaderException
{
53 assumeTrue(testTrace
.exists());
54 fixture
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()), createFile());
55 fixture
.setTimestampEnd(1L);
58 private static File
createFile() {
59 File path
= new File(testTrace
.getPath());
60 return path
.listFiles(new FilenameFilter() {
62 public boolean accept(File dir
, String name
) {
63 if (name
.contains("hann")) {
72 * Run the StreamInput(Stream,FileChannel,File) constructor test.
75 public void testStreamInput() {
76 assertNotNull(fixture
);
80 * Run the String getFilename() method test.
83 public void testGetFilename() {
84 String result
= fixture
.getFilename();
85 assertNotNull(result
);
89 * Run the String getPath() method test.
92 public void testGetPath() {
93 String result
= fixture
.getScopePath().toString();
94 assertNotNull(result
);
98 * Run the Stream getStream() method test.
101 public void testGetStream() {
102 CTFStream result
= fixture
.getStream();
103 assertNotNull(result
);
107 * Run the long getTimestampEnd() method test.
110 public void testGetTimestampEnd() {
111 long result
= fixture
.getTimestampEnd();
112 assertTrue(0L < result
);
116 * Run the Definition lookupDefinition(String) method test.
119 public void testLookupDefinition() {
120 Definition result
= fixture
.lookupDefinition("id");
125 * Run the void setTimestampEnd(long) method test.
128 public void testSetTimestampEnd() {
129 fixture
.setTimestampEnd(1L);
130 assertEquals(fixture
.getTimestampEnd(), 1L);
137 public void testEquals1() throws CTFReaderException
{
138 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
140 assertFalse(s1
.equals(null));
144 public void testEquals2() throws CTFReaderException
{
145 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
147 assertFalse(s1
.equals(new Long(23L)));
152 public void testEquals3() throws CTFReaderException
{
153 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
155 assertEquals(s1
, s1
);
160 public void testEquals4() throws CTFReaderException
{
161 s1
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
163 s2
= new CTFStreamInput(new CTFStream(testTrace
.getTrace()),
165 assertEquals(s1
, s2
);
This page took 0.034317 seconds and 5 git commands to generate.