9a1e75ab641d9b0f8fc5cb05712c7812f72b5578
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamInputTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.trace;
2
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;
8
9 import java.io.File;
10 import java.io.IOException;
11 import java.nio.channels.FileChannel;
12
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.ctf.core.trace.Stream;
17 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
18 import org.junit.After;
19 import org.junit.Before;
20 import org.junit.Test;
21
22 /**
23 * The class <code>StreamInputTest</code> contains tests for the class
24 * <code>{@link StreamInput}</code>.
25 *
26 * @author ematkho
27 * @version $Revision: 1.0 $
28 */
29 @SuppressWarnings("javadoc")
30 public class StreamInputTest {
31
32 private StreamInput fixture;
33
34 /**
35 * Launch the test.
36 *
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.
46 *
47 * @throws CTFReaderException
48 */
49 @Before
50 public void setUp() throws CTFReaderException {
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.
78 *
79 * @throws IOException
80 */
81 @Test
82 public void testGetFileChannel() throws IOException {
83 FileChannel result = fixture.getFileChannel();
84 assertNull(result);
85 if (result != null) {
86 result.close();
87 }
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 String getPath() method test.
101 */
102 @Test
103 public void testGetPath() {
104 String result = fixture.getPath();
105 assertNotNull(result);
106 }
107
108 /**
109 * Run the Stream getStream() method test.
110 */
111 @Test
112 public void testGetStream() {
113 Stream result = fixture.getStream();
114 assertNotNull(result);
115 }
116
117 /**
118 * Run the long getTimestampEnd() method test.
119 */
120 @Test
121 public void testGetTimestampEnd() {
122 long result = fixture.getTimestampEnd();
123 assertTrue(0L < result);
124 }
125
126 /**
127 * Run the Definition lookupDefinition(String) method test.
128 */
129 @Test
130 public void testLookupDefinition() {
131 Definition result = fixture.lookupDefinition("id"); //$NON-NLS-1$
132 assertNull(result);
133 }
134
135 /**
136 * Run the void setTimestampEnd(long) method test.
137 */
138 @Test
139 public void testSetTimestampEnd() {
140 fixture.setTimestampEnd(1L);
141 assertEquals(fixture.getTimestampEnd(), 1L);
142 }
143
144 StreamInput s1;
145 StreamInput s2;
146
147
148 @Test
149 public void testEquals1() throws CTFReaderException{
150 s1 = new StreamInput(new Stream(TestParams.createTrace()),
151 (FileChannel) null, createFile());
152 assertFalse(s1.equals(null));
153 }
154
155 @Test
156 public void testEquals2() throws CTFReaderException{
157 s1 = new StreamInput(new Stream(TestParams.createTrace()),
158 (FileChannel) null, createFile());
159 assertFalse(s1.equals(new Long(23L)));
160
161 }
162 @Test
163 public void testEquals3() throws CTFReaderException{
164 s1 = new StreamInput(new Stream(TestParams.createTrace()),
165 (FileChannel) null, createFile());
166 assertEquals(s1,s1);
167
168 }
169 @Test
170 public void testEquals4() throws CTFReaderException{
171 s1 = new StreamInput(new Stream(TestParams.createTrace()),
172 (FileChannel) null, createFile());
173 s2 = new StreamInput(new Stream(TestParams.createTrace()),
174 (FileChannel) null, createFile());
175 assertEquals(s1,s2);
176 }
177 }
This page took 0.034323 seconds and 5 git commands to generate.