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