Move alltests plugin to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / analysis / AnalysisParameterProviderTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
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
13 package org.eclipse.linuxtools.tmf.core.tests.analysis;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.fail;
17
18 import java.util.List;
19
20 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
21 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
22 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisParameterProvider;
23 import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
24 import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
25 import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
26 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
27 import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
28 import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysisParameterProvider;
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 /**
34 * Test the TmfAbstractParameterProvider class
35 *
36 * @author Geneviève Bastien
37 */
38 public class AnalysisParameterProviderTest {
39
40 /**
41 * Registers the parameter provider
42 */
43 @Before
44 public void setup() {
45 TmfAnalysisManager.registerParameterProvider(AnalysisManagerTest.MODULE_PARAM, TestAnalysisParameterProvider.class);
46 }
47
48 /**
49 * Cleanup the trace after testing
50 */
51 @After
52 public void cleanupTrace() {
53 TmfTestTrace.A_TEST_10K.dispose();
54 }
55
56 /**
57 * Test that the provider's value is used
58 */
59 @Test
60 public void testProviderTmfTrace() {
61 ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
62 /* Make sure the value is set to null */
63 IAnalysisModuleHelper helper = TmfAnalysisManager.getAnalysisModule(AnalysisManagerTest.MODULE_PARAM);
64 try (IAnalysisModule module = helper.newModule(trace);) {
65
66 assertEquals(10, module.getParameter(TestAnalysis.PARAM_TEST));
67
68 /* Change the value of the parameter in the provider */
69 List<IAnalysisParameterProvider> providers = TmfAnalysisManager.getParameterProviders(module, trace);
70 assertEquals(1, providers.size());
71 TestAnalysisParameterProvider provider = (TestAnalysisParameterProvider) providers.get(0);
72 provider.setValue(5);
73 assertEquals(5, module.getParameter(TestAnalysis.PARAM_TEST));
74
75 } catch (TmfAnalysisException e) {
76 fail(e.getMessage());
77 return;
78 }
79 }
80
81 }
This page took 0.033639 seconds and 5 git commands to generate.