Commit | Line | Data |
---|---|---|
866e5b51 FC |
1 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
2 | ||
3 | import static org.junit.Assert.assertNotNull; | |
4 | import static org.junit.Assert.assertNull; | |
5 | import static org.junit.Assert.assertTrue; | |
6 | ||
7 | import java.io.File; | |
79cb3749 | 8 | import java.io.IOException; |
866e5b51 FC |
9 | import java.nio.channels.FileChannel; |
10 | ||
11 | import org.eclipse.linuxtools.ctf.core.event.types.Definition; | |
12 | import org.eclipse.linuxtools.ctf.core.tests.TestParams; | |
13be1a8f | 13 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
ce2388e0 FC |
14 | import org.eclipse.linuxtools.internal.ctf.core.trace.Stream; |
15 | import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInput; | |
16 | import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndex; | |
866e5b51 FC |
17 | import org.junit.After; |
18 | import org.junit.Before; | |
19 | import org.junit.Test; | |
20 | ||
21 | /** | |
22 | * The class <code>StreamInputTest</code> contains tests for the class | |
23 | * <code>{@link StreamInput}</code>. | |
24 | * | |
25 | * @author ematkho | |
26 | * @version $Revision: 1.0 $ | |
27 | */ | |
28 | public class StreamInputTest { | |
29 | ||
30 | private StreamInput fixture; | |
31 | ||
32 | /** | |
33 | * Launch the test. | |
34 | * | |
35 | * @param args | |
36 | * the command line arguments | |
37 | */ | |
38 | public static void main(String[] args) { | |
39 | new org.junit.runner.JUnitCore().run(StreamInputTest.class); | |
40 | } | |
41 | ||
42 | /** | |
43 | * Perform pre-test initialization. | |
13be1a8f AM |
44 | * |
45 | * @throws CTFReaderException | |
866e5b51 FC |
46 | */ |
47 | @Before | |
13be1a8f | 48 | public void setUp() throws CTFReaderException { |
866e5b51 FC |
49 | fixture = new StreamInput(new Stream(TestParams.createTrace()), |
50 | (FileChannel) null, createFile()); | |
51 | fixture.setTimestampEnd(1L); | |
52 | } | |
53 | ||
54 | /** | |
55 | * Perform post-test clean-up. | |
56 | */ | |
57 | @After | |
58 | public void tearDown() { | |
59 | // Add additional tear down code here | |
60 | } | |
61 | ||
62 | private static File createFile() { | |
63 | return new File("Tests/traces/trace20m/channel_0"); //$NON-NLS-1$ | |
64 | } | |
65 | ||
66 | /** | |
67 | * Run the StreamInput(Stream,FileChannel,File) constructor test. | |
68 | */ | |
69 | @Test | |
70 | public void testStreamInput() { | |
71 | assertNotNull(fixture); | |
72 | } | |
73 | ||
74 | /** | |
75 | * Run the FileChannel getFileChannel() method test. | |
79cb3749 AM |
76 | * |
77 | * @throws IOException | |
866e5b51 FC |
78 | */ |
79 | @Test | |
79cb3749 | 80 | public void testGetFileChannel() throws IOException { |
866e5b51 FC |
81 | FileChannel result = fixture.getFileChannel(); |
82 | assertNull(result); | |
79cb3749 AM |
83 | if (result != null) { |
84 | result.close(); | |
85 | } | |
866e5b51 FC |
86 | } |
87 | ||
88 | /** | |
89 | * Run the String getFilename() method test. | |
90 | */ | |
91 | @Test | |
92 | public void testGetFilename() { | |
93 | String result = fixture.getFilename(); | |
94 | assertNotNull(result); | |
95 | } | |
96 | ||
97 | /** | |
98 | * Run the StreamInputPacketIndex getIndex() method test. | |
99 | */ | |
100 | @Test | |
101 | public void testGetIndex() { | |
102 | StreamInputPacketIndex result = fixture.getIndex(); | |
103 | assertNotNull(result); | |
104 | } | |
105 | ||
106 | /** | |
107 | * Run the String getPath() method test. | |
108 | */ | |
109 | @Test | |
110 | public void testGetPath() { | |
111 | String result = fixture.getPath(); | |
112 | assertNotNull(result); | |
113 | } | |
114 | ||
115 | /** | |
116 | * Run the Stream getStream() method test. | |
117 | */ | |
118 | @Test | |
119 | public void testGetStream() { | |
120 | Stream result = fixture.getStream(); | |
121 | assertNotNull(result); | |
122 | } | |
123 | ||
124 | /** | |
125 | * Run the long getTimestampEnd() method test. | |
126 | */ | |
127 | @Test | |
128 | public void testGetTimestampEnd() { | |
129 | long result = fixture.getTimestampEnd(); | |
130 | assertTrue(0L < result); | |
131 | } | |
132 | ||
133 | /** | |
134 | * Run the Definition lookupDefinition(String) method test. | |
135 | */ | |
136 | @Test | |
137 | public void testLookupDefinition() { | |
138 | Definition result = fixture.lookupDefinition("id"); //$NON-NLS-1$ | |
139 | assertNull(result); | |
140 | } | |
141 | ||
142 | /** | |
143 | * Run the void setTimestampEnd(long) method test. | |
144 | */ | |
145 | @Test | |
146 | public void testSetTimestampEnd() { | |
147 | fixture.setTimestampEnd(1L); | |
148 | } | |
149 | } |