Perl5Matcher localMatcher = JMeterUtils.getMatcher(); // We use multi-line mask so can prefix the line with ^ // also match \w+ to catch Transfer-Encoding: chunked // TODO: may need to be extended to allow for other header values with non-word contents String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$ Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); if(localMatcher.contains(requestHeaders, pattern)) { // The value is in the first group, group 0 is the whole match return localMatcher.getMatch().group(1); } else { return null; }
Perl5Matcher localMatcher = JMeterUtils.getMatcher(); String regularExpression = "^" + HTTPSamplerBase.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$"; Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK); if(localMatcher.contains(requestHeaders, pattern)) { MatchResult match = localMatcher.getMatch(); return match.group(1); } else { return null; }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
Method name: String getRequestHeaderValue(String, String) Method name: String getBoundaryStringFromContentType(String)
Number of AST nodes: 6 Number of AST nodes: 7
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
1
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
2
        // We use multi-line mask so can prefix the line with ^
2
        
3
        // also match \w+ to catch Transfer-Encoding: chunked
4
        // TODO: may need to be extended to allow for other header values with non-word contents
5
        String expression = "^" + headerName + ":\\s+(\\w+)"; // $NON-NLS-1$ $NON-NLS-2$        
3
String regularExpression = "^" + HTTPSamplerBase.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$"; 
6
        Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
4
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
7
        if(localMatcher.contains(requestHeaders, pattern)) {
5
        if(localMatcher.contains(requestHeaders, pattern)) {
8
            // The value is in the first group, group 0 is the whole match
6
            MatchResult match = localMatcher.getMatch();
9
            return localMatcher.getMatch().group(1);
7
            return match.group(1);
10
        }
8
        }
11
        else {
9
        else {
12
            return null;
10
            return null;
13
        }
11
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes
Number of node comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    1
    Perl5Matcher localMatcher = JMeterUtils.getMatcher();
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    2
    String expression = "^" + headerName + ":\\s+(\\w+)";
    2
    String regularExpression = "^" + HTTPSamplerBase.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$";
    Differences
    Expression1Expression2Difference
    expressionregularExpressionVARIABLE_NAME_MISMATCH
    ":\\s+(\\w+)"": multipart/form-data; boundary=(.+)$"LITERAL_VALUE_MISMATCH
    headerNameHTTPSamplerBase.HEADER_CONTENT_TYPETYPE_COMPATIBLE_REPLACEMENT
    2
    String regularExpression = "^" + HTTPSamplerBase.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$";
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    3
    Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    Differences
    Expression1Expression2Difference
    expressionregularExpressionVARIABLE_NAME_MISMATCH
    3
    Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
    4
    if (localMatcher.contains(requestHeaders, pattern))
    4
    if (localMatcher.contains(requestHeaders, pattern))
                                                                                              
    5
    MatchResult match = localMatcher.getMatch();
    Preondition Violations
    Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    MatchResult match = localMatcher.getMatch();
    5
    return localMatcher.getMatch().group(1);
    5
    return localMatcher.getMatch().group(1);
    6
    return match.group(1);
    Differences
    Expression1Expression2Difference
    localMatcher.getMatch()matchTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression localMatcher.getMatch() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    return match.group(1);
    else
    else
    6
    return null;
    7
    return null;
    Precondition Violations (3)
    Row Violation
    1Unmatched statement MatchResult match=localMatcher.getMatch(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression localMatcher.getMatch() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables , while Clone fragment #2 returns variables localMatcher