tmf: enable and fix o.e.tc.tmf.ui.tests.trace test cases
Change-Id: I19aa42577be1d1c7056299d8d29d7e9fa768257f
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/60733
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/69081
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
(cherry picked from commit 2d3a60ecdd7337480521731ae8b5484fafccf427)
Reviewed-on: https://git.eclipse.org/r/69094
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/AllTmfUITests.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/AllTmfUITests.java
index 6adf8bf..e224634 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/AllTmfUITests.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/AllTmfUITests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011-2014 Ericsson
+ * Copyright (c) 2011, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -26,6 +26,7 @@
org.eclipse.tracecompass.tmf.ui.tests.histogram.AllTests.class,
org.eclipse.tracecompass.tmf.ui.tests.project.model.AllTests.class,
org.eclipse.tracecompass.tmf.ui.tests.statistics.AllTests.class,
+ org.eclipse.tracecompass.tmf.ui.tests.trace.AllTests.class,
org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.dialogs.AllTests.class,
org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.load.AllTests.class,
org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader.AllTests.class
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/AbstractCustomTraceIndexTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/AbstractCustomTraceIndexTest.java
index 9fa4ff0..9ddad1f 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/AbstractCustomTraceIndexTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/AbstractCustomTraceIndexTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -49,6 +49,7 @@
* The total number of events in the generated trace
*/
protected static final int NB_EVENTS = 10000;
+ private static final long MILLISECOND_TO_NANOSECOND = 1000000;
private TestTrace fTrace = null;
/**
@@ -152,12 +153,13 @@
}
private void verifyIndexContent() {
+ long endTime = (NB_EVENTS - 1) * MILLISECOND_TO_NANOSECOND;
assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
assertEquals("getRange-start", 0, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS - 1, fTrace.getTimeRange().getEndTime().getValue());
+ assertEquals("getRange-end", endTime, fTrace.getTimeRange().getEndTime().getValue());
assertEquals("getStartTime", 0, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS - 1, fTrace.getEndTime().getValue());
+ assertEquals("getEndTime", endTime, fTrace.getEndTime().getValue());
ITmfCheckpointIndex checkpoints = fTrace.getIndexer().getCheckpoints();
int pageSize = fTrace.getCacheSize();
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceBadlyFormedTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceBadlyFormedTest.java
index 0e94645..4ea6b6f 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceBadlyFormedTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceBadlyFormedTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -19,6 +19,7 @@
import java.util.Collection;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -55,10 +56,14 @@
*/
@Test
public void testBadlyFormed() {
- IStatus valid = getTrace().validate(null, getPath());
- if (IStatus.ERROR != valid.getSeverity()) {
- fail(valid.toString());
+ IStatus invalid = getTrace().validate(null, getPath());
+ // Validation doesn't check for syntax errors. It returns a confidence
+ // of 0 and status OK if it is a text file for malformed xml files.
+ if ((IStatus.ERROR == invalid.getSeverity() ||
+ ((IStatus.OK == invalid.getSeverity() && (invalid instanceof TraceValidationStatus) && ((TraceValidationStatus) invalid).getConfidence() == 0)))) {
+ return;
}
+ fail(getPath());
}
/**
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceInvalidTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceInvalidTest.java
index dbfc3a2..9fe9e62 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceInvalidTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceInvalidTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -19,6 +19,7 @@
import java.util.Collection;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -67,9 +68,15 @@
@Test
public void testInvalid() {
IStatus invalid = getTrace().validate(null, getPath());
- if (IStatus.ERROR != invalid.getSeverity()) {
- fail(getPath());
+
+ // Validation doesn't check for syntax errors. It returns a confidence
+ // of 0 and status OK if it is a text file for invalid xml files.
+ if ((IStatus.ERROR == invalid.getSeverity() ||
+ ((IStatus.OK == invalid.getSeverity() && (invalid instanceof TraceValidationStatus) && ((TraceValidationStatus) invalid).getConfidence() == 0)))) {
+ return;
}
+
+ fail(getPath());
}
}
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceTest.java
index 4dac2dc..b483b6c 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -12,10 +12,8 @@
package org.eclipse.tracecompass.tmf.ui.tests.trace;
-import java.util.ArrayList;
+import java.io.File;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
import org.junit.Before;
@@ -27,6 +25,9 @@
*
*/
public abstract class CustomXmlTraceTest {
+
+ private static final String DEFINITION_PATH = "tracesets" + File.separator + "xml" + File.separator + "testDefinition.xml";
+
private CustomXmlTraceDefinition cxtd;
/**
* The trace to use to "validate" the xml files
@@ -43,7 +44,7 @@
*/
@Before
public void init() {
- cxtd = new CustomXmlTraceDefinition(CustomXmlTraceDefinition.CUSTOM_XML_CATEGORY, "test", new CustomXmlInputElement(), new ArrayList<OutputColumn>(), "s");
+ cxtd = createDefinition();
t = new CustomXmlTrace(cxtd);
}
@@ -71,4 +72,8 @@
this.path = path;
}
+ private static CustomXmlTraceDefinition createDefinition() {
+ CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(new File(DEFINITION_PATH).toString());
+ return definitions[0];
+ }
}