Commit | Line | Data |
---|---|---|
866e5b51 FC |
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; | |
aa572e22 | 7 | |
866e5b51 FC |
8 | import org.eclipse.linuxtools.ctf.core.event.EventDeclaration; |
9 | import org.eclipse.linuxtools.ctf.core.event.EventDefinition; | |
10 | import org.eclipse.linuxtools.ctf.core.tests.TestParams; | |
13be1a8f | 11 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
866e5b51 | 12 | import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader; |
ce2388e0 FC |
13 | import org.eclipse.linuxtools.internal.ctf.core.trace.Stream; |
14 | import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInput; | |
15 | import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputReaderComparator; | |
aa572e22 MK |
16 | import org.junit.After; |
17 | import org.junit.Before; | |
18 | import 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 | */ | |
27 | public 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 | } |