ctf: Depend on the tracecompass-test-traces project
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / core / tests / stateprovider / StateProviderTest.java
CommitLineData
8945f67f 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
8945f67f
GB
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 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.tmf.analysis.xml.core.tests.stateprovider;
8945f67f
GB
14
15import static org.junit.Assert.assertFalse;
16import static org.junit.Assert.assertNotNull;
17import static org.junit.Assert.assertTrue;
18import static org.junit.Assert.fail;
8945f67f 19
8945f67f
GB
20import java.util.List;
21
8945f67f
GB
22import org.eclipse.core.runtime.NullProgressMonitor;
23import org.eclipse.core.runtime.Path;
e894a508 24import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
c4d57ac1 25import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
2bdf0193
AM
26import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
27import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.XmlStateSystemModule;
28import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
29import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
30import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
c4d57ac1 31import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
8945f67f
GB
32import org.junit.After;
33import org.junit.Before;
34import org.junit.Test;
35import org.w3c.dom.Document;
36import org.w3c.dom.Element;
37import org.w3c.dom.NodeList;
8945f67f
GB
38
39/**
40 * Test suite for the xml state providers
41 *
42 * TODO: instead of using one of the test traces, we should make a custom trace
43 * to make sure it covers the different possibilities of the state provider
44 *
45 * @author Geneviève Bastien
46 */
47public class StateProviderTest {
48
49 private ITmfTrace fTrace;
50 private XmlStateSystemModule fModule;
51
52 /**
53 * Setup the test fields
54 */
55 @Before
56 public void setupTest() {
57 /* Initialize the trace */
c4d57ac1 58 ITmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.KERNEL);
ba27dd38 59 fTrace = trace;
8945f67f
GB
60
61 /* Initialize the state provider module */
9a0aa59e 62 Document doc = TmfXmlTestFiles.VALID_FILE.getXmlDocument();
8945f67f
GB
63 assertNotNull(doc);
64
65 /* get State Providers modules */
66 NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER);
67
68 Element node = (Element) stateproviderNodes.item(0);
69 fModule = new XmlStateSystemModule();
f47f1bbe 70 String moduleId = node.getAttribute(TmfXmlStrings.ID);
ba27dd38 71 assertNotNull(moduleId);
8945f67f
GB
72 fModule.setId(moduleId);
73
74 fModule.setXmlFile(new Path(TmfXmlTestFiles.VALID_FILE.getFile().getAbsolutePath()));
aa89118c 75
8945f67f 76 try {
ba27dd38 77 fModule.setTrace(trace);
8945f67f
GB
78 fModule.schedule();
79 } catch (TmfAnalysisException e) {
80 fail("Cannot set trace " + e.getMessage());
81 }
82 }
83
84 /**
85 * Cleanup after the test
86 */
87 @After
88 public void cleanupTest() {
ba27dd38 89 fTrace.dispose();
8945f67f
GB
90 }
91
92 /**
93 * Test the building of the state system
94 */
95 @Test
96 public void testStateSystem() {
97 assertTrue(fModule.waitForCompletion(new NullProgressMonitor()));
98 ITmfStateSystem ss = fModule.getStateSystem();
99 assertNotNull(ss);
100
101 List<Integer> quarks = ss.getQuarks("*");
102 assertFalse(quarks.isEmpty());
103 }
104
105}
This page took 0.061226 seconds and 5 git commands to generate.