1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.tests
.trace
;
16 import java
.io
.IOException
;
17 import java
.net
.URISyntaxException
;
20 import junit
.framework
.TestCase
;
22 import org
.eclipse
.core
.runtime
.FileLocator
;
23 import org
.eclipse
.core
.runtime
.Path
;
24 import org
.eclipse
.linuxtools
.lttng
.tests
.LTTngCoreTestPlugin
;
25 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngExperiment
;
26 import org
.eclipse
.linuxtools
.lttng
.trace
.LTTngTrace
;
27 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
28 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
29 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
30 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfTrace
;
33 * <b><u>TmfExperimentTest</u></b>
35 * TODO: Implement me. Please.
37 public class LTTngExperimentTest
extends TestCase
{
39 private static final String DIRECTORY
= "traceset";
40 private static final String TEST_STREAM
= "trace-15316events_nolost_newformat";
41 private static final String EXPERIMENT
= "MyExperiment";
42 private static int NB_EVENTS
= 15316;
44 // Note: Start/end times are for the LTTng *trace*, not the actual events
45 private static final TmfTimestamp fStartTime
= new TmfTimestamp(13589692331524L, (byte) -9);
46 private static final TmfTimestamp fEndTime
= new TmfTimestamp(13589907059242L, (byte) -9);
48 private static ITmfTrace
[] fTraces
;
49 private static LTTngExperiment
<TmfEvent
> fExperiment
;
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 private synchronized static ITmfTrace
[] setupTrace(String path
) {
56 if (fTraces
== null) {
57 fTraces
= new ITmfTrace
[1];
59 URL location
= FileLocator
.find(LTTngCoreTestPlugin
.getPlugin().getBundle(), new Path(path
), null);
60 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
61 LTTngTrace trace
= new LTTngTrace(testfile
.getPath());
63 } catch (URISyntaxException e
) {
65 } catch (IOException e
) {
67 } catch (Exception e
) {
74 private synchronized static void setupExperiment() {
75 if (fExperiment
== null) {
76 fExperiment
= new LTTngExperiment
<TmfEvent
>(TmfEvent
.class, EXPERIMENT
, fTraces
, TmfTimestamp
.Zero
, 1000, true);
80 public LTTngExperimentTest(String name
) throws Exception
{
85 protected void setUp() throws Exception
{
87 setupTrace(DIRECTORY
+ File
.separator
+ TEST_STREAM
);
92 protected void tearDown() throws Exception
{
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
100 public void testBasicTmfExperimentConstructor() {
102 assertEquals("GetId", EXPERIMENT
, fExperiment
.getName());
103 assertEquals("GetEpoch", TmfTimestamp
.Zero
, fExperiment
.getEpoch());
104 assertEquals("GetNbEvents", NB_EVENTS
, fExperiment
.getNbEvents());
106 long nbTraceEvents
= fExperiment
.getTraces()[0].getNbEvents();
107 assertEquals("GetNbEvents", NB_EVENTS
, nbTraceEvents
);
109 TmfTimeRange timeRange
= fExperiment
.getTimeRange();
110 assertTrue("getStartTime", fStartTime
.equals(timeRange
.getStartTime()));
111 assertTrue("getEndTime", fEndTime
.equals(timeRange
.getEndTime()));
This page took 0.03505 seconds and 6 git commands to generate.