lttng: Disable NLS warnings in tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfTmfTraceTest.java
CommitLineData
95bf10e7 1/*******************************************************************************
61759503 2 * Copyright (c) 2012, 2013 Ericsson
95bf10e7
AM
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.assertNotNull;
18import static org.junit.Assert.assertNull;
19import static org.junit.Assert.assertTrue;
5dd1fa65 20import static org.junit.Assume.assumeTrue;
81c8e6f7
MK
21
22import org.eclipse.core.resources.IProject;
23import org.eclipse.core.resources.IResource;
24import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
f5df94f8 25import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
81c8e6f7
MK
26import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
27import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
28import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
6256d8ad 29import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
81c8e6f7 30import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
81c8e6f7
MK
31import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
32import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
5dd1fa65 33import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
3bd46eef
AM
34import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
35import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
36import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
81c8e6f7 37import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
81c8e6f7
MK
38import org.junit.After;
39import org.junit.Before;
40import org.junit.Test;
41
42/**
95bf10e7
AM
43 * The class <code>CtfTmfTraceTest</code> contains tests for the class
44 * <code>{@link CtfTmfTrace}</code>.
81c8e6f7 45 *
81c8e6f7 46 * @author ematkho
95bf10e7 47 * @version 1.0
81c8e6f7
MK
48 */
49public class CtfTmfTraceTest {
95bf10e7 50
5dd1fa65
AM
51 private static final int TRACE_INDEX = 0;
52 private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX);
81c8e6f7 53
95bf10e7
AM
54 private CtfTmfTrace fixture;
55
95bf10e7
AM
56 /**
57 * Perform pre-test initialization.
81c8e6f7 58 *
95bf10e7
AM
59 * @throws TmfTraceException
60 * If the test trace is not found
81c8e6f7 61 */
95bf10e7
AM
62 @Before
63 public void setUp() throws TmfTraceException {
5dd1fa65 64 assumeTrue(CtfTmfTestTraces.tracesExist());
95bf10e7
AM
65 fixture = new CtfTmfTrace();
66 fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class);
67 }
81c8e6f7 68
95bf10e7
AM
69 /**
70 * Perform post-test clean-up.
71 */
72 @After
73 public void tearDown() {
5dd1fa65
AM
74 if (fixture != null) {
75 fixture.dispose();
76 }
95bf10e7
AM
77 }
78
79 /**
80 * Run the CtfTmfTrace() constructor test.
81 */
82 @Test
83 public void testCtfTmfTrace() {
81c8e6f7
MK
84 CtfTmfTrace result = new CtfTmfTrace();
85
81c8e6f7 86 assertNotNull(result);
95bf10e7 87 assertNull(result.getEventType());
bfe038ff 88 assertEquals(1000, result.getCacheSize());
81c8e6f7
MK
89 assertEquals(0L, result.getNbEvents());
90 assertEquals(0L, result.getStreamingInterval());
95bf10e7 91 assertNull(result.getResource());
81c8e6f7 92 assertEquals(1000, result.getQueueSize());
95bf10e7 93 assertNull(result.getType());
81c8e6f7
MK
94 }
95
95bf10e7
AM
96 /**
97 * Test the parseEvent() method
98 */
788ddcbc 99 @Test
95bf10e7 100 public void testParseEvent() {
788ddcbc
MK
101 ITmfContext ctx = fixture.seekEvent(0);
102 fixture.getNext(ctx);
103 CtfTmfEvent event = fixture.parseEvent(ctx);
104 assertNotNull(event);
105 }
106
81c8e6f7
MK
107 /**
108 * Run the void broadcast(TmfSignal) method test.
81c8e6f7
MK
109 */
110 @Test
95bf10e7 111 public void testBroadcast() {
81c8e6f7 112 TmfSignal signal = new TmfEndSynchSignal(1);
81c8e6f7 113 fixture.broadcast(signal);
81c8e6f7
MK
114 }
115
116
117 /**
118 * Run the void dispose() method test.
81c8e6f7
MK
119 */
120 @Test
95bf10e7
AM
121 public void testDispose() {
122 CtfTmfTrace emptyFixture = new CtfTmfTrace();
123 emptyFixture.dispose();
81c8e6f7
MK
124
125 }
126
127 /**
128 * Run the int getCacheSize() method test.
81c8e6f7
MK
129 */
130 @Test
95bf10e7
AM
131 public void testGetCacheSize() {
132 CtfTmfTrace emptyFixture = new CtfTmfTrace();
133 int result = emptyFixture.getCacheSize();
bfe038ff 134 assertEquals(1000, result);
81c8e6f7
MK
135 }
136
137 /**
138 * Run the ITmfLocation<Comparable> getCurrentLocation() method test.
81c8e6f7
MK
139 */
140 @Test
95bf10e7 141 public void testGetCurrentLocation() {
81c8e6f7 142 CtfLocation result = (CtfLocation) fixture.getCurrentLocation();
f474d36b 143 assertNull(result);
81c8e6f7
MK
144 }
145
95bf10e7
AM
146 /**
147 * Test the seekEvent() method with a null location.
148 */
81c8e6f7 149 @Test
95bf10e7 150 public void testSeekEventLoc_null() {
81c8e6f7
MK
151 CtfLocation loc = null;
152 fixture.seekEvent(loc);
153 assertNotNull(fixture);
154 }
155
95bf10e7
AM
156 /**
157 * Test the seekEvent() method with a location from a timestamp.
158 */
81c8e6f7 159 @Test
95bf10e7 160 public void testSeekEventLoc_timetamp(){
81c8e6f7
MK
161 CtfLocation loc = new CtfLocation(new CtfTmfTimestamp(0L));
162 fixture.seekEvent(loc);
163 assertNotNull(fixture);
164 }
165
166
167 /**
168 * Run the ITmfTimestamp getEndTime() method test.
81c8e6f7
MK
169 */
170 @Test
95bf10e7 171 public void testGetEndTime() {
81c8e6f7
MK
172 ITmfTimestamp result = fixture.getEndTime();
173 assertNotNull(result);
174 }
175
176 /**
177 * Run the String[] getEnvNames() method test.
81c8e6f7
MK
178 */
179 @Test
95bf10e7 180 public void testGetEnvNames() {
81c8e6f7 181 String[] result = fixture.getEnvNames();
81c8e6f7
MK
182 assertNotNull(result);
183 }
184
185 /**
186 * Run the String getEnvValue(String) method test.
81c8e6f7
MK
187 */
188 @Test
95bf10e7 189 public void testGetEnvValue() {
81c8e6f7 190 String key = "tracer_name"; //$NON-NLS-1$
81c8e6f7 191 String result = fixture.getEnvValue(key);
81c8e6f7
MK
192 assertEquals("\"lttng-modules\"",result); //$NON-NLS-1$
193 }
194
195 /**
196 * Run the Class<CtfTmfEvent> getEventType() method test.
81c8e6f7
MK
197 */
198 @Test
95bf10e7 199 public void testGetEventType() {
6256d8ad 200 Class<ITmfEvent> result = fixture.getEventType();
bfe038ff 201 assertNotNull(result);
81c8e6f7
MK
202 }
203
204 /**
205 * Run the double getLocationRatio(ITmfLocation<?>) method test.
81c8e6f7
MK
206 */
207 @Test
95bf10e7 208 public void testGetLocationRatio() {
f5df94f8 209 final CtfLocationInfo location2 = new CtfLocationInfo(1, 0);
132a02b0 210 CtfLocation location = new CtfLocation(location2);
81c8e6f7
MK
211 double result = fixture.getLocationRatio(location);
212
788ddcbc 213 assertEquals(Double.NEGATIVE_INFINITY, result, 0.1);
81c8e6f7
MK
214 }
215
216 /**
217 * Run the String getName() method test.
81c8e6f7
MK
218 */
219 @Test
95bf10e7 220 public void testGetName() {
81c8e6f7 221 String result = fixture.getName();
81c8e6f7
MK
222 assertNotNull(result);
223 }
224
225 /**
226 * Run the int getNbEnvVars() method test.
81c8e6f7
MK
227 */
228 @Test
95bf10e7 229 public void testGetNbEnvVars() {
81c8e6f7 230 int result = fixture.getNbEnvVars();
81c8e6f7
MK
231 assertEquals(8, result);
232 }
233
234 /**
235 * Run the long getNbEvents() method test.
81c8e6f7
MK
236 */
237 @Test
95bf10e7 238 public void testGetNbEvents() {
81c8e6f7 239 long result = fixture.getNbEvents();
132a02b0 240 assertEquals(1L, result);
81c8e6f7
MK
241 }
242
243 /**
244 * Run the CtfTmfEvent getNext(ITmfContext) method test.
81c8e6f7
MK
245 */
246 @Test
95bf10e7 247 public void testGetNext() {
f474d36b 248 ITmfContext context = fixture.seekEvent(0);
81c8e6f7 249 CtfTmfEvent result = fixture.getNext(context);
81c8e6f7
MK
250 assertNotNull(result);
251 }
252
253 /**
254 * Run the String getPath() method test.
81c8e6f7
MK
255 */
256 @Test
95bf10e7 257 public void testGetPath() {
81c8e6f7 258 String result = fixture.getPath();
81c8e6f7
MK
259 assertNotNull(result);
260 }
261
262 /**
263 * Run the IResource getResource() method test.
81c8e6f7
MK
264 */
265 @Test
95bf10e7 266 public void testGetResource() {
81c8e6f7 267 IResource result = fixture.getResource();
81c8e6f7
MK
268 assertNull(result);
269 }
270
271 /**
272 * Run the ITmfTimestamp getStartTime() method test.
81c8e6f7
MK
273 */
274 @Test
95bf10e7 275 public void testGetStartTime() {
81c8e6f7 276 ITmfTimestamp result = fixture.getStartTime();
81c8e6f7
MK
277 assertNotNull(result);
278 }
279
81c8e6f7
MK
280 /**
281 * Run the long getStreamingInterval() method test.
81c8e6f7
MK
282 */
283 @Test
95bf10e7 284 public void testGetStreamingInterval() {
81c8e6f7 285 long result = fixture.getStreamingInterval();
81c8e6f7
MK
286 assertEquals(0L, result);
287 }
288
289 /**
290 * Run the TmfTimeRange getTimeRange() method test.
81c8e6f7
MK
291 */
292 @Test
95bf10e7 293 public void testGetTimeRange() {
81c8e6f7 294 TmfTimeRange result = fixture.getTimeRange();
81c8e6f7
MK
295 assertNotNull(result);
296 }
297
81c8e6f7
MK
298 /**
299 * Run the CtfTmfEvent readNextEvent(ITmfContext) method test.
81c8e6f7
MK
300 */
301 @Test
95bf10e7 302 public void testReadNextEvent() {
f474d36b 303 ITmfContext context = fixture.seekEvent(0);
c32744d6 304 CtfTmfEvent result = fixture.getNext(context);
81c8e6f7
MK
305 assertNotNull(result);
306 }
307
308 /**
309 * Run the ITmfContext seekEvent(double) method test.
81c8e6f7
MK
310 */
311 @Test
95bf10e7 312 public void testSeekEvent_ratio() {
788ddcbc 313 double ratio = 0.99;
81c8e6f7 314 ITmfContext result = fixture.seekEvent(ratio);
81c8e6f7
MK
315 assertNotNull(result);
316 }
317
318 /**
319 * Run the ITmfContext seekEvent(long) method test.
81c8e6f7
MK
320 */
321 @Test
95bf10e7 322 public void testSeekEvent_rank() {
81c8e6f7 323 long rank = 1L;
81c8e6f7 324 ITmfContext result = fixture.seekEvent(rank);
81c8e6f7
MK
325 assertNotNull(result);
326 }
327
328 /**
329 * Run the ITmfContext seekEvent(ITmfTimestamp) method test.
81c8e6f7
MK
330 */
331 @Test
95bf10e7 332 public void testSeekEvent_timestamp() {
81c8e6f7 333 ITmfTimestamp timestamp = new TmfTimestamp();
81c8e6f7 334 ITmfContext result = fixture.seekEvent(timestamp);
81c8e6f7
MK
335 assertNotNull(result);
336 }
337
81c8e6f7 338 /**
95bf10e7 339 * Run the ITmfContext seekEvent(ITmfLocation<?>) method test.
81c8e6f7
MK
340 */
341 @Test
95bf10e7 342 public void testSeekEvent_location() {
f5df94f8 343 final CtfLocationInfo location2 = new CtfLocationInfo(1L, 0L);
132a02b0 344 CtfLocation ctfLocation = new CtfLocation(location2);
95bf10e7
AM
345 ITmfContext result = fixture.seekEvent(ctfLocation);
346 assertNotNull(result);
81c8e6f7
MK
347 }
348
349 /**
350 * Run the boolean validate(IProject,String) method test.
81c8e6f7
MK
351 */
352 @Test
95bf10e7 353 public void testValidate() {
81c8e6f7
MK
354 IProject project = null;
355 String path = PATH;
81c8e6f7 356 boolean result = fixture.validate(project, path);
81c8e6f7
MK
357 assertTrue(result);
358 }
2d223a34 359}
This page took 0.048681 seconds and 5 git commands to generate.