1 /*******************************************************************************
2 * Copyright (c) 2013, 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
.linuxtools
.tmf
.core
.tests
.statesystem
;
15 import static org
.junit
.Assert
.assertNotNull
;
16 import static org
.junit
.Assert
.assertNull
;
17 import static org
.junit
.Assert
.fail
;
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
;
33 * Test the {@link TmfStateSystemAnalysisModule} class
35 * @author Geneviève Bastien
37 public class StateSystemAnalysisModuleTest
{
39 /** Time-out tests after 20 seconds */
41 public TestRule globalTimeout
= new Timeout(20000);
43 /** ID of the test state system analysis module */
44 public static final String MODULE_SS
= "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest";
46 private TmfStateSystemAnalysisModule module
;
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));
57 module
= (TmfStateSystemAnalysisModule
) trace
.getAnalysisModule(MODULE_SS
);
61 * Some tests use traces, let's clean them here
64 public void cleanupTraces() {
65 TmfTestTrace
.A_TEST_10K
.dispose();
69 * Test the state system module execution and result
72 public void testSsModule() {
73 ITmfStateSystem ss
= module
.getStateSystem();
76 if (module
.waitForCompletion()) {
77 ss
= module
.getStateSystem();
80 fail("Module did not complete properly");
85 * Make sure that the state system is initialized after calling
86 * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
89 public void testInitialization() {
90 assertNull(module
.getStateSystem());
93 module
.waitForInitialization();
94 assertNotNull(module
.getStateSystem());