File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java | File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java | |||
Method name: void addAnchorUrls(Document, HTTPSampleResult, HTTPSamplerBase, List)
|
Method name: void addFramesetUrls(Document, HTTPSampleResult, HTTPSamplerBase, List)
|
|||
Number of AST nodes: 22 | Number of AST nodes: 20 | |||
1 | String base = "";↵ | 1 | String base = "";↵ | |
2 | NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$↵ | 2 | NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$↵ | |
3 | if (baseList.getLength() > 0) {↵ | 3 | if (baseList.getLength() > 0) {↵ | |
4 | base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); // $NON-NLS-1$↵ | 4 | base = baseList.item(0).getAttributes().getNamedItem("href")↵ | |
5 | }↵ | |||
6 | ↵ | 5 | // $NON-NLS-1$↵ | |
6 | .getNodeValue();↵ | |||
7 | }↵ | |||
7 | NodeList nodeList = html.getElementsByTagName("a"); // $NON-NLS-1$↵ | 8 | NodeList nodeList = html.getElementsByTagName("frame"); // $NON-NLS-1$↵ | |
8 | for (int i = 0; i < nodeList.getLength(); i++) {↵ | 9 | for (int i = 0; i < nodeList.getLength(); i++) {↵ | |
9 | Node tempNode = nodeList.item(i);↵ | 10 | Node tempNode = nodeList.item(i);↵ | |
10 | NamedNodeMap nnm = tempNode.getAttributes();↵ | 11 | NamedNodeMap nnm = tempNode.getAttributes();↵ | |
11 | Node namedItem = nnm.getNamedItem("href"); // $NON-NLS-1$↵ | 12 | Node namedItem = nnm.getNamedItem("src"); // $NON-NLS-1$↵ | |
12 | if (namedItem == null) {↵ | 13 | if (namedItem == null) {↵ | |
13 | continue;↵ | |||
14 | }↵ | |||
15 | String hrefStr = namedItem.getNodeValue();↵ | |||
16 | if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$↵ | |||
17 | continue; // No point trying these↵ | |||
18 | }↵ | |||
19 | try {↵ | |||
20 | ↵ | 14 | continue;↵ | |
15 | }↵ | |||
16 | String hrefStr = namedItem.getNodeValue();↵ | |||
17 | try {↵ | |||
21 | HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(↵ | 18 | HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(↵ | |
22 | hrefStr, new URL(result.getURL(), base));↵ | 19 | hrefStr, new URL(result.getURL(), base));↵ | |
23 | newUrl.setMethod(HTTPConstants.GET);↵ | 20 | newUrl.setMethod(HTTPConstants.GET);↵ | |
24 | if (log.isDebugEnabled()) {↵ | 21 | if (log.isDebugEnabled()) {↵ | |
25 | log.debug("Potential <a href> match: " + newUrl);↵ | 22 | log.debug("Potential <frame src> match: " + newUrl);↵ | |
26 | }↵ | |||
27 | ↵ | 23 | }↵ | |
28 | if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {↵ | 24 | if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {↵ | |
29 | log.debug("Matched!");↵ | 25 | log.debug("Matched!");↵ | |
30 | potentialLinks.add(newUrl);↵ | 26 | potentialLinks.add(newUrl);↵ | |
31 | }↵ | |||
32 | ↵ | 27 | }↵ | |
33 | } catch (MalformedURLException e) {↵ | 28 | } catch (MalformedURLException e) {↵ | |
34 | log.warn("Bad URL "+e);↵ | 29 | log.warn("Bad URL "+e);↵ | |
35 | }↵ | |||
36 | ↵ | 30 | }↵ | |
37 | } | 31 | } | |
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) | 1.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 72 |
Number of mapped statements | 20 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 6.6 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | String base = ""; | 1 | String base = ""; | |||||||||||
2 | NodeList baseList = html.getElementsByTagName("base"); | 2 | NodeList baseList = html.getElementsByTagName("base"); | |||||||||||
3 | if (baseList.getLength() > 0) | 3 | if (baseList.getLength() > 0) | |||||||||||
4 | base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); | 4 | base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); | |||||||||||
5 | NodeList nodeList = html.getElementsByTagName("a"); |
| 5 | NodeList nodeList = html.getElementsByTagName("frame"); | ||||||||||
6 | for (int i = 0; i < nodeList.getLength(); i++) | 6 | for (int i = 0; i < nodeList.getLength(); i++) | |||||||||||
7 | Node tempNode = nodeList.item(i); | 7 | Node tempNode = nodeList.item(i); | |||||||||||
8 | NamedNodeMap nnm = tempNode.getAttributes(); | 8 | NamedNodeMap nnm = tempNode.getAttributes(); | |||||||||||
9 | Node namedItem = nnm.getNamedItem("href"); |
| 9 | Node namedItem = nnm.getNamedItem("src"); | ||||||||||
10 | if (namedItem == null) | 10 | if (namedItem == null) | |||||||||||
11 | continue; | 11 | continue; | |||||||||||
12 | String hrefStr = namedItem.getNodeValue(); | 12 | String hrefStr = namedItem.getNodeValue(); | |||||||||||
13 | if (hrefStr.startsWith("javascript:")) |
| | |||||||||||
14 | continue; |
| | |||||||||||
15 | try | 13 | try | |||||||||||
16 | HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base)); | 14 | HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base)); | |||||||||||
17 | newUrl.setMethod(HTTPConstants.GET); | 15 | newUrl.setMethod(HTTPConstants.GET); | |||||||||||
18 | if (log.isDebugEnabled()) | 16 | if (log.isDebugEnabled()) | |||||||||||
19 | log.debug("Potential <a href> match: " + newUrl); |
| 17 | log.debug("Potential <frame src> match: " + newUrl); | ||||||||||
20 | if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) | 18 | if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) | |||||||||||
21 | log.debug("Matched!"); | 19 | log.debug("Matched!"); | |||||||||||
22 | potentialLinks.add(newUrl); | 20 | potentialLinks.add(newUrl); |
Row | Violation |
---|---|
1 | Unmatched statement if(hrefStr.startsWith("javascript:")) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched continue; |
3 | Clone fragment #1 returns variables hrefStr , while Clone fragment #2 returns variables |