1 /*******************************************************************************
2 * Copyright (c) 2013 É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
.linuxtools
.tmf
.core
.tests
.analysis
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.fail
;
18 import java
.util
.List
;
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
;
34 * Test the TmfAbstractParameterProvider class
36 * @author Geneviève Bastien
38 public class AnalysisParameterProviderTest
{
41 * Registers the parameter provider
45 TmfAnalysisManager
.registerParameterProvider(AnalysisManagerTest
.MODULE_PARAM
, TestAnalysisParameterProvider
.class);
49 * Cleanup the trace after testing
52 public void cleanupTrace() {
53 TmfTestTrace
.A_TEST_10K
.dispose();
57 * Test that the provider's value is used
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
);) {
66 assertEquals(10, module
.getParameter(TestAnalysis
.PARAM_TEST
));
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);
73 assertEquals(5, module
.getParameter(TestAnalysis
.PARAM_TEST
));
75 } catch (TmfAnalysisException e
) {