From: Geneviève Bastien Date: Mon, 7 Jul 2014 17:11:52 +0000 (-0400) Subject: TMF: bug 438949: fix the traceTypeApplies method in analysis module helper X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=04da5385369d91be0cd8202a81e99b21be8a9a86;p=deliverable%2Ftracecompass.git TMF: bug 438949: fix the traceTypeApplies method in analysis module helper Analysis modules described in configuration elements can now support correctly many trace type elements. And it makes sure the applies="false" is treated correctly as well. Change-Id: I8e940bdde94feaa709ccac48e671aa5dced1a5c5 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/29564 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir Reviewed-by: Vincent Perot --- diff --git a/org.eclipse.linuxtools.tmf.core.tests/plugin.xml b/org.eclipse.linuxtools.tmf.core.tests/plugin.xml index 686156a7f3..bf01118274 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/plugin.xml +++ b/org.eclipse.linuxtools.tmf.core.tests/plugin.xml @@ -13,6 +13,10 @@ + + + + @@ -77,6 +85,20 @@ name="TMF Tests" trace_type="org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub"> + + + + > expected = ImmutableSet.of((Class) TmfTraceStub.class, TmfTraceStub2.class, TmfTraceStub3.class); Iterable> traceTypes = fReqModule.getValidTraceTypes(); - for (Class traceType : traceTypes) { - assertTrue(fReqModule.appliesToTraceType(traceType)); - assertNotNull(traceTypeHelper); - assertEquals(traceTypeHelper.getTraceClass(), traceType); - traceTypeCount++; - } - assertEquals(1, traceTypeCount); + assertEquals(expected, traceTypes); } /** diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub2.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub2.java index 657f8558f8..30b19c5727 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub2.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub2.java @@ -22,6 +22,13 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; */ public class TmfTraceStub2 extends TmfTraceStub { + /** + * Default constructor + */ + public TmfTraceStub2() { + super(); + } + /** * Constructor to specify the parser and indexer. The streaming interval * will be 0. diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub3.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub3.java new file mode 100644 index 0000000000..c619eec29b --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub3.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2014 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Geneviève Bastien - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.tests.stubs.trace; + +/** + * Another stub trace class for unit tests who need more than one stub class. + * + * @author Geneviève Bastien + */ +public class TmfTraceStub3 extends TmfTraceStub { + + /** + * Default constructor + */ + public TmfTraceStub3() { + super(); + } + +} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java index 2912283d58..4b73977b35 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java @@ -106,9 +106,12 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp classApplies = Boolean.parseBoolean(classAppliesVal); } if (classApplies) { - applies = applyclass.isAssignableFrom(traceclass); + applies |= applyclass.isAssignableFrom(traceclass); } else { - applies = !applyclass.isAssignableFrom(traceclass); + /* If the trace type does not apply, reset the applies variable to false */ + if (applyclass.isAssignableFrom(traceclass)) { + applies = false; + } } } catch (ClassNotFoundException e) { Activator.logError("Error in applies to trace", e); //$NON-NLS-1$ @@ -139,6 +142,7 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp return module.getAnalysisRequirements(); } return Collections.EMPTY_SET; + } // --------------------------------------- @@ -197,5 +201,6 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp return ret; } return getHelpText(); + } }