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
.CtfTmfEvent
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
26 import org
.junit
.After
;
27 import org
.junit
.Before
;
28 import org
.junit
.Test
;
31 * The class <code>CtfIteratorTest</code> contains tests for the class
32 * <code>{@link CtfIterator}</code>.
37 public class CtfIteratorTest
{
39 private CtfIterator fixture
;
45 * the command line arguments
47 public static void main(String
[] args
) {
48 new org
.junit
.runner
.JUnitCore().run(CtfIteratorTest
.class);
52 * Perform pre-test initialization.
54 * @throws TmfTraceException
55 * If the test trace is not found
58 public void setUp() throws TmfTraceException
{
59 fixture
= new CtfIterator(createTrace());
60 CtfLocation ctfLocation
= new CtfLocation(Long
.valueOf(1));
61 ctfLocation
.setLocation(Long
.valueOf(1));
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
, timestampValue
, 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(Long
.valueOf(1));
168 ctfLocation1
.setLocation(Long
.valueOf(1));
169 obj
.setLocation(ctfLocation1
);
172 boolean result
= fixture
.equals(obj
);
177 * Run the boolean equals(Object) method test. Compare with an empty object.
180 public void testEquals_empty() {
181 Object obj
= new Object();
182 boolean result
= fixture
.equals(obj
);
188 * Run the CtfTmfTrace getCtfTmfTrace() method test.
191 public void testGetCtfTmfTrace() {
192 CtfTmfTrace result
= fixture
.getCtfTmfTrace();
193 assertNotNull(result
);
197 * Run the CtfTmfEvent getCurrentEvent() method test.
200 public void testGetCurrentEvent() {
201 CtfTmfEvent result
= fixture
.getCurrentEvent();
202 assertNotNull(result
);
206 * Run the CtfLocation getLocation() method test.
209 public void testGetLocation() {
210 CtfLocation result
= fixture
.getLocation();
211 assertNotNull(result
);
215 * Run the long getRank() method test.
218 public void testGetRank() {
219 long result
= fixture
.getRank();
220 assertEquals(1L, result
);
224 * Run the boolean hasValidRank() method test.
227 public void testHasValidRank() {
228 boolean result
= fixture
.hasValidRank();
233 * Run the int hashCode() method test.
236 public void testHashCode() {
237 int result
= fixture
.hashCode();
238 int result2
= fixture
.hashCode();
239 assertEquals(result
, result2
);
243 * Run the void increaseRank() method test.
246 public void testIncreaseRank() {
247 fixture
.increaseRank();
251 * Run the boolean seek(long) method test.
254 public void testSeek() {
256 boolean result
= fixture
.seek(timestamp
);
261 * Run the void setLocation(ITmfLocation<?>) method test.
264 public void testSetLocation() {
265 CtfLocation location
= new CtfLocation(Long
.valueOf(1));
266 location
.setLocation(Long
.valueOf(1));
267 fixture
.setLocation(location
);
This page took 0.045089 seconds and 5 git commands to generate.