public class BeanShellPostProcessor extends BeanShellTestElement implements Cloneable, PostProcessor, TestBean { private static final Logger log = LoggingManager.getLoggerForClass(); private static final long serialVersionUID = 4; // can be specified in jmeter.properties private static final String INIT_FILE = "beanshell.postprocessor.init"; //$NON-NLS-1$ protected String getInitFileProperty() { return INIT_FILE; } public void process() { JMeterContext jmctx = JMeterContextService.getContext(); SampleResult prev = jmctx.getPreviousResult(); final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (prev == null || bshInterpreter == null) { log.error("BeanShell not found"); return; } JMeterVariables vars = jmctx.getVariables(); try { // Add variables for access to context and variables bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$ bshInterpreter.set("vars", vars);//$NON-NLS-1$ bshInterpreter.set("prev", prev);//$NON-NLS-1$ bshInterpreter.set("data", prev.getResponseData());//$NON-NLS-1$ processFileOrScript(bshInterpreter); } catch (JMeterException e) { log.warn("Problem in BeanShell script "+e);
public class BeanShellPreProcessor extends BeanShellTestElement implements Cloneable, PreProcessor, TestBean { private static final Logger log = LoggingManager.getLoggerForClass(); private static final long serialVersionUID = 4; // can be specified in jmeter.properties private static final String INIT_FILE = "beanshell.preprocessor.init"; //$NON-NLS-1$ protected String getInitFileProperty() { return INIT_FILE; } public void process(){ final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (bshInterpreter == null) { log.error("BeanShell not found"); return; } JMeterContext jmctx = JMeterContextService.getContext(); JMeterVariables vars = jmctx.getVariables(); Sampler sam = jmctx.getCurrentSampler(); SampleResult prev = jmctx.getPreviousResult(); try { // Add variables for access to context and variables bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$ bshInterpreter.set("vars", vars);//$NON-NLS-1$ bshInterpreter.set("sampler", sam);//$NON-NLS-1$ bshInterpreter.set("prev", prev);//$NON-NLS-1$ processFileOrScript(bshInterpreter); } catch (JMeterException e) { log.warn("Problem in BeanShell script "+e);
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/extractor/BeanShellPostProcessor.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/modifiers/BeanShellPreProcessor.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class BeanShellPostProcessor extends BeanShellTestElement 
1
public class BeanShellPreProcessor extends BeanShellTestElement
2
    implements Cloneable, PostProcessor, TestBean
2
    implements Cloneable, PreProcessor, TestBean
3
{
3
{
4
    private static final Logger log = LoggingManager.getLoggerForClass();
4
    private static final Logger log = LoggingManager.getLoggerForClass();
5
    
5
    
6
    private static final long serialVersionUID = 4;
6
    private static final long serialVersionUID = 4;
7
    
7
    
8
    // can be specified in jmeter.properties
8
    // can be specified in jmeter.properties
9
    private static final String INIT_FILE = "beanshell.postprocessor.init"; //$NON-NLS-1$
9
    private static final String INIT_FILE = "beanshell.preprocessor.init"; //$NON-NLS-1$
10
    protected String getInitFileProperty() {
10
    protected String getInitFileProperty() {
11
        return INIT_FILE;
11
        return INIT_FILE;
12
    }
12
    }
13
    
14
     public void process() {
13
    public void process(){
15
        JMeterContext jmctx = JMeterContextService.getContext();
14
        
16
        SampleResult prev = jmctx.getPreviousResult();
17
		final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
15
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
18
		if (prev == null || bshInterpreter == null) {
16
		if (bshInterpreter == null) {
19
        	log.error("BeanShell not found");
17
        	log.error("BeanShell not found");
20
			return;
18
        	return;
21
		}
22
        JMeterVariables vars = jmctx.getVariables
19
        }
20
        JMeterContext jmctx = JMeterContextService.getContext();
21
        JMeterVariables vars = jmctx.getVariables();
22
		Sampler sam = jmctx.getCurrentSampler();
23
();
23
		SampleResult prev = jmctx.getPreviousResult();
24
        try {
24
        try {
25
            // Add variables for access to context and variables
25
            // Add variables for access to context and variables
26
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
26
            bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
27
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
27
            bshInterpreter.set("vars", vars);//$NON-NLS-1$
28
            bshInterpreter.set("prev", prev);//$NON-NLS-1$
28
            bshInterpreter.set("sampler", sam);//$NON-NLS-1$
29
            bshInterpreter.set("data", prev.getResponseData());//$NON-NLS-1$
29
            bshInterpreter.set("prev", prev);//$NON-NLS-1$
30
            
30
            processFileOrScript(bshInterpreter);
31
            processFileOrScript(bshInterpreter);
31
        } catch (JMeterException e) {
32
        } catch (JMeterException e) {
32
            log.warn("Problem in BeanShell script "+e);
33
            log.warn("Problem in BeanShell script "+e);
33
        
34
        
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0