Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / StreamInputReaderComparatorTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.trace;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5
6 import java.nio.channels.FileChannel;
7 import org.eclipse.linuxtools.ctf.core.event.EventDeclaration;
8 import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
9 import org.eclipse.linuxtools.ctf.core.tests.TestParams;
10 import org.eclipse.linuxtools.ctf.core.trace.Stream;
11 import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
12 import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
13 import org.eclipse.linuxtools.ctf.core.trace.StreamInputReaderComparator;
14 import org.junit.*;
15
16 /**
17 * The class <code>StreamInputReaderComparatorTest</code> contains tests for the
18 * class <code>{@link StreamInputReaderComparator}</code>.
19 *
20 * @author ematkho
21 * @version $Revision: 1.0 $
22 */
23 public class StreamInputReaderComparatorTest {
24
25 private StreamInputReaderComparator fixture;
26
27 /**
28 * Launch the test.
29 *
30 * @param args
31 * the command line arguments
32 */
33 public static void main(String[] args) {
34 new org.junit.runner.JUnitCore().run(StreamInputReaderComparatorTest.class);
35 }
36
37 /**
38 * Perform pre-test initialization.
39 */
40 @Before
41 public void setUp() {
42 fixture = new StreamInputReaderComparator();
43 }
44
45 /**
46 * Perform post-test clean-up.
47 */
48 @After
49 public void tearDown() {
50 // Add additional tear down code here
51 }
52
53 /**
54 * Run the StreamInputReaderComparator() constructor test.
55 */
56 @Test
57 public void testStreamInputReaderComparator() {
58 assertNotNull(fixture);
59 }
60
61 /**
62 * Run the int compare(StreamInputReader,StreamInputReader) method test.
63 */
64 @Test
65 public void testCompare() {
66 StreamInputReader sir1, sir2;
67 EventDefinition ed1, ed2;
68
69 sir1 = new StreamInputReader(new StreamInput(new Stream(
70 TestParams.createTrace()), (FileChannel) null,
71 TestParams.getEmptyFile()));
72 ed1 = new EventDefinition(new EventDeclaration(),
73 new StreamInputReader(new StreamInput(new Stream(
74 TestParams.createTrace()), (FileChannel) null,
75 TestParams.getEmptyFile())));
76 ed1.timestamp = 1L;
77 sir1.setCurrentEvent(ed1);
78
79 sir2 = new StreamInputReader(new StreamInput(new Stream(
80 TestParams.createTrace()), (FileChannel) null,
81 TestParams.getEmptyFile()));
82 ed2 = new EventDefinition(new EventDeclaration(),
83 new StreamInputReader(new StreamInput(new Stream(
84 TestParams.createTrace()), (FileChannel) null,
85 TestParams.getEmptyFile())));
86
87 ed2.timestamp = 1L;
88 sir2.setCurrentEvent(ed2);
89
90 int result = fixture.compare(sir1, sir2);
91 assertEquals(0, result);
92 }
93 }
This page took 0.034583 seconds and 6 git commands to generate.