lttng: Restrict version of jdt.annotation in Tycho target platform
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamInputTest.java
CommitLineData
4bd7f2db
AM
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
7 *
8 * Contributors:
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11
866e5b51
FC
12package org.eclipse.linuxtools.ctf.core.tests.trace;
13
4dd0eaed
MK
14import static org.junit.Assert.assertEquals;
15import static org.junit.Assert.assertFalse;
866e5b51
FC
16import static org.junit.Assert.assertNotNull;
17import static org.junit.Assert.assertNull;
18import static org.junit.Assert.assertTrue;
e5acb357 19import static org.junit.Assume.assumeTrue;
866e5b51
FC
20
21import java.io.File;
8e15b929 22import java.io.FilenameFilter;
866e5b51
FC
23
24import org.eclipse.linuxtools.ctf.core.event.types.Definition;
9ac63b5b 25import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
13be1a8f 26import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
486efb2e
AM
27import org.eclipse.linuxtools.ctf.core.trace.Stream;
28import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
866e5b51
FC
29import org.junit.Before;
30import org.junit.Test;
31
32/**
33 * The class <code>StreamInputTest</code> contains tests for the class
34 * <code>{@link StreamInput}</code>.
4dd0eaed 35 *
866e5b51
FC
36 * @author ematkho
37 * @version $Revision: 1.0 $
38 */
be6df2d8 39@SuppressWarnings("javadoc")
866e5b51
FC
40public class StreamInputTest {
41
9ac63b5b 42 private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
32bf80d2 43
866e5b51
FC
44 private StreamInput fixture;
45
866e5b51
FC
46 /**
47 * Perform pre-test initialization.
4dd0eaed
MK
48 *
49 * @throws CTFReaderException
866e5b51
FC
50 */
51 @Before
13be1a8f 52 public void setUp() throws CTFReaderException {
9ac63b5b 53 assumeTrue(testTrace.exists());
8e15b929 54 fixture = new StreamInput(new Stream(testTrace.getTrace()), createFile());
866e5b51
FC
55 fixture.setTimestampEnd(1L);
56 }
57
866e5b51 58 private static File createFile() {
8e15b929
MK
59 File path = new File(testTrace.getPath());
60 return path.listFiles(new FilenameFilter() {
61 @Override
62 public boolean accept(File dir, String name) {
63 if (name.contains("hann")) {
64 return true;
65 }
66 return false;
67 }
68 })[0];
866e5b51
FC
69 }
70
71 /**
72 * Run the StreamInput(Stream,FileChannel,File) constructor test.
73 */
74 @Test
75 public void testStreamInput() {
76 assertNotNull(fixture);
77 }
78
866e5b51
FC
79 /**
80 * Run the String getFilename() method test.
81 */
82 @Test
83 public void testGetFilename() {
84 String result = fixture.getFilename();
85 assertNotNull(result);
86 }
87
866e5b51
FC
88 /**
89 * Run the String getPath() method test.
90 */
91 @Test
92 public void testGetPath() {
a4fa4e36 93 String result = fixture.getScopePath().toString();
866e5b51
FC
94 assertNotNull(result);
95 }
96
97 /**
98 * Run the Stream getStream() method test.
99 */
100 @Test
101 public void testGetStream() {
102 Stream result = fixture.getStream();
103 assertNotNull(result);
104 }
105
106 /**
107 * Run the long getTimestampEnd() method test.
108 */
109 @Test
110 public void testGetTimestampEnd() {
111 long result = fixture.getTimestampEnd();
112 assertTrue(0L < result);
113 }
114
115 /**
116 * Run the Definition lookupDefinition(String) method test.
117 */
118 @Test
119 public void testLookupDefinition() {
4a9c1f07 120 Definition result = fixture.lookupDefinition("id");
866e5b51
FC
121 assertNull(result);
122 }
123
124 /**
125 * Run the void setTimestampEnd(long) method test.
126 */
127 @Test
128 public void testSetTimestampEnd() {
129 fixture.setTimestampEnd(1L);
4dd0eaed
MK
130 assertEquals(fixture.getTimestampEnd(), 1L);
131 }
132
133 StreamInput s1;
134 StreamInput s2;
135
4dd0eaed 136 @Test
8e15b929 137 public void testEquals1() throws CTFReaderException {
9ac63b5b 138 s1 = new StreamInput(new Stream(testTrace.getTrace()),
8e15b929 139 createFile());
4dd0eaed
MK
140 assertFalse(s1.equals(null));
141 }
142
143 @Test
8e15b929 144 public void testEquals2() throws CTFReaderException {
9ac63b5b 145 s1 = new StreamInput(new Stream(testTrace.getTrace()),
8e15b929 146 createFile());
4dd0eaed
MK
147 assertFalse(s1.equals(new Long(23L)));
148
149 }
8e15b929 150
4dd0eaed 151 @Test
8e15b929 152 public void testEquals3() throws CTFReaderException {
9ac63b5b 153 s1 = new StreamInput(new Stream(testTrace.getTrace()),
8e15b929
MK
154 createFile());
155 assertEquals(s1, s1);
4dd0eaed
MK
156
157 }
8e15b929 158
4dd0eaed 159 @Test
8e15b929 160 public void testEquals4() throws CTFReaderException {
9ac63b5b 161 s1 = new StreamInput(new Stream(testTrace.getTrace()),
8e15b929 162 createFile());
9ac63b5b 163 s2 = new StreamInput(new Stream(testTrace.getTrace()),
8e15b929
MK
164 createFile());
165 assertEquals(s1, s2);
4dd0eaed 166 }
866e5b51 167}
This page took 0.048105 seconds and 5 git commands to generate.