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
.assertTrue
;
19 import static org
.junit
.Assert
.fail
;
22 import java
.util
.concurrent
.TimeUnit
;
24 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.Messages
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.tests
.shared
.TmfTestTrace
;
30 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.analysis
.TestStateSystemModule
;
31 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.TmfTraceStub
;
32 import org
.junit
.After
;
33 import org
.junit
.Before
;
34 import org
.junit
.Rule
;
35 import org
.junit
.Test
;
36 import org
.junit
.rules
.TestRule
;
37 import org
.junit
.rules
.Timeout
;
40 * Test the {@link TmfStateSystemAnalysisModule} class
42 * @author Geneviève Bastien
44 public class StateSystemAnalysisModuleTest
{
46 /** Time-out tests after 1 minute. */
48 public TestRule globalTimeout
= new Timeout(1, TimeUnit
.MINUTES
);
50 /** ID of the test state system analysis module */
51 public static final String MODULE_SS
= "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest";
53 private TmfStateSystemAnalysisModule module
;
59 public void setupTraces() {
60 TmfTraceStub trace
= (TmfTraceStub
) TmfTestTrace
.A_TEST_10K
.getTrace();
61 TmfSignalManager
.deregister(trace
);
62 trace
.traceOpened(new TmfTraceOpenedSignal(this, trace
, null));
64 module
= (TmfStateSystemAnalysisModule
) trace
.getAnalysisModule(MODULE_SS
);
68 * Some tests use traces, let's clean them here
71 public void cleanupTraces() {
72 TmfTestTrace
.A_TEST_10K
.dispose();
76 * Test the state system module execution and result
79 public void testSsModule() {
80 ITmfStateSystem ss
= module
.getStateSystem();
83 if (module
.waitForCompletion()) {
84 ss
= module
.getStateSystem();
87 fail("Module did not complete properly");
92 * Make sure that the state system is initialized after calling
93 * {@link TmfStateSystemAnalysisModule#waitForInitialization()}.
96 public void testInitialization() {
97 assertNull(module
.getStateSystem());
100 assertTrue("Initialization succeeded", module
.waitForInitialization());
101 assertNotNull(module
.getStateSystem());
105 * Test that helper returns the right properties
108 public void testProperties() {
110 assertTrue(module
instanceof TestStateSystemModule
);
111 TestStateSystemModule mod
= (TestStateSystemModule
) module
;
113 /* The stub state system has in mem backend 2 properties */
114 Map
<String
, String
> properties
= mod
.getProperties();
115 assertEquals(mod
.getBackendName(), properties
.get(Messages
.TmfStateSystemAnalysisModule_PropertiesBackend
));
116 assertEquals(mod
.getId(), properties
.get(org
.eclipse
.tracecompass
.tmf
.core
.analysis
.Messages
.TmfAbstractAnalysisModule_LabelId
));