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