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