tmf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core.tests / src / org / eclipse / tracecompass / tmf / analysis / xml / core / tests / stateprovider / StateProviderTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
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
13 package org.eclipse.tracecompass.tmf.analysis.xml.core.tests.stateprovider;
14
15 import static org.junit.Assert.assertFalse;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19 import static org.junit.Assume.assumeTrue;
20
21 import java.util.List;
22
23 import org.eclipse.core.runtime.NullProgressMonitor;
24 import org.eclipse.core.runtime.Path;
25 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
26 import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
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.core.exceptions.TmfAnalysisException;
30 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
31 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
32 import org.junit.After;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.w3c.dom.Document;
36 import org.w3c.dom.Element;
37 import org.w3c.dom.NodeList;
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 */
47 public 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 */
58 assumeTrue(CtfTmfTestTrace.KERNEL.exists());
59 ITmfTrace trace = CtfTmfTestTrace.KERNEL.getTrace();
60 fTrace = trace;
61
62 /* Initialize the state provider module */
63 Document doc = TmfXmlTestFiles.VALID_FILE.getXmlDocument();
64 assertNotNull(doc);
65
66 /* get State Providers modules */
67 NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER);
68
69 Element node = (Element) stateproviderNodes.item(0);
70 fModule = new XmlStateSystemModule();
71 String moduleId = node.getAttribute(TmfXmlStrings.ID);
72 assertNotNull(moduleId);
73 fModule.setId(moduleId);
74
75 fModule.setXmlFile(new Path(TmfXmlTestFiles.VALID_FILE.getFile().getAbsolutePath()));
76
77 try {
78 fModule.setTrace(trace);
79 fModule.schedule();
80 } catch (TmfAnalysisException e) {
81 fail("Cannot set trace " + e.getMessage());
82 }
83 }
84
85 /**
86 * Cleanup after the test
87 */
88 @After
89 public void cleanupTest() {
90 fTrace.dispose();
91 }
92
93 /**
94 * Test the building of the state system
95 */
96 @Test
97 public void testStateSystem() {
98 assertTrue(fModule.waitForCompletion(new NullProgressMonitor()));
99 ITmfStateSystem ss = fModule.getStateSystem();
100 assertNotNull(ss);
101
102 List<Integer> quarks = ss.getQuarks("*");
103 assertFalse(quarks.isEmpty());
104 }
105
106 }
This page took 0.038569 seconds and 6 git commands to generate.