From: Matthew Khouzam Date: Thu, 31 Mar 2016 22:04:39 +0000 (-0400) Subject: xml.core: test double valued xml fields X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=8765f95a3c5f8a3f0035a981c8d242e793e22c6d;p=deliverable%2Ftracecompass.git xml.core: test double valued xml fields This test also tests the forcedType tag Change-Id: I84249aa8a1c06bad80def9aba959fd368a06121c Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/69664 Reviewed-by: Hudson CI Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien Reviewed-by: Bernd Hufmann --- diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java index 5aa363d10f..b81c68fe4c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java @@ -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 index 0000000000..579ee90d60 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stateprovider/TmfXmlDoubleTest.java @@ -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 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 index 0000000000..eff953c095 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ 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 index 0000000000..c8b1c8cb2c --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_doubles.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + \ No newline at end of file