1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.stateprovider
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.fail
;
19 import java
.util
.List
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
23 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.AttributeNotFoundException
;
24 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateSystemDisposedException
;
25 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
;
26 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.TmfStateValue
;
27 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.stateprovider
.XmlStateSystemModule
;
28 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.common
.TmfXmlTestFiles
;
29 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.tests
.module
.XmlUtilsTest
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
32 import org
.junit
.Test
;
35 * Test the XML model for state providers
37 * @author Geneviève Bastien
39 public class StateProviderModelTest
{
41 private static final @NonNull String testTrace1
= "test_traces/testTrace1.xml";
44 * Test an increment of one, for an event name attribute
47 public void testEventName() {
48 ITmfTrace trace
= XmlUtilsTest
.initializeTrace(testTrace1
);
49 XmlStateSystemModule module
= XmlUtilsTest
.initializeModule(TmfXmlTestFiles
.ATTRIBUTE_FILE
);
52 module
.setTrace(trace
);
55 module
.waitForCompletion();
57 ITmfStateSystem ss
= module
.getStateSystem();
60 List
<Integer
> quarks
= ss
.getQuarks("*");
61 assertEquals(2, quarks
.size());
63 for (Integer quark
: quarks
) {
64 String name
= ss
.getAttributeName(quark
);
68 final int[] expectedStarts
= { 1, 5, 7 };
69 ITmfStateValue
[] expectedValues
= { TmfStateValue
.newValueInt(1), TmfStateValue
.newValueInt(2) };
70 XmlUtilsTest
.verifyStateIntervals("test", ss
, quark
, expectedStarts
, expectedValues
);
75 final int[] expectedStarts
= { 1, 3, 7, 7 };
76 ITmfStateValue
[] expectedValues
= { TmfStateValue
.nullValue(), TmfStateValue
.newValueInt(1), TmfStateValue
.newValueInt(2) };
77 XmlUtilsTest
.verifyStateIntervals("test1", ss
, quark
, expectedStarts
, expectedValues
);
81 fail("Wrong attribute name " + name
);
86 } catch (TmfAnalysisException
| AttributeNotFoundException
| StateSystemDisposedException e
) {