TMF: Add a few NonNull annotations to remove warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / analysis / AnalysisParameterProviderTest.java
CommitLineData
c068a752
GB
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
13package org.eclipse.linuxtools.tmf.core.tests.analysis;
14
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.fail;
17
18import java.util.List;
19
20import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
21import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
22import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisParameterProvider;
23import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
24import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
25import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
26import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
27import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysis;
28import org.eclipse.linuxtools.tmf.tests.stubs.analysis.TestAnalysisParameterProvider;
29import org.junit.After;
30import org.junit.Before;
31import org.junit.Test;
32
33/**
34 * Test the TmfAbstractParameterProvider class
35 *
36 * @author Geneviève Bastien
37 */
38public 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 IAnalysisModule module;
65 try {
66 module = helper.newModule(trace);
67 } catch (TmfAnalysisException e) {
68 fail(e.getMessage());
69 return;
70 }
71 assertEquals(10, module.getParameter(TestAnalysis.PARAM_TEST));
72
73 /* Change the value of the parameter in the provider */
74 List<IAnalysisParameterProvider> providers = TmfAnalysisManager.getParameterProviders(module, trace);
75 assertEquals(1, providers.size());
76 TestAnalysisParameterProvider provider = (TestAnalysisParameterProvider) providers.get(0);
77 provider.setValue(5);
78 assertEquals(5, module.getParameter(TestAnalysis.PARAM_TEST));
79 }
80
81}
This page took 0.037911 seconds and 5 git commands to generate.