1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.trace
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertFalse
;
5 import static org
.junit
.Assert
.assertNotNull
;
6 import static org
.junit
.Assert
.assertNull
;
7 import static org
.junit
.Assert
.assertTrue
;
10 import java
.io
.IOException
;
11 import java
.nio
.channels
.FileChannel
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
16 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.trace
.Stream
;
17 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.trace
.StreamInput
;
18 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.trace
.StreamInputPacketIndex
;
19 import org
.junit
.After
;
20 import org
.junit
.Before
;
21 import org
.junit
.Test
;
24 * The class <code>StreamInputTest</code> contains tests for the class
25 * <code>{@link StreamInput}</code>.
28 * @version $Revision: 1.0 $
30 public class StreamInputTest
{
32 private StreamInput fixture
;
38 * the command line arguments
40 public static void main(String
[] args
) {
41 new org
.junit
.runner
.JUnitCore().run(StreamInputTest
.class);
45 * Perform pre-test initialization.
47 * @throws CTFReaderException
50 public void setUp() throws CTFReaderException
{
51 fixture
= new StreamInput(new Stream(TestParams
.createTrace()),
52 (FileChannel
) null, createFile());
53 fixture
.setTimestampEnd(1L);
57 * Perform post-test clean-up.
60 public void tearDown() {
61 // Add additional tear down code here
64 private static File
createFile() {
65 return new File("Tests/traces/trace20m/channel_0"); //$NON-NLS-1$
69 * Run the StreamInput(Stream,FileChannel,File) constructor test.
72 public void testStreamInput() {
73 assertNotNull(fixture
);
77 * Run the FileChannel getFileChannel() method test.
82 public void testGetFileChannel() throws IOException
{
83 FileChannel result
= fixture
.getFileChannel();
91 * Run the String getFilename() method test.
94 public void testGetFilename() {
95 String result
= fixture
.getFilename();
96 assertNotNull(result
);
100 * Run the StreamInputPacketIndex getIndex() method test.
103 public void testGetIndex() {
104 StreamInputPacketIndex result
= fixture
.getIndex();
105 assertNotNull(result
);
109 * Run the String getPath() method test.
112 public void testGetPath() {
113 String result
= fixture
.getPath();
114 assertNotNull(result
);
118 * Run the Stream getStream() method test.
121 public void testGetStream() {
122 Stream result
= fixture
.getStream();
123 assertNotNull(result
);
127 * Run the long getTimestampEnd() method test.
130 public void testGetTimestampEnd() {
131 long result
= fixture
.getTimestampEnd();
132 assertTrue(0L < result
);
136 * Run the Definition lookupDefinition(String) method test.
139 public void testLookupDefinition() {
140 Definition result
= fixture
.lookupDefinition("id"); //$NON-NLS-1$
145 * Run the void setTimestampEnd(long) method test.
148 public void testSetTimestampEnd() {
149 fixture
.setTimestampEnd(1L);
150 assertEquals(fixture
.getTimestampEnd(), 1L);
158 public void testEquals1() throws CTFReaderException
{
159 s1
= new StreamInput(new Stream(TestParams
.createTrace()),
160 (FileChannel
) null, createFile());
161 assertFalse(s1
.equals(null));
165 public void testEquals2() throws CTFReaderException
{
166 s1
= new StreamInput(new Stream(TestParams
.createTrace()),
167 (FileChannel
) null, createFile());
168 assertFalse(s1
.equals(new Long(23L)));
172 public void testEquals3() throws CTFReaderException
{
173 s1
= new StreamInput(new Stream(TestParams
.createTrace()),
174 (FileChannel
) null, createFile());
179 public void testEquals4() throws CTFReaderException
{
180 s1
= new StreamInput(new Stream(TestParams
.createTrace()),
181 (FileChannel
) null, createFile());
182 s2
= new StreamInput(new Stream(TestParams
.createTrace()),
183 (FileChannel
) null, createFile());
187 public void testEquals5() throws CTFReaderException
{
188 s1
= new StreamInput(new Stream(TestParams
.createTrace()),
189 (FileChannel
) null, createFile());
190 s2
= new StreamInput(new Stream(null),
191 (FileChannel
) null, new File("")); //$NON-NLS-1$
192 assertFalse(s1
.equals(s2
));
195 public void testEquals6(){
196 s1
= new StreamInput(new Stream(null),
197 (FileChannel
) null, null);
198 s2
= new StreamInput(new Stream(null),
199 (FileChannel
) null, new File("")); //$NON-NLS-1$
202 assertFalse(s1
.equals(s2
));
205 public void testEquals7() throws CTFReaderException
{
206 s1
= new StreamInput(new Stream(null),
207 (FileChannel
) null, new File("")); //$NON-NLS-1$
208 s2
= new StreamInput(new Stream(TestParams
.createTrace()),
209 (FileChannel
) null, createFile());
210 assertFalse(s1
.equals(s2
));