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 ctfLocation
.setLocation(new CtfLocationData(1, 0));
63 fixture
.setLocation(ctfLocation
);
64 fixture
.increaseRank();
68 * Perform post-test clean-up.
71 public void tearDown() {
76 private static CtfTmfTrace
createTrace() throws TmfTraceException
{
77 return TestParams
.createTrace();
81 * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
83 * @throws TmfTraceException
84 * If the test trace is not found
87 public void testCtfIterator_noinit() throws TmfTraceException
{
88 CtfTmfTrace trace
= createTrace();
89 CtfIterator result
= new CtfIterator(trace
);
90 assertNotNull(result
);
94 * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
96 * @throws TmfTraceException
97 * If the test trace is not found
100 public void testCtfIterator_init() throws TmfTraceException
{
101 CtfTmfTrace trace
= createTrace();
102 trace
.init("test"); //$NON-NLS-1$
103 CtfIterator result
= new CtfIterator(trace
);
105 assertNotNull(result
);
109 * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
110 * specifies an initial position for the iterator.
112 * @throws TmfTraceException
113 * If the test trace is not found
116 public void testCtfIterator_position() throws TmfTraceException
{
117 CtfTmfTrace trace
= createTrace();
118 long timestampValue
= 1L;
120 CtfIterator result
= new CtfIterator(trace
, new CtfLocationData(timestampValue
, 0), rank
);
122 assertNotNull(result
);
127 * Run the boolean advance() method test.
130 public void testAdvance() {
131 boolean result
= fixture
.advance();
136 * Run the CtfIterator clone() method test.
139 public void testClone() {
140 CtfIterator result
= fixture
.clone();
141 assertNotNull(result
);
145 * Run the int compareTo(CtfIterator) method test.
147 * @throws TmfTraceException
148 * If the test trace is not found
151 public void testCompareTo() throws TmfTraceException
{
152 CtfIterator o
= new CtfIterator(createTrace());
153 int result
= fixture
.compareTo(o
);
155 assertEquals(1L, result
);
159 * Run the boolean equals(Object) method test. Compare with another iterator
162 * @throws TmfTraceException
163 * If the test trace is not found
166 public void testEquals_other() throws TmfTraceException
{
167 CtfIterator obj
= new CtfIterator(createTrace());
168 CtfLocation ctfLocation1
= new CtfLocation(new CtfLocationData(1, 0));
169 ctfLocation1
.setLocation(new CtfLocationData(1, 0));
170 obj
.setLocation(ctfLocation1
);
173 boolean result
= fixture
.equals(obj
);
178 * Run the boolean equals(Object) method test. Compare with an empty object.
181 public void testEquals_empty() {
182 Object obj
= new Object();
183 boolean result
= fixture
.equals(obj
);
189 * Run the CtfTmfTrace getCtfTmfTrace() method test.
192 public void testGetCtfTmfTrace() {
193 CtfTmfTrace result
= fixture
.getCtfTmfTrace();
194 assertNotNull(result
);
198 * Run the CtfTmfEvent getCurrentEvent() method test.
201 public void testGetCurrentEvent() {
202 CtfTmfEvent result
= fixture
.getCurrentEvent();
203 assertNotNull(result
);
207 * Run the CtfLocation getLocation() method test.
210 public void testGetLocation() {
211 CtfLocation result
= fixture
.getLocation();
212 assertNotNull(result
);
216 * Run the long getRank() method test.
219 public void testGetRank() {
220 long result
= fixture
.getRank();
221 assertEquals(1L, result
);
225 * Run the boolean hasValidRank() method test.
228 public void testHasValidRank() {
229 boolean result
= fixture
.hasValidRank();
234 * Run the int hashCode() method test.
237 public void testHashCode() {
238 int result
= fixture
.hashCode();
239 int result2
= fixture
.hashCode();
240 assertEquals(result
, result2
);
244 * Run the void increaseRank() method test.
247 public void testIncreaseRank() {
248 fixture
.increaseRank();
252 * Run the boolean seek(long) method test.
255 public void testSeek() {
257 boolean result
= fixture
.seek(timestamp
);
262 * Run the void setLocation(ITmfLocation<?>) method test.
265 public void testSetLocation() {
266 CtfLocation location
= new CtfLocation(new CtfLocationData(1, 0));
267 location
.setLocation(new CtfLocationData(1, 0));
268 fixture
.setLocation(location
);
This page took 0.037412 seconds and 5 git commands to generate.