tmf: Rename CtfLocationData to CtfLocationInfo
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfIteratorTest.java
CommitLineData
95bf10e7
AM
1/*******************************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial generation with CodePro tools
11 * Alexandre Montplaisir - Clean up, consolidate redundant tests
12 *******************************************************************************/
13
81c8e6f7
MK
14package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
15
16import static org.junit.Assert.assertEquals;
17import static org.junit.Assert.assertFalse;
18import static org.junit.Assert.assertNotNull;
19import static org.junit.Assert.assertTrue;
20
21import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator;
22import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
f5df94f8 23import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
81c8e6f7
MK
24import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
25import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
26import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
27import org.junit.After;
28import org.junit.Before;
29import org.junit.Test;
30
31/**
95bf10e7
AM
32 * The class <code>CtfIteratorTest</code> contains tests for the class
33 * <code>{@link CtfIterator}</code>.
81c8e6f7 34 *
81c8e6f7 35 * @author ematkho
95bf10e7 36 * @version 1.0
81c8e6f7 37 */
81c8e6f7 38public class CtfIteratorTest {
95bf10e7
AM
39
40 private CtfIterator fixture;
41
95bf10e7
AM
42 /**
43 * Perform pre-test initialization.
81c8e6f7 44 *
95bf10e7
AM
45 * @throws TmfTraceException
46 * If the test trace is not found
47 */
48 @Before
49 public void setUp() throws TmfTraceException {
50 fixture = new CtfIterator(createTrace());
f5df94f8 51 CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0));
95bf10e7
AM
52 fixture.setLocation(ctfLocation);
53 fixture.increaseRank();
54 }
55
56 /**
57 * Perform post-test clean-up.
58 */
59 @After
60 public void tearDown() {
61 fixture.dispose();
62 }
63
64
65 private static CtfTmfTrace createTrace() throws TmfTraceException {
66 return TestParams.createTrace();
67 }
68
69 /**
70 * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace.
71 *
72 * @throws TmfTraceException
73 * If the test trace is not found
81c8e6f7
MK
74 */
75 @Test
95bf10e7 76 public void testCtfIterator_noinit() throws TmfTraceException {
81c8e6f7
MK
77 CtfTmfTrace trace = createTrace();
78 CtfIterator result = new CtfIterator(trace);
79 assertNotNull(result);
80 }
81
82 /**
95bf10e7 83 * Run the CtfIterator(CtfTmfTrace) constructor on an init'ed trace.
81c8e6f7 84 *
95bf10e7
AM
85 * @throws TmfTraceException
86 * If the test trace is not found
81c8e6f7
MK
87 */
88 @Test
95bf10e7 89 public void testCtfIterator_init() throws TmfTraceException {
81c8e6f7 90 CtfTmfTrace trace = createTrace();
0879b6b9 91 trace.init("test"); //$NON-NLS-1$
81c8e6f7
MK
92 CtfIterator result = new CtfIterator(trace);
93
94 assertNotNull(result);
95 }
96
97 /**
95bf10e7
AM
98 * Run the CtfIterator(CtfTmfTrace,long,long) constructor test, which
99 * specifies an initial position for the iterator.
81c8e6f7 100 *
95bf10e7
AM
101 * @throws TmfTraceException
102 * If the test trace is not found
81c8e6f7
MK
103 */
104 @Test
95bf10e7 105 public void testCtfIterator_position() throws TmfTraceException {
81c8e6f7
MK
106 CtfTmfTrace trace = createTrace();
107 long timestampValue = 1L;
108 long rank = 1L;
f5df94f8 109 CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank);
81c8e6f7
MK
110
111 assertNotNull(result);
112 }
113
114
115 /**
116 * Run the boolean advance() method test.
81c8e6f7
MK
117 */
118 @Test
95bf10e7 119 public void testAdvance() {
81c8e6f7 120 boolean result = fixture.advance();
81c8e6f7
MK
121 assertTrue(result);
122 }
123
124 /**
125 * Run the CtfIterator clone() method test.
81c8e6f7
MK
126 */
127 @Test
95bf10e7 128 public void testClone() {
81c8e6f7
MK
129 CtfIterator result = fixture.clone();
130 assertNotNull(result);
131 }
132
133 /**
134 * Run the int compareTo(CtfIterator) method test.
135 *
81c8e6f7 136 * @throws TmfTraceException
95bf10e7 137 * If the test trace is not found
81c8e6f7
MK
138 */
139 @Test
95bf10e7 140 public void testCompareTo() throws TmfTraceException {
81c8e6f7 141 CtfIterator o = new CtfIterator(createTrace());
81c8e6f7
MK
142 int result = fixture.compareTo(o);
143
95bf10e7 144 assertEquals(1L, result);
81c8e6f7
MK
145 }
146
147 /**
95bf10e7
AM
148 * Run the boolean equals(Object) method test. Compare with another iterator
149 * on the same trace.
81c8e6f7 150 *
95bf10e7
AM
151 * @throws TmfTraceException
152 * If the test trace is not found
81c8e6f7
MK
153 */
154 @Test
95bf10e7 155 public void testEquals_other() throws TmfTraceException {
81c8e6f7 156 CtfIterator obj = new CtfIterator(createTrace());
f5df94f8 157 CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0));
81c8e6f7
MK
158 obj.setLocation(ctfLocation1);
159 obj.increaseRank();
160
161 boolean result = fixture.equals(obj);
81c8e6f7
MK
162 assertTrue(result);
163 }
164
165 /**
95bf10e7 166 * Run the boolean equals(Object) method test. Compare with an empty object.
81c8e6f7
MK
167 */
168 @Test
95bf10e7 169 public void testEquals_empty() {
81c8e6f7 170 Object obj = new Object();
81c8e6f7
MK
171 boolean result = fixture.equals(obj);
172
173 assertFalse(result);
174 }
175
176 /**
177 * Run the CtfTmfTrace getCtfTmfTrace() method test.
81c8e6f7
MK
178 */
179 @Test
95bf10e7 180 public void testGetCtfTmfTrace() {
81c8e6f7 181 CtfTmfTrace result = fixture.getCtfTmfTrace();
81c8e6f7
MK
182 assertNotNull(result);
183 }
184
185 /**
186 * Run the CtfTmfEvent getCurrentEvent() method test.
81c8e6f7
MK
187 */
188 @Test
95bf10e7 189 public void testGetCurrentEvent() {
81c8e6f7 190 CtfTmfEvent result = fixture.getCurrentEvent();
81c8e6f7
MK
191 assertNotNull(result);
192 }
193
194 /**
195 * Run the CtfLocation getLocation() method test.
81c8e6f7
MK
196 */
197 @Test
95bf10e7 198 public void testGetLocation() {
81c8e6f7 199 CtfLocation result = fixture.getLocation();
81c8e6f7
MK
200 assertNotNull(result);
201 }
202
203 /**
204 * Run the long getRank() method test.
81c8e6f7
MK
205 */
206 @Test
95bf10e7 207 public void testGetRank() {
81c8e6f7 208 long result = fixture.getRank();
f474d36b 209 assertEquals(1L, result);
81c8e6f7
MK
210 }
211
212 /**
213 * Run the boolean hasValidRank() method test.
81c8e6f7
MK
214 */
215 @Test
95bf10e7 216 public void testHasValidRank() {
81c8e6f7 217 boolean result = fixture.hasValidRank();
81c8e6f7
MK
218 assertTrue(result);
219 }
220
221 /**
222 * Run the int hashCode() method test.
81c8e6f7
MK
223 */
224 @Test
95bf10e7 225 public void testHashCode() {
81c8e6f7
MK
226 int result = fixture.hashCode();
227 int result2 = fixture.hashCode();
228 assertEquals(result, result2);
229 }
230
231 /**
232 * Run the void increaseRank() method test.
81c8e6f7
MK
233 */
234 @Test
95bf10e7 235 public void testIncreaseRank() {
81c8e6f7 236 fixture.increaseRank();
81c8e6f7
MK
237 }
238
239 /**
240 * Run the boolean seek(long) method test.
81c8e6f7
MK
241 */
242 @Test
95bf10e7 243 public void testSeek() {
81c8e6f7 244 long timestamp = 1L;
81c8e6f7 245 boolean result = fixture.seek(timestamp);
81c8e6f7
MK
246 assertTrue(result);
247 }
248
81c8e6f7
MK
249 /**
250 * Run the void setLocation(ITmfLocation<?>) method test.
81c8e6f7
MK
251 */
252 @Test
95bf10e7 253 public void testSetLocation() {
f5df94f8 254 CtfLocation location = new CtfLocation(new CtfLocationInfo(1, 0));
81c8e6f7 255 fixture.setLocation(location);
81c8e6f7 256 }
95bf10e7 257}
This page took 0.042628 seconds and 5 git commands to generate.