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
.CtfLocationData
;
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
;
46 * the command line arguments
48 public static void main(String
[] args
) {
49 new org
.junit
.runner
.JUnitCore().run(CtfIteratorTest
.class);
53 * Perform pre-test initialization.
55 * @throws TmfTraceException
56 * If the test trace is not found
59 public void setUp() throws TmfTraceException
{
60 fixture
= new CtfIterator(createTrace());
61 CtfLocation ctfLocation
= new CtfLocation(new CtfLocationData(1, 0));
62 fixture
.setLocation(ctfLocation
);
63 fixture
.increaseRank();
67 * Perform post-test clean-up.
70 public void tearDown() {
75 private static CtfTmfTrace
createTrace() throws TmfTraceException
{
76 return TestParams
.createTrace();
80 * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
82 * @throws TmfTraceException
83 * If the test trace is not found
86 public void testCtfIterator_noinit() throws TmfTraceException
{
87 CtfTmfTrace trace
= createTrace();
88 CtfIterator result
= new CtfIterator(trace
);
89 assertNotNull(result
);
93 * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
95 * @throws TmfTraceException
96 * If the test trace is not found
99 public void testCtfIterator_init() throws TmfTraceException
{
100 CtfTmfTrace trace
= createTrace();
101 trace
.init("test"); //$NON-NLS-1$
102 CtfIterator result
= new CtfIterator(trace
);
104 assertNotNull(result
);
108 * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
109 * specifies an initial position for the iterator.
111 * @throws TmfTraceException
112 * If the test trace is not found
115 public void testCtfIterator_position() throws TmfTraceException
{
116 CtfTmfTrace trace
= createTrace();
117 long timestampValue
= 1L;
119 CtfIterator result
= new CtfIterator(trace
, new CtfLocationData(timestampValue
, 0), rank
);
121 assertNotNull(result
);
126 * Run the boolean advance() method test.
129 public void testAdvance() {
130 boolean result
= fixture
.advance();
135 * Run the CtfIterator clone() method test.
138 public void testClone() {
139 CtfIterator result
= fixture
.clone();
140 assertNotNull(result
);
144 * Run the int compareTo(CtfIterator) method test.
146 * @throws TmfTraceException
147 * If the test trace is not found
150 public void testCompareTo() throws TmfTraceException
{
151 CtfIterator o
= new CtfIterator(createTrace());
152 int result
= fixture
.compareTo(o
);
154 assertEquals(1L, result
);
158 * Run the boolean equals(Object) method test. Compare with another iterator
161 * @throws TmfTraceException
162 * If the test trace is not found
165 public void testEquals_other() throws TmfTraceException
{
166 CtfIterator obj
= new CtfIterator(createTrace());
167 CtfLocation ctfLocation1
= new CtfLocation(new CtfLocationData(1, 0));
168 obj
.setLocation(ctfLocation1
);
171 boolean result
= fixture
.equals(obj
);
176 * Run the boolean equals(Object) method test. Compare with an empty object.
179 public void testEquals_empty() {
180 Object obj
= new Object();
181 boolean result
= fixture
.equals(obj
);
187 * Run the CtfTmfTrace getCtfTmfTrace() method test.
190 public void testGetCtfTmfTrace() {
191 CtfTmfTrace result
= fixture
.getCtfTmfTrace();
192 assertNotNull(result
);
196 * Run the CtfTmfEvent getCurrentEvent() method test.
199 public void testGetCurrentEvent() {
200 CtfTmfEvent result
= fixture
.getCurrentEvent();
201 assertNotNull(result
);
205 * Run the CtfLocation getLocation() method test.
208 public void testGetLocation() {
209 CtfLocation result
= fixture
.getLocation();
210 assertNotNull(result
);
214 * Run the long getRank() method test.
217 public void testGetRank() {
218 long result
= fixture
.getRank();
219 assertEquals(1L, result
);
223 * Run the boolean hasValidRank() method test.
226 public void testHasValidRank() {
227 boolean result
= fixture
.hasValidRank();
232 * Run the int hashCode() method test.
235 public void testHashCode() {
236 int result
= fixture
.hashCode();
237 int result2
= fixture
.hashCode();
238 assertEquals(result
, result2
);
242 * Run the void increaseRank() method test.
245 public void testIncreaseRank() {
246 fixture
.increaseRank();
250 * Run the boolean seek(long) method test.
253 public void testSeek() {
255 boolean result
= fixture
.seek(timestamp
);
260 * Run the void setLocation(ITmfLocation<?>) method test.
263 public void testSetLocation() {
264 CtfLocation location
= new CtfLocation(new CtfLocationData(1, 0));
265 fixture
.setLocation(location
);
This page took 0.036045 seconds and 5 git commands to generate.