1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial generation with CodePro tools
11 * Alexandre Montplaisir - Clean up, consolidate redundant tests
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertFalse
;
18 import static org
.junit
.Assert
.assertNotNull
;
19 import static org
.junit
.Assert
.assertTrue
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfIterator
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfLocation
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfLocationInfo
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
27 import org
.junit
.After
;
28 import org
.junit
.Before
;
29 import org
.junit
.Test
;
32 * The class <code>CtfIteratorTest</code> contains tests for the class
33 * <code>{@link CtfIterator}</code>.
38 public class CtfIteratorTest
{
40 private CtfIterator fixture
;
43 * Perform pre-test initialization.
45 * @throws TmfTraceException
46 * If the test trace is not found
49 public void setUp() throws TmfTraceException
{
50 fixture
= new CtfIterator(createTrace());
51 CtfLocation ctfLocation
= new CtfLocation(new CtfLocationInfo(1, 0));
52 fixture
.setLocation(ctfLocation
);
53 fixture
.increaseRank();
57 * Perform post-test clean-up.
60 public void tearDown() {
65 private static CtfTmfTrace
createTrace() throws TmfTraceException
{
66 return TestParams
.createTrace();
70 * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
72 * @throws TmfTraceException
73 * If the test trace is not found
76 public void testCtfIterator_noinit() throws TmfTraceException
{
77 CtfTmfTrace trace
= createTrace();
78 CtfIterator result
= new CtfIterator(trace
);
79 assertNotNull(result
);
83 * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
85 * @throws TmfTraceException
86 * If the test trace is not found
89 public void testCtfIterator_init() throws TmfTraceException
{
90 CtfTmfTrace trace
= createTrace();
91 trace
.init("test"); //$NON-NLS-1$
92 CtfIterator result
= new CtfIterator(trace
);
94 assertNotNull(result
);
98 * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
99 * specifies an initial position for the iterator.
101 * @throws TmfTraceException
102 * If the test trace is not found
105 public void testCtfIterator_position() throws TmfTraceException
{
106 CtfTmfTrace trace
= createTrace();
107 long timestampValue
= 1L;
109 CtfIterator result
= new CtfIterator(trace
, new CtfLocationInfo(timestampValue
, 0), rank
);
111 assertNotNull(result
);
116 * Run the boolean advance() method test.
119 public void testAdvance() {
120 boolean result
= fixture
.advance();
125 * Run the CtfIterator clone() method test.
128 public void testClone() {
129 CtfIterator result
= fixture
.clone();
130 assertNotNull(result
);
134 * Run the int compareTo(CtfIterator) method test.
136 * @throws TmfTraceException
137 * If the test trace is not found
140 public void testCompareTo() throws TmfTraceException
{
141 CtfIterator o
= new CtfIterator(createTrace());
142 int result
= fixture
.compareTo(o
);
144 assertEquals(1L, result
);
148 * Run the boolean equals(Object) method test. Compare with another iterator
151 * @throws TmfTraceException
152 * If the test trace is not found
155 public void testEquals_other() throws TmfTraceException
{
156 CtfIterator obj
= new CtfIterator(createTrace());
157 CtfLocation ctfLocation1
= new CtfLocation(new CtfLocationInfo(1, 0));
158 obj
.setLocation(ctfLocation1
);
161 boolean result
= fixture
.equals(obj
);
166 * Run the boolean equals(Object) method test. Compare with an empty object.
169 public void testEquals_empty() {
170 Object obj
= new Object();
171 boolean result
= fixture
.equals(obj
);
177 * Run the CtfTmfTrace getCtfTmfTrace() method test.
180 public void testGetCtfTmfTrace() {
181 CtfTmfTrace result
= fixture
.getCtfTmfTrace();
182 assertNotNull(result
);
186 * Run the CtfTmfEvent getCurrentEvent() method test.
189 public void testGetCurrentEvent() {
190 CtfTmfEvent result
= fixture
.getCurrentEvent();
191 assertNotNull(result
);
195 * Run the CtfLocation getLocation() method test.
198 public void testGetLocation() {
199 CtfLocation result
= fixture
.getLocation();
200 assertNotNull(result
);
204 * Run the long getRank() method test.
207 public void testGetRank() {
208 long result
= fixture
.getRank();
209 assertEquals(1L, result
);
213 * Run the boolean hasValidRank() method test.
216 public void testHasValidRank() {
217 boolean result
= fixture
.hasValidRank();
222 * Run the int hashCode() method test.
225 public void testHashCode() {
226 int result
= fixture
.hashCode();
227 int result2
= fixture
.hashCode();
228 assertEquals(result
, result2
);
232 * Run the void increaseRank() method test.
235 public void testIncreaseRank() {
236 fixture
.increaseRank();
240 * Run the boolean seek(long) method test.
243 public void testSeek() {
245 boolean result
= fixture
.seek(timestamp
);
250 * Run the void setLocation(ITmfLocation<?>) method test.
253 public void testSetLocation() {
254 CtfLocation location
= new CtfLocation(new CtfLocationInfo(1, 0));
255 fixture
.setLocation(location
);
This page took 0.091748 seconds and 6 git commands to generate.