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