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/visualizers/BeanShellListener.java | |||
Method name: void process()
|
Method name: void sampleOccurred(SampleEvent)
|
|||
Number of AST nodes: 13 | Number of AST nodes: 13 | |||
1 | JMeterContext jmctx = JMeterContextService.getContext();↵ | |||
2 | SampleResult prev = jmctx.getPreviousResult();↵ | |||
3 | final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();↵ | 1 | final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();↵ | |
4 | if (prev == null || bshInterpreter == null) {↵ | 2 | if (bshInterpreter == null) {↵ | |
5 | log.error("BeanShell not found");↵ | 3 | log.error("BeanShell not found");↵ | |
6 | return;↵ | |||
7 | }↵ | |||
4 | return;↵ | |||
5 | }↵ | |||
6 | ↵ | |||
7 | JMeterContext jmctx = JMeterContextService.getContext();↵ | |||
8 | JMeterVariables vars = jmctx.getVariables();↵ | 8 | JMeterVariables vars = jmctx.getVariables();↵ | |
9 | SampleResult samp=se.getResult();↵ | |||
9 | try {↵ | 10 | try {↵ | |
10 | // Add variables for access to context and variables↵ | 11 | // Add variables for access to context and variables↵ | |
11 | bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$↵ | 12 | bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$↵ | |
12 | bshInterpreter.set("vars", vars);//$NON-NLS-1$↵ | 13 | bshInterpreter.set("vars", vars);//$NON-NLS-1$↵ | |
13 | bshInterpreter.set("prev", prev);//$NON-NLS-1$↵ | 14 | bshInterpreter.set("sampleEvent", se);//$NON-NLS-1$↵ | |
14 | bshInterpreter.set("data", prev.getResponseData());//$NON-NLS-1$↵ | 15 | bshInterpreter.set("sampleResult", samp);//$NON-NLS-1$↵ | |
15 | processFileOrScript(bshInterpreter);↵ | 16 | processFileOrScript(bshInterpreter);↵ | |
16 | } catch (JMeterException e) {↵ | 17 | } catch (JMeterException e) {↵ | |
17 | log.warn("Problem in BeanShell script "+e);↵ | 18 | log.warn("Problem in BeanShell script "+e);↵ | |
18 | } | 19 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 55 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 3.2 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | if (bshInterpreter == null) | |||||||||||||||
| 3 | log.error("BeanShell not found"); | |||||||||||||||
|
| 4 | return; | ||||||||||||||
1 | JMeterContext jmctx = JMeterContextService.getContext(); | 5 | JMeterContext jmctx = JMeterContextService.getContext(); | ||||||||||||||
2 | SampleResult prev = jmctx.getPreviousResult(); |
| | ||||||||||||||
3 | final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); | 1 | final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); | ||||||||||||||
4 | if (prev == null || bshInterpreter == null) | | |||||||||||||||
5 | log.error("BeanShell not found"); | | |||||||||||||||
6 | return; |
| | ||||||||||||||
7 | JMeterVariables vars = jmctx.getVariables(); | 6 | JMeterVariables vars = jmctx.getVariables(); | ||||||||||||||
| 7 | SampleResult samp = se.getResult(); | |||||||||||||||
8 | try | 8 | try | ||||||||||||||
9 | bshInterpreter.set("ctx", jmctx); | 9 | bshInterpreter.set("ctx", jmctx); | ||||||||||||||
10 | bshInterpreter.set("vars", vars); | 10 | bshInterpreter.set("vars", vars); | ||||||||||||||
|
| 11 | bshInterpreter.set("sampleEvent", se); | ||||||||||||||
11 | bshInterpreter.set("prev", prev); |
| 12 | bshInterpreter.set("sampleResult", samp); | |||||||||||||
12 | bshInterpreter.set("data", prev.getResponseData()); |
| | ||||||||||||||
13 | processFileOrScript(bshInterpreter); | 13 | processFileOrScript(bshInterpreter); |
Row | Violation |
---|---|
1 | Unmatched return; |
2 | Unmatched statement SampleResult prev=jmctx.getPreviousResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched return; |
4 | Unmatched statement bshInterpreter.set("sampleEvent",se); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
5 | Unmatched statement bshInterpreter.set("data",prev.getResponseData()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
6 | Clone fragment #1 returns variables jmctx, bshInterpreter , while Clone fragment #2 returns variables bshInterpreter |