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