xml.core: test double valued xml fields
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 31 Mar 2016 22:04:39 +0000 (18:04 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 4 Apr 2016 16:52:09 +0000 (12:52 -0400)
This test also tests the forcedType tag

Change-Id: I84249aa8a1c06bad80def9aba959fd368a06121c
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/69664
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stateprovider/TmfXmlDoubleTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_doubles.xml [new file with mode: 0644]

index 5aa363d10fa79de3aa3332e9083873adef15a5a0..b81c68fe4c018601db66c62130d4888ecffd31e3 100644 (file)
@@ -41,6 +41,8 @@ public enum TmfXmlTestFiles {
     ATTRIBUTE_FILE("test_xml_files/test_valid/test_attributes.xml"),
     /** A valid file for conditions tests */
     CONDITION_FILE("test_xml_files/test_valid/test_conditions.xml"),
+    /** A valid file for doubles tests */
+    DOUBLES_FILE("test_xml_files/test_valid/test_doubles.xml"),
     /** A valid file for pattern tests */
     VALID_PATTERN_FILE("test_xml_files/test_valid/test_valid_pattern.xml"),
     /** A valid pattern file to test the pattern segment **/
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stateprovider/TmfXmlDoubleTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stateprovider/TmfXmlDoubleTest.java
new file mode 100644 (file)
index 0000000..579ee90
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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.analysis.xml.core.tests.stateprovider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.junit.Test;
+
+/**
+ * Test Doubles in xml state system
+ *
+ * @author Matthew Khouzam
+ *
+ */
+public class TmfXmlDoubleTest {
+
+    private static final @NonNull String testTrace3 = "test_traces/testTrace3.xml";
+
+    /**
+     * Test the state system on a double
+     *
+     * @throws TmfAnalysisException
+     *             if it happens, we fail
+     * @throws StateSystemDisposedException
+     *             if it happens, we fail
+     *
+     */
+    @Test
+    public void testConditionsValidation() throws TmfAnalysisException, StateSystemDisposedException {
+        ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace3);
+        XmlStateSystemModule module = XmlUtilsTest.initializeModule(TmfXmlTestFiles.DOUBLES_FILE);
+        module.setTrace(trace);
+
+        module.schedule();
+        module.waitForCompletion();
+
+        ITmfStateSystem ss = module.getStateSystem();
+        assertNotNull(ss);
+        List<ITmfStateInterval> val = ss.queryFullState(2);
+        assertEquals(3.141592, val.get(0).getStateValue().unboxDouble(), Double.MIN_VALUE);
+        val = ss.queryFullState(4);
+        assertEquals(2.71828, val.get(0).getStateValue().unboxDouble(), Double.MIN_VALUE);
+        val = ss.queryFullState(6);
+        assertEquals(1.41421, val.get(0).getStateValue().unboxDouble(), Double.MIN_VALUE);
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml
new file mode 100644 (file)
index 0000000..eff953c
--- /dev/null
@@ -0,0 +1,22 @@
+<!-- ***************************************************************************
+* Copyright (c) 2016 Ericsson
+*
+* 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
+*************************************************************************** -->
+<trace>
+<event timestamp="1" name="x">
+<field name="testField" type="double" value="3.141592" />
+</event>
+<event timestamp="3" name="x">
+<field name="testField" type="double" value="2.71828" />
+</event>
+<event timestamp="5" name="x">
+<field name="testField" type="double" value="1.41421" />
+</event>
+<event timestamp="7" name="x">
+<field name="testField" type="double" value="2.68545" />
+</event>
+</trace>
\ No newline at end of file
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_doubles.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_doubles.xml
new file mode 100644 (file)
index 0000000..c8b1c8c
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***************************************************************************
+* Copyright (c) 2016 Ericsson
+*
+* 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
+*
+* Contributors:
+*   Matthew Khouzam - Initial API and implementation
+*************************************************************************** -->
+<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+       <stateProvider id="test.xml.doubles" version="1">
+               <eventHandler eventName="x">
+                       <stateChange>
+                                       <stateAttribute type="constant" value="testField" />
+                                       <stateValue type="eventField" forcedType="double" value="testField" />
+                       </stateChange>
+               </eventHandler>
+       </stateProvider>
+</tmfxml>
\ No newline at end of file
This page took 0.033206 seconds and 5 git commands to generate.