@@ -0,0 +1,3524 @@
+package net.ssehub.kernel_haven.test_utils;%0A%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Properties;%0A%0Aimport net.ssehub.kernel_haven.SetUpException;%0Aimport net.ssehub.kernel_haven.analysis.AnalysisComponent;%0Aimport net.ssehub.kernel_haven.config.Configuration;%0A%0A/**%0A * Contains a helper method to execute analysis components.%0A * %0A * @author Adam%0A */%0Apublic class AnalysisComponentExecuter %7B%0A%0A    /**%0A     * Don't allow any instances.%0A     */%0A    private AnalysisComponentExecuter() %7B%0A    %7D%0A%0A    /**%0A     * Creates and executes the given %7B@link AnalysisComponent%7D class.%0A     * %0A     * @param componentClass The component class to create and execute.%0A     * @param config The %7B@link Configuration%7D for the component. %3Ccode%3Enull%3C/code%3E if no special settings are needed.%0A     * @param inputs The input values for the component. The first dimension represent the different%0A     *      %7B@link AnalysisComponent%7D inputs; the second dimension represent that values that each input component%0A     *      should create.%0A     *      %0A     * @param %3CT%3E The output type of the analysis component.%0A     *      %0A     * @return The list of results that the component created.%0A     */%0A    public static %3CT%3E List%3CT%3E executeComponent(Class%3C?%3E componentClass, Configuration config, Object%5B%5D... inputs) %7B%0A        %0A        // create an empty configuration is none is passed to us%0A        if (config == null) %7B%0A            try %7B%0A                config = new TestConfiguration(new Properties());%0A            %7D catch (SetUpException e) %7B%0A                throw new RuntimeException(%22Can't create test configuration%22, e);%0A            %7D%0A        %7D%0A        %0A        // create input components based on the inputs parameter%0A        AnalysisComponent%3C?%3E%5B%5D inputComponents = new AnalysisComponent%5Binputs.length%5D;%0A        for (int i = 0; i %3C inputs.length; i++) %7B%0A            try %7B%0A                inputComponents%5Bi%5D = new TestAnalysisComponentProvider%3C%3E(inputs%5Bi%5D);%0A            %7D catch (SetUpException e) %7B%0A                throw new RuntimeException(%22Can't create test input component%22, e);%0A            %7D%0A        %7D%0A        %0A        // create an array with the parameter types, to get the right constructor%0A        Class%3C?%3E%5B%5D parameterTypes = new Class%5B1 + inputComponents.length%5D;%0A        parameterTypes%5B0%5D = Configuration.class;%0A        for (int i = 0; i %3C inputComponents.length; i++) %7B%0A            parameterTypes%5Bi + 1%5D = AnalysisComponent.class;%0A        %7D%0A        %0A        // create an array with the parameter values, to pass to the consturctor%0A        Object%5B%5D parameterValues = new Object%5B1 + inputComponents.length%5D;%0A        parameterValues%5B0%5D = config;%0A        for (int i = 0; i %3C inputComponents.length; i++) %7B%0A            parameterValues%5Bi + 1%5D = inputComponents%5Bi%5D;%0A        %7D%0A        %0A        List%3CT%3E result = new LinkedList%3C%3E();%0A        %0A        try %7B%0A            // instantiate the component%0A            @SuppressWarnings(%22unchecked%22)%0A            AnalysisComponent%3CT%3E component = (AnalysisComponent%3CT%3E)%0A                    componentClass.getConstructor(parameterTypes).newInstance(parameterValues);%0A            %0A            // execute the component%0A            T r;%0A            while ((r = component.getNextResult()) != null) %7B%0A                result.add(r);%0A            %7D%0A            %0A        %7D catch (ReflectiveOperationException %7C ClassCastException %7C SecurityException e) %7B%0A            throw new RuntimeException(%22Can't instantiate analysis component%22, e);%0A        %7D%0A        %0A        return result;%0A    %7D%0A    %0A%7D%0A

Create helper method for testing analysis components