1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Jean-Christian Kouame - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.stateprovider
;
14 import static org
.junit
.Assert
.assertEquals
;
15 import static org
.junit
.Assert
.assertNotNull
;
16 import static org
.junit
.Assert
.fail
;
18 import java
.util
.List
;
20 import org
.eclipse
.jdt
.annotation
.NonNull
;
21 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
22 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.AttributeNotFoundException
;
23 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateSystemDisposedException
;
24 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
;
25 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.TmfStateValue
;
26 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.stateprovider
.XmlStateSystemModule
;
27 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.common
.TmfXmlTestFiles
;
28 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.module
.XmlUtilsTest
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.junit
.Test
;
34 * Test suite for the XML conditions
37 public class TmfXmlConditionTest
{
39 private static final @NonNull String testTrace2
= "test_traces/testTrace2.xml";
45 public void testConditionsValidation() {
46 ITmfTrace trace
= XmlUtilsTest
.initializeTrace(testTrace2
);
47 XmlStateSystemModule module
= XmlUtilsTest
.initializeModule(TmfXmlTestFiles
.CONDITION_FILE
);
49 module
.setTrace(trace
);
52 module
.waitForCompletion();
54 ITmfStateSystem ss
= module
.getStateSystem();
57 List
<Integer
> quarks
= ss
.getQuarks("*");
58 assertEquals(4, quarks
.size());
60 for (Integer quark
: quarks
) {
61 String name
= ss
.getAttributeName(quark
);
64 final int[] expectedStarts
= { 1, 5, 7 };
65 ITmfStateValue
[] expectedValues
= { TmfStateValue
.newValueLong(1), TmfStateValue
.newValueLong(0) };
66 XmlUtilsTest
.verifyStateIntervals("test", ss
, quark
, expectedStarts
, expectedValues
);
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
);
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
);
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
);
88 fail("Wrong attribute name " + name
);
92 } catch (TmfAnalysisException
| AttributeNotFoundException
| StateSystemDisposedException e
) {