tmf: enable and fix o.e.tc.tmf.ui.tests.trace test cases
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Wed, 18 Nov 2015 18:14:39 +0000 (13:14 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Thu, 19 Nov 2015 11:57:39 +0000 (06:57 -0500)
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>
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/AllTmfUITests.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/AbstractCustomTraceIndexTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceBadlyFormedTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceInvalidTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomXmlTraceTest.java

index 6adf8bf33ec0e35b1bc8d409fd245d4c36b00e81..e22463404c54d37b2034bdb6655d330b317cfc77 100644 (file)
@@ -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 @@ import org.junit.runner.RunWith;
         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
index 9fa4ff0b24d9f61edbf7cd9489a59f86b3b49b98..9ddad1f2f8ed8aa5530ec80dad21158452803cde 100644 (file)
@@ -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 @@ public abstract class AbstractCustomTraceIndexTest {
      * 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 @@ public abstract class AbstractCustomTraceIndexTest {
     }
 
     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();
index 0e946450edc03006c972f6e6adab5c36c53e49fb..4ea6b6fcc8915eb91ed092ab496f272008a179a5 100644 (file)
@@ -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.ArrayList;
 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 @@ public class CustomXmlTraceBadlyFormedTest extends CustomXmlTraceTest {
      */
     @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());
     }
 
     /**
index dbfc3a2874781e3ab4431ba211201be729f116ba..9fe9e623266d88735075753ca489b88d69306fff 100644 (file)
@@ -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.ArrayList;
 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 @@ public class CustomXmlTraceInvalidTest extends CustomXmlTraceTest{
     @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());
     }
 
 }
index 4dac2dc296cb5b9ab461414fcef1f604c54b658c..b483b6c1bde163a573df9fca7fb7829bd3aafee2 100644 (file)
@@ -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
 
 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 @@ import org.junit.Before;
  *
  */
 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 @@ public abstract class CustomXmlTraceTest {
      */
     @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 @@ public abstract class CustomXmlTraceTest {
         this.path = path;
     }
 
+    private static CustomXmlTraceDefinition createDefinition() {
+        CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(new File(DEFINITION_PATH).toString());
+        return definitions[0];
+    }
 }
This page took 0.032856 seconds and 5 git commands to generate.