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
.tracecompass
.tmf
.core
.tests
.statesystem
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertNull
;
18 import static org
.junit
.Assert
.fail
;
21 import java
.util
.concurrent
.TimeUnit
;
23 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.tests
.shared
.TmfTestTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.TmfTraceStub
;
29 import org
.junit
.After
;
30 import org
.junit
.Before
;
31 import org
.junit
.Rule
;
32 import org
.junit
.Test
;
33 import org
.junit
.rules
.TestRule
;
34 import org
.junit
.rules
.Timeout
;
37 * Test the {@link TmfStateSystemAnalysisModule} class
39 * @author Geneviève Bastien
41 public class StateSystemAnalysisModuleTest
{
43 /** Time-out tests after 20 seconds */
45 public TestRule globalTimeout
= new Timeout(20, TimeUnit
.SECONDS
);
47 /** ID of the test state system analysis module */
48 public static final String MODULE_SS
= "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest";
50 private TmfStateSystemAnalysisModule module
;
56 public void setupTraces() {
57 TmfTraceStub trace
= (TmfTraceStub
) TmfTestTrace
.A_TEST_10K
.getTrace();
58 TmfSignalManager
.deregister(trace
);
59 trace
.traceOpened(new TmfTraceOpenedSignal(this, trace
, null));
61 module
= (TmfStateSystemAnalysisModule
) trace
.getAnalysisModule(MODULE_SS
);
65 * Some tests use traces, let's clean them here
68 public void cleanupTraces() {
69 TmfTestTrace
.A_TEST_10K
.dispose();
73 * Test the state system module execution and result
76 public void testSsModule() {
77 ITmfStateSystem ss
= module
.getStateSystem();
80 if (module
.waitForCompletion()) {
81 ss
= module
.getStateSystem();
84 fail("Module did not complete properly");
89 * Make sure that the state system is initialized after calling
90 * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
93 public void testInitialization() {
94 assertNull(module
.getStateSystem());
97 module
.waitForInitialization();
98 assertNotNull(module
.getStateSystem());
102 * Test that helper returns the right properties
105 public void testProperties() {
107 TmfStateSystemAnalysisModule mod
= module
;
110 /* The stub state system has in mem backend so only 1 property */
111 Map
<String
, String
> properties
= mod
.getProperties();
112 assertEquals(1, properties
.size());