import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.Test;
/**
*/
@Test
public void testBuildGraph() {
- TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
+ TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
TmfGraphBuilderModule module = getModule(trace);
module.schedule();
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import com.google.common.collect.ImmutableSet;
*
* @author Geneviève Bastien
*/
-public class TmfXmlKernelTraceStub extends TmfXmlTraceStub implements IKernelTrace {
+public class TmfXmlKernelTraceStub extends TmfXmlTraceStubNs implements IKernelTrace {
private @Nullable IKernelAnalysisEventLayout fLayout;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.Test;
import com.google.common.collect.ImmutableSet;
@Test
public void testExecuteNoDepend() throws TmfAnalysisException {
StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
fixture.setTrace(trace);
assertFalse(fixture.executeAnalysis(new NullProgressMonitor()));
trace.dispose();
@Test
public void testExecute() throws TmfAnalysisException {
StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
fixture.setTrace(trace);
fixture.getDependentAnalyses();
assertTrue(fixture.executeAnalysis(new NullProgressMonitor()));
*/
@Test
public void testTotalStats() throws TmfAnalysisException {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
SegmentStoreStatistics totalStats = fixture.getTotalStats();
assertNotNull(totalStats);
*/
@Test
public void testPerTypeStats() throws TmfAnalysisException {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStats();
assertNotNull(perTypeStats);
*/
@Test
public void testPartialStats() throws TmfAnalysisException {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
SegmentStoreStatistics totalStats = fixture.getTotalStatsForRange(100, 1100, new NullProgressMonitor());
assertNotNull(totalStats);
*/
@Test
public void testPartialPerTypeStats() throws TmfAnalysisException {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStatsForRange(100, 1100, new NullProgressMonitor());
assertNotNull(perTypeStats);
*/
@Test
public void testPartialPerTypeStatsCancel() throws TmfAnalysisException {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
NullProgressMonitor monitor = new NullProgressMonitor();
monitor.setCanceled(true);
SWTBotImportWizardUtils.selectImportFromArchive(fBot, absolutePath.toOSString());
String subFolderName = IS_WIN32 ? "folder_colon" : "folder:colon";
selectFolder(ARCHIVE_ROOT_ELEMENT_NAME, subFolderName);
- SWTBotImportWizardUtils.setOptions(fBot, 0, "Test trace : XML Trace Stub");
+ SWTBotImportWizardUtils.setOptions(fBot, 0, "Test trace : XML Trace Stub (ns)");
importFinish();
TmfProjectElement tmfProject = TmfProjectRegistry.getProject(getProjectResource(), true);
* @return The absolute path of this test file
*/
public IPath getPath() {
- IPath absPath = Activator.getAbsolutePath(new Path(fPath));
- if (absPath == null) {
- fail("Cannot find file path for '" + fPath + "'");
- }
- return absPath;
+ return Activator.getAbsolutePath(new Path(fPath));
}
/**
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jdt.annotation.NonNull;
import org.osgi.framework.BundleContext;
/**
* The path relative to this plugin
* @return The absolute path corresponding to this relative path
*/
- public static IPath getAbsolutePath(Path relativePath) {
+ public static @NonNull IPath getAbsolutePath(Path relativePath) {
Activator plugin2 = getDefault();
if (plugin2 == null) {
/*
* Shouldn't happen but at least throw something to get the test to
* fail early
*/
- return null;
+ throw new IllegalStateException();
}
URL location = FileLocator.find(plugin2.getBundle(), relativePath, null);
try {
IPath path = new Path(FileLocator.toFileURL(location).getPath());
return path;
} catch (IOException e) {
- return null;
+ throw new IllegalStateException(e);
}
}
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.Activator;
import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
-import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.After;
import org.junit.Test;
import org.w3c.dom.Document;
*/
public static @NonNull ITmfTrace initializeTrace(String traceFile) {
/* Initialize the trace */
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
- try {
- trace.initTrace(null, Activator.getAbsolutePath(new Path(traceFile)).toOSString(), TmfEvent.class);
- } catch (TmfTraceException e1) {
- fail(e1.getMessage());
- }
+ TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsolutePath(new Path(traceFile)));
return trace;
}
* Geneviève Bastien - Initial API and implementation
*************************************************************************** -->
<trace>
-<event timestamp="1" name="test" source="0">
+<event timestamp="1" name="test">
</event>
-<event timestamp="3" name="test1" source="0">
+<event timestamp="3" name="test1">
</event>
-<event timestamp="5" name="test" source="0">
+<event timestamp="5" name="test">
</event>
-<event timestamp="7" name="test1" source="0">
+<event timestamp="7" name="test1">
</event>
</trace>
\ No newline at end of file
*************************************************************************** -->
<trace>
<event timestamp="1" name="x">
-<field name="testField" type="double" value="3.141592" />
+<field name="testField" type="string" value="3.141592" />
</event>
<event timestamp="3" name="x">
-<field name="testField" type="double" value="2.71828" />
+<field name="testField" type="string" value="2.71828" />
</event>
<event timestamp="5" name="x">
-<field name="testField" type="double" value="1.41421" />
+<field name="testField" type="string" value="1.41421" />
</event>
<event timestamp="7" name="x">
-<field name="testField" type="double" value="2.68545" />
+<field name="testField" type="string" value="2.68545" />
</event>
</trace>
\ No newline at end of file
* Geneviève Bastien - Initial API and implementation
*************************************************************************** -->
<trace>
-<event timestamp="1" name="entry" source="0">
+<event timestamp="1" name="entry">
<field name="cpu" type="int" value="0" />
<field name="op" type="string" value="op1" />
</event>
-<event timestamp="3" name="exit" source="0">
+<event timestamp="3" name="exit">
<field name="cpu" type="int" value="0" />
<field name="curState" type="string" value="GOOD" />
<field name="op" type="string" value="op1" />
</event>
-<event timestamp="5" name="entry" source="0">
+<event timestamp="5" name="entry">
<field name="cpu" type="int" value="0" />
<field name="op" type="string" value="op1" />
</event>
-<event timestamp="7" name="exit" source="0">
+<event timestamp="7" name="exit">
<field name="cpu" type="int" value="0" />
<field name="curState" type="string" value="BAD" />
<field name="op" type="string" value="op1" />
* http://www.eclipse.org/legal/epl-v10.html
*************************************************************************** -->
<trace>
-<event timestamp="1" name="entry" source="0">
+<event timestamp="1" name="entry">
<field name="cpu" type="int" value="0" />
</event>
-<event timestamp="3" name="entry" source="0">
+<event timestamp="3" name="entry">
<field name="cpu" type="int" value="0" />
</event>
-<event timestamp="5" name="entry" source="0">
+<event timestamp="5" name="entry">
<field name="cpu" type="int" value="0" />
</event>
-<event timestamp="7" name="exit" source="0">
+<event timestamp="7" name="exit">
<field name="cpu" type="int" value="0" />
</event>
</trace>
\ No newline at end of file
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.Test;
/**
@Test
public void testBuiltinOutput() {
- TmfTrace trace = new TmfXmlTraceStub();
+ TmfTrace trace = new TmfXmlTraceStubNs();
try {
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
category="org.eclipse.linuxtools.tmf.core.tests.category"
event_type="org.eclipse.tracecompass.tmf.core.event.TmfEvent"
id="org.eclipse.linuxtools.tmf.core.tests.xmlstub"
- name="XML Trace Stub"
- trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub">
+ name="XML Trace Stub (ns)"
+ trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs">
+ </type>
+ <type
+ category="org.eclipse.linuxtools.tmf.core.tests.category"
+ event_type="org.eclipse.tracecompass.tmf.core.event.TmfEvent"
+ id="org.eclipse.linuxtools.tmf.core.tests.xmlstubsec"
+ name="XML Trace Stub (sec)"
+ trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubSec">
</type>
</extension>
<extension
import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemModule;
import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemProvider;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
*/
@Before
public void setupTraces() {
- TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(XML_TRACE));
+ TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(XML_TRACE));
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fTrace = trace;
import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestExperimentAnalysis;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
assertTrue("isCancelled", request.isCancelled());
}
- private static abstract class TestTrace extends TmfXmlTraceStub implements ITmfPropertiesProvider {
+ private static abstract class TestTrace extends TmfXmlTraceStubNs implements ITmfPropertiesProvider {
}
};
t2.setTimestampTransform(tt2);
- ITmfTrace t3 = new TmfXmlTraceStub() {
+ ITmfTrace t3 = new TmfXmlTraceStubNs() {
@Override
public @NonNull String getHostId() {
return hostId2;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
import org.junit.Test;
/**
- * Test suite for the {@link TmfXmlTraceStub} class
+ * Test suite for the {@link TmfXmlTraceStubNs} class
*
* @author Geneviève Bastien
*/
/**
* Test the
- * {@link TmfXmlTraceStub#validate(org.eclipse.core.resources.IProject, String)}
+ * {@link TmfXmlTraceStubNs#validate(org.eclipse.core.resources.IProject, String)}
* method
*/
@Test
public void testValidate() {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ TmfXmlTraceStubNs trace = new TmfXmlTraceStubNs();
File[] invalidFiles = TmfCoreTestPlugin.getAbsoluteFilePath(INVALID_PATH).toFile().listFiles();
assertTrue(invalidFiles.length > 0);
for (File f : invalidFiles) {
*/
@Test
public void testDevelopmentTrace() {
- TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
+ TmfXmlTraceStubNs trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
CustomEventRequest req = new CustomEventRequest(trace);
trace.sendRequest(req);
*/
@Test
public void testAspects() {
- TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
+ TmfXmlTraceStubNs trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
ITmfEventAspect<?> cpuAspect = null;
ITmfEventAspect<?> testAspect = null;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<CustomXMLTraceDefinitionList>
-<Definition name="set_aspects">
-<InputElement name="trace">
-<InputElement logentry="true" name="set_aspects">
-<InputData action="0" format="" name="Ignore"/>
-<InputElement name="field">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="2" format="" name="fields"/>
-</Attribute>
-<Attribute name="type">
-<InputData action="2" format="" name="type"/>
-</Attribute>
-<Attribute name="value">
-<InputData action="2" format="" name="values"/>
-</Attribute>
-</InputElement>
-</InputElement>
-</InputElement>
-<OutputColumn name="fields"/>
-<OutputColumn name="values"/>
-<OutputColumn name="type"/>
-</Definition>
-<Definition name="events">
-<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
-<InputElement name="trace">
-<InputElement logentry="true" name="event">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="0" format="" name="Message"/>
-</Attribute>
-<Attribute name="timestamp">
-<InputData action="0" format="Tn" name="Time Stamp"/>
-</Attribute>
-<InputElement name="field">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="2" format="" name="fields"/>
-</Attribute>
-<Attribute name="type">
-<InputData action="2" format="" name="type"/>
-</Attribute>
-<Attribute name="value">
-<InputData action="2" format="" name="values"/>
-</Attribute>
-</InputElement>
-</InputElement>
-</InputElement>
-<OutputColumn name="Time Stamp"/>
-<OutputColumn name="Message"/>
-<OutputColumn name="source"/>
-<OutputColumn name="fields"/>
-<OutputColumn name="values"/>
-<OutputColumn name="type"/>
-</Definition>
-</CustomXMLTraceDefinitionList>
<xs:enumeration value="int"/>
<xs:enumeration value="long"/>
<xs:enumeration value="string"/>
+ <xs:enumeration value="double"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomXMLTraceDefinitionList>
+<Definition name="set_aspects">
+<InputElement name="trace">
+<InputElement logentry="true" name="set_aspects">
+<InputData action="0" format="" name="Ignore"/>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+<Definition name="events">
+<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
+<InputElement name="trace">
+<InputElement logentry="true" name="event">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="0" format="" name="Message"/>
+</Attribute>
+<Attribute name="timestamp">
+<InputData action="0" format="Tn" name="Time Stamp"/>
+</Attribute>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="Time Stamp"/>
+<OutputColumn name="Message"/>
+<OutputColumn name="source"/>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+</CustomXMLTraceDefinitionList>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomXMLTraceDefinitionList>
+<Definition name="set_aspects">
+<InputElement name="trace">
+<InputElement logentry="true" name="set_aspects">
+<InputData action="0" format="" name="Ignore"/>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+<Definition name="events">
+<TimeStampOutputFormat>T</TimeStampOutputFormat>
+<InputElement name="trace">
+<InputElement logentry="true" name="event">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="0" format="" name="Message"/>
+</Attribute>
+<Attribute name="timestamp">
+<InputData action="0" format="T" name="Time Stamp"/>
+</Attribute>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="Time Stamp"/>
+<OutputColumn name="Message"/>
+<OutputColumn name="source"/>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+</CustomXMLTraceDefinitionList>
package org.eclipse.tracecompass.tmf.tests.stubs.trace.xml;
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.annotation.DefaultLocation;
*
* @author Geneviève Bastien
*/
-public class TmfXmlTraceStub extends TmfTrace {
+public abstract class TmfXmlTraceStub extends TmfTrace {
- private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTrace.xml"; //$NON-NLS-1$
private static final String DEVELOPMENT_TRACE_XSD = "TmfXmlDevelopmentTrace.xsd"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private final Collection<ITmfEventAspect<?>> fAdditionalAspects = new HashSet<>();
private final Collection<IAnalysisModule> fAdditionalModules = new HashSet<>();
- /**
- * Validate and initialize a {@link TmfXmlTraceStub} object
- *
- * @param absolutePath
- * The absolute file path of the trace file
- * @return The trace
- */
- public static TmfXmlTraceStub setupTrace(IPath absolutePath) {
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
- IStatus status = trace.validate(null, absolutePath.toOSString());
- if (!status.isOK()) {
- fail(status.getException().getMessage());
- }
- try {
- trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
- } catch (TmfTraceException e) {
- trace.dispose();
- fail(e.getMessage());
- }
- return trace;
- }
-
/**
* Constructor. Constructs the custom XML trace with the appropriate
* definition.
public TmfXmlTraceStub() {
boolean nonNullTraceIsNonNull = false;
/* Load custom XML definition */
- try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(DEVELOPMENT_TRACE_PARSER_PATH);) {
+ try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(getParserFileName());) {
CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(in);
if (definitions.length < 2) {
throw new IllegalStateException("The custom trace definition does not exist"); //$NON-NLS-1$
}
+ /**
+ * Get the name of the file that contains the XML parser for this trace
+ * stub. The file should be located in this class's package.
+ *
+ * @return The name of the file
+ */
+ protected abstract String getParserFileName();
+
@Override
@NonNullByDefault({DefaultLocation.TYPE_ARGUMENT})
public void initTrace(@Nullable IResource resource, @Nullable String path, @Nullable Class<? extends ITmfEvent> type) throws TmfTraceException {
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.tests.stubs.trace.xml;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+
+/**
+ * An XML development trace using a custom XML trace definition and schema.
+ *
+ * This class will typically be used to build custom traces to unit test more
+ * complex functionalities like analyzes or to develop and test data-driven
+ * analyzes.
+ *
+ * This class wraps a custom XML trace and rewrites the returned events in the
+ * getNext() method so that event's fields are the ones defined in <field ... />
+ * elements instead of those defined in the custom XML parser. This way, each
+ * event can have a different set of fields. This class can, for example, mimic
+ * a CTF trace.
+ *
+ * The timestamps of this trace will be in nanoseconds
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfXmlTraceStubNs extends TmfXmlTraceStub {
+
+ private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTraceNs.xml"; //$NON-NLS-1$
+
+ /**
+ * Validate and initialize a {@link TmfXmlTraceStubNs} object
+ *
+ * @param absolutePath
+ * The absolute file path of the trace file
+ * @return The trace
+ */
+ public static TmfXmlTraceStubNs setupTrace(IPath absolutePath) {
+ TmfXmlTraceStubNs trace = new TmfXmlTraceStubNs();
+ IStatus status = trace.validate(null, absolutePath.toOSString());
+ if (!status.isOK()) {
+ fail(status.getException().getMessage());
+ }
+ try {
+ trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
+ } catch (TmfTraceException e) {
+ trace.dispose();
+ fail(e.getMessage());
+ }
+ return trace;
+ }
+
+ @Override
+ protected @NonNull String getParserFileName() {
+ return DEVELOPMENT_TRACE_PARSER_PATH;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.tests.stubs.trace.xml;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+
+/**
+ * An XML development trace using a custom XML trace definition and schema.
+ *
+ * This class will typically be used to build custom traces to unit test more
+ * complex functionalities like analyzes or to develop and test data-driven
+ * analyzes.
+ *
+ * This class wraps a custom XML trace and rewrites the returned events in the
+ * getNext() method so that event's fields are the ones defined in <field ... />
+ * elements instead of those defined in the custom XML parser. This way, each
+ * event can have a different set of fields. This class can, for example, mimic
+ * a CTF trace.
+ *
+ * The timestamps of this trace will be in seconds
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfXmlTraceStubSec extends TmfXmlTraceStub {
+
+ private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTraceSec.xml"; //$NON-NLS-1$
+
+ /**
+ * Validate and initialize a {@link TmfXmlTraceStubSec} object
+ *
+ * @param absolutePath
+ * The absolute file path of the trace file
+ * @return The trace
+ */
+ public static TmfXmlTraceStubSec setupTrace(IPath absolutePath) {
+ TmfXmlTraceStubSec trace = new TmfXmlTraceStubSec();
+ IStatus status = trace.validate(null, absolutePath.toOSString());
+ if (!status.isOK()) {
+ fail(status.getException().getMessage());
+ }
+ try {
+ trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
+ } catch (TmfTraceException e) {
+ trace.dispose();
+ fail(e.getMessage());
+ }
+ return trace;
+ }
+
+ @Override
+ protected @NonNull String getParserFileName() {
+ return DEVELOPMENT_TRACE_PARSER_PATH;
+ }
+
+}
private static final String COMPARE = "COMPARE";
private static final String CONTAINS = "CONTAINS";
private static final String XMLSTUB_ID = "org.eclipse.linuxtools.tmf.core.tests.xmlstub";
- private static final String TRACETYPE = "Test trace : XML Trace Stub";
+ private static final String TRACETYPE = "Test trace : XML Trace Stub (ns)";
private static final String AND = "AND";
private static final String WITH_TRACETYPE = "WITH TRACETYPE " + TRACETYPE;
private static final String FILTER_TEST = "FILTER ";