tmf: Split the state system in a separate plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / statesystem / StateSystemAnalysisModuleTest.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.linuxtools.tmf.core.tests.statesystem;
14
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertNull;
17 import static org.junit.Assert.fail;
18
19 import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
20 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
21 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
22 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
23 import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
24 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.rules.TestRule;
30 import org.junit.rules.Timeout;
31
32 /**
33 * Test the {@link TmfStateSystemAnalysisModule} class
34 *
35 * @author Geneviève Bastien
36 */
37 public class StateSystemAnalysisModuleTest {
38
39 /** Time-out tests after 20 seconds */
40 @Rule
41 public TestRule globalTimeout= new Timeout(20000);
42
43 /** ID of the test state system analysis module */
44 public static final String MODULE_SS = "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest";
45
46 private TmfStateSystemAnalysisModule module;
47
48 /**
49 * Setup test trace
50 */
51 @Before
52 public void setupTraces() {
53 TmfTraceStub trace = (TmfTraceStub) TmfTestTrace.A_TEST_10K.getTrace();
54 TmfSignalManager.deregister(trace);
55 trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
56
57 module = (TmfStateSystemAnalysisModule) trace.getAnalysisModule(MODULE_SS);
58 }
59
60 /**
61 * Some tests use traces, let's clean them here
62 */
63 @After
64 public void cleanupTraces() {
65 TmfTestTrace.A_TEST_10K.dispose();
66 }
67
68 /**
69 * Test the state system module execution and result
70 */
71 @Test
72 public void testSsModule() {
73 ITmfStateSystem ss = module.getStateSystem();
74 assertNull(ss);
75 module.schedule();
76 if (module.waitForCompletion()) {
77 ss = module.getStateSystem();
78 assertNotNull(ss);
79 } else {
80 fail("Module did not complete properly");
81 }
82 }
83
84 /**
85 * Make sure that the state system is initialized after calling 
86 * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
87 */
88 @Test
89 public void testInitialization() {
90 assertNull(module.getStateSystem());
91 module.schedule();
92
93 module.waitForInitialization();
94 assertNotNull(module.getStateSystem());
95 }
96
97 }
This page took 0.040472 seconds and 5 git commands to generate.