tmf : Fix the xml condition multiple problem
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / core / tests / stateprovider / TmfXmlConditionTest.java
CommitLineData
900cbf89
JCK
1/*******************************************************************************
2 * Copyright (c) 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Jean-Christian Kouame - Initial API and implementation
11 *******************************************************************************/
12package org.eclipse.tracecompass.tmf.analysis.xml.core.tests.stateprovider;
13
14import static org.junit.Assert.assertEquals;
15import static org.junit.Assert.assertNotNull;
16import static org.junit.Assert.fail;
17
18import java.util.List;
19
20import org.eclipse.jdt.annotation.NonNull;
21import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
22import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
23import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
24import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
25import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
26import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
27import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
28import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest;
29import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
30import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
31import org.junit.Test;
32
33/**
34 * Test suite for the XML conditions
35 *
36 */
37public class TmfXmlConditionTest {
38
39 private static final @NonNull String testTrace2 = "test_traces/testTrace2.xml";
40
41 /**
42 *
43 */
44 @Test
45 public void testConditionsValidation() {
46 ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace2);
47 XmlStateSystemModule module = XmlUtilsTest.initializeModule(TmfXmlTestFiles.CONDITION_FILE);
48 try {
49 module.setTrace(trace);
50
51 module.schedule();
52 module.waitForCompletion();
53
54 ITmfStateSystem ss = module.getStateSystem();
55 assertNotNull(ss);
56
57 List<Integer> quarks = ss.getQuarks("*");
1010de5e 58 assertEquals(4, quarks.size());
900cbf89
JCK
59
60 for (Integer quark : quarks) {
61 String name = ss.getAttributeName(quark);
62 switch (name) {
63 case "test": {
64 final int[] expectedStarts = { 1, 5, 7 };
65 ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
66 XmlUtilsTest.verifyStateIntervals("test", ss, quark, expectedStarts, expectedValues);
67 }
68 break;
69 case "test1": {
70 final int[] expectedStarts = { 1, 3, 7, 7 };
71 ITmfStateValue[] expectedValues = { TmfStateValue.nullValue(), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
72 XmlUtilsTest.verifyStateIntervals("test1", ss, quark, expectedStarts, expectedValues);
73 }
74 break;
75 case "checkpoint": {
76 final int[] expectedStarts = { 1, 5, 7, 7 };
77 ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
78 XmlUtilsTest.verifyStateIntervals("checkpoint", ss, quark, expectedStarts, expectedValues);
79 }
80 break;
1010de5e
JCK
81 case "or_three_operands": {
82 final int[] expectedStarts = { 1, 5, 7, 7 };
83 ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
84 XmlUtilsTest.verifyStateIntervals("or_three_operands", ss, quark, expectedStarts, expectedValues);
85 }
86 break;
900cbf89
JCK
87 default:
88 fail("Wrong attribute name " + name);
89 break;
90 }
91 }
92 } catch (TmfAnalysisException | AttributeNotFoundException | StateSystemDisposedException e) {
93 fail(e.getMessage());
94 } finally {
95 module.dispose();
96 trace.dispose();
97 }
98 }
99}
This page took 0.028877 seconds and 5 git commands to generate.