0c621c7248861182b720ca2cbdbcae047763b3a3
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
;
20 import static org
.junit
.Assume
.assumeTrue
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfIterator
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfLocation
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfLocationInfo
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTraces
;
28 import org
.junit
.After
;
29 import org
.junit
.Before
;
30 import org
.junit
.Test
;
33 * The class <code>CtfIteratorTest</code> contains tests for the class
34 * <code>{@link CtfIterator}</code>.
39 public class CtfIteratorTest
{
41 private static final int TRACE_INDEX
= 0;
43 private CtfIterator fixture
;
46 * Perform pre-test initialization.
50 assumeTrue(CtfTmfTestTraces
.tracesExist());
51 fixture
= new CtfIterator(getTrace());
52 CtfLocation ctfLocation
= new CtfLocation(new CtfLocationInfo(1, 0));
53 fixture
.setLocation(ctfLocation
);
54 fixture
.increaseRank();
58 * Perform post-test clean-up.
61 public void tearDown() {
62 if (fixture
!= null) {
67 private static CtfTmfTrace
getTrace() {
68 return CtfTmfTestTraces
.getTestTrace(TRACE_INDEX
);
72 * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
75 public void testCtfIterator_noinit() {
76 CtfTmfTrace trace
= getTrace();
77 CtfIterator result
= new CtfIterator(trace
);
78 assertNotNull(result
);
82 * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
85 public void testCtfIterator_init() {
86 CtfTmfTrace trace
= getTrace();
87 trace
.init("test"); //$NON-NLS-1$
88 CtfIterator result
= new CtfIterator(trace
);
90 assertNotNull(result
);
94 * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
95 * specifies an initial position for the iterator.
98 public void testCtfIterator_position() {
99 CtfTmfTrace trace
= getTrace();
100 long timestampValue
= 1L;
102 CtfIterator result
= new CtfIterator(trace
, new CtfLocationInfo(timestampValue
, 0), rank
);
104 assertNotNull(result
);
109 * Run the boolean advance() method test.
112 public void testAdvance() {
113 boolean result
= fixture
.advance();
118 * Run the CtfIterator clone() method test.
121 public void testClone() {
122 CtfIterator result
= fixture
.clone();
123 assertNotNull(result
);
127 * Run the int compareTo(CtfIterator) method test.
130 public void testCompareTo() {
131 CtfIterator o
= new CtfIterator(getTrace());
132 int result
= fixture
.compareTo(o
);
134 assertEquals(1L, result
);
138 * Run the boolean equals(Object) method test. Compare with another iterator
142 public void testEquals_other() {
143 CtfIterator obj
= new CtfIterator(getTrace());
144 CtfLocation ctfLocation1
= new CtfLocation(new CtfLocationInfo(1, 0));
145 obj
.setLocation(ctfLocation1
);
148 boolean result
= fixture
.equals(obj
);
153 * Run the boolean equals(Object) method test. Compare with an empty object.
156 public void testEquals_empty() {
157 Object obj
= new Object();
158 boolean result
= fixture
.equals(obj
);
164 * Run the CtfTmfTrace getCtfTmfTrace() method test.
167 public void testGetCtfTmfTrace() {
168 CtfTmfTrace result
= fixture
.getCtfTmfTrace();
169 assertNotNull(result
);
173 * Run the CtfTmfEvent getCurrentEvent() method test.
176 public void testGetCurrentEvent() {
177 CtfTmfEvent result
= fixture
.getCurrentEvent();
178 assertNotNull(result
);
182 * Run the CtfLocation getLocation() method test.
185 public void testGetLocation() {
186 CtfLocation result
= fixture
.getLocation();
187 assertNotNull(result
);
191 * Run the long getRank() method test.
194 public void testGetRank() {
195 long result
= fixture
.getRank();
196 assertEquals(1L, result
);
200 * Run the boolean hasValidRank() method test.
203 public void testHasValidRank() {
204 boolean result
= fixture
.hasValidRank();
209 * Run the int hashCode() method test.
212 public void testHashCode() {
213 int result
= fixture
.hashCode();
214 int result2
= fixture
.hashCode();
215 assertEquals(result
, result2
);
219 * Run the void increaseRank() method test.
222 public void testIncreaseRank() {
223 fixture
.increaseRank();
227 * Run the boolean seek(long) method test.
230 public void testSeek() {
232 boolean result
= fixture
.seek(timestamp
);
237 * Run the void setLocation(ITmfLocation<?>) method test.
240 public void testSetLocation() {
241 CtfLocation location
= new CtfLocation(new CtfLocationInfo(1, 0));
242 fixture
.setLocation(location
);
This page took 0.036864 seconds and 5 git commands to generate.