Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5c4e27892035b164d38500ee6cc0503a315b6280 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package org.eclipse.linuxtools.ctf.core.tests.trace;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.nio.channels.FileChannel;
import org.eclipse.linuxtools.ctf.core.event.EventDeclaration;
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
import org.eclipse.linuxtools.ctf.core.tests.TestParams;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.Stream;
import org.eclipse.linuxtools.ctf.core.trace.StreamInput;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReaderComparator;
import org.junit.*;

/**
 * The class <code>StreamInputReaderComparatorTest</code> contains tests for the
 * class <code>{@link StreamInputReaderComparator}</code>.
 * 
 * @author ematkho
 * @version $Revision: 1.0 $
 */
public class StreamInputReaderComparatorTest {

    private StreamInputReaderComparator fixture;

    /**
     * Launch the test.
     * 
     * @param args
     *            the command line arguments
     */
    public static void main(String[] args) {
        new org.junit.runner.JUnitCore().run(StreamInputReaderComparatorTest.class);
    }

    /**
     * Perform pre-test initialization.
     */
    @Before
    public void setUp() {
        fixture = new StreamInputReaderComparator();
    }

    /**
     * Perform post-test clean-up.
     */
    @After
    public void tearDown() {
        // Add additional tear down code here
    }

    /**
     * Run the StreamInputReaderComparator() constructor test.
     */
    @Test
    public void testStreamInputReaderComparator() {
        assertNotNull(fixture);
    }

    /**
     * Run the int compare(StreamInputReader,StreamInputReader) method test.
     * 
     * @throws CTFReaderException 
     */
    @Test
    public void testCompare() throws CTFReaderException {
        StreamInputReader sir1, sir2;
        EventDefinition ed1, ed2;

        sir1 = new StreamInputReader(new StreamInput(new Stream(
                TestParams.createTrace()), (FileChannel) null,
                TestParams.getEmptyFile()));
        ed1 = new EventDefinition(new EventDeclaration(),
                new StreamInputReader(new StreamInput(new Stream(
                        TestParams.createTrace()), (FileChannel) null,
                        TestParams.getEmptyFile())));
        ed1.timestamp = 1L;
        sir1.setCurrentEvent(ed1);

        sir2 = new StreamInputReader(new StreamInput(new Stream(
                TestParams.createTrace()), (FileChannel) null,
                TestParams.getEmptyFile()));
        ed2 = new EventDefinition(new EventDeclaration(),
                new StreamInputReader(new StreamInput(new Stream(
                        TestParams.createTrace()), (FileChannel) null,
                        TestParams.getEmptyFile())));

        ed2.timestamp = 1L;
        sir2.setCurrentEvent(ed2);

        int result = fixture.compare(sir1, sir2);
        assertEquals(0, result);
    }
}

Back to the top