checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody); // Test sending data as UTF-8, with values similar to __VIEWSTATE parameter that .net uses sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc="; descriptionValue = "mydescription"; setupUrl(sampler, contentEncoding); setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue); ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false); ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false); res = executeSampler(sampler); expectedPostBody = titleValue + descriptionValue; checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody); // Test sending data as UTF-8, with + as part of the value, // where the value is set in sampler as not urluencoded, but the // isalwaysencoded flag of the argument is set to false. // This mimics the HTTPSamplerBase.addNonEncodedArgument, which the // Proxy server calls in some cases sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "mytitle++"; descriptionValue = "mydescription+"; setupUrl(sampler, contentEncoding); setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody); // Test sending data as UTF-8, with values that have been urlencoded sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "mytitle%2F%3D"; descriptionValue = "mydescription+++%2F%5C"; setupUrl(sampler, contentEncoding); setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue); ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false); ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false); res = executeSampler(sampler); expectedPostBody = titleValue + descriptionValue; checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody); // Test sending data as UTF-8, with values that have been urlencoded, and // where we tell the sampler to urlencode the parameter values sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "mytitle%2F%3D"; descriptionValue = "mydescription+++%2F%5C"; setupUrl(sampler, contentEncoding); setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
Method name: void testPostRequest_BodyFromParameterValues(int, String) Method name: void testPostRequest_BodyFromParameterValues(int, String)
Number of AST nodes: 18 Number of AST nodes: 18
1
checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
1
checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
2
        // Test sending data as UTF-8, with values similar to __VIEWSTATE parameter that .net uses
2
        // Test sending data as UTF-8, with values that have been urlencoded
3
        sampler = createHttpSampler(samplerType);
3
        sampler = createHttpSampler(samplerType);
4
        contentEncoding = "UTF-8";
4
        contentEncoding = "UTF-8";
5
        titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
5
        titleValue = "mytitle%2F%3D";
6
        descriptionValue = "mydescription";
6
        descriptionValue = "mydescription+++%2F%5C";
7
        setupUrl(sampler, contentEncoding);
7
        setupUrl(sampler, contentEncoding);
8
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
8
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
9
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
9
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
10
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
10
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
11
        res = executeSampler(sampler);
11
        res = executeSampler(sampler);
12
        expectedPostBody = titleValue + descriptionValue;
12
        expectedPostBody = titleValue + descriptionValue;
13
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
13
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
14
        
15
        // Test sending data as UTF-8, with + as part of the value,
14
        // Test sending data as UTF-8, with 
16
        // where the value is set in sampler as not urluencoded, but the 
15
values that have been urlencoded, and
17
        // isalwaysencoded flag of the argument is set to false.
16
        // 
18
        // This mimics the HTTPSamplerBase.addNonEncodedArgument, which the
19
        // Proxy server calls in some cases
17
where we tell the sampler to urlencode the parameter values
20
        sampler = createHttpSampler(samplerType);
18
        sampler = createHttpSampler(samplerType);
21
        contentEncoding = "UTF-8";
19
        contentEncoding = "UTF-8";
22
        titleValue = "mytitle++";
20
        titleValue = "mytitle%2F%3D";
23
        descriptionValue = "mydescription+";
21
        descriptionValue = "mydescription+++%2F%5C";
24
        setupUrl(sampler, contentEncoding);
22
        setupUrl(sampler, contentEncoding);
25
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
23
        setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
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.0
Clones locationClones are in the same method
Number of node comparisons156
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                
    53
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
                                                                                          
    54
    sampler = createHttpSampler(samplerType);
                                                            
    55
    contentEncoding = "UTF-8";
    73
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    64
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    74
    sampler = createHttpSampler(samplerType);
    65
    sampler = createHttpSampler(samplerType);
    75
    contentEncoding = "UTF-8";
    66
    contentEncoding = "UTF-8";
    76
    titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
    76
    titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
    56
    titleValue = "mytitle%2F%3D";
    Differences
    Expression1Expression2Difference
    "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=""mytitle%2F%3D"LITERAL_VALUE_MISMATCH
    56
    titleValue = "mytitle%2F%3D";
    77
    descriptionValue = "mydescription";
    77
    descriptionValue = "mydescription";
    57
    descriptionValue = "mydescription+++%2F%5C";
    Differences
    Expression1Expression2Difference
    "mydescription""mydescription+++%2F%5C"LITERAL_VALUE_MISMATCH
    57
    descriptionValue = "mydescription+++%2F%5C";
                                                                                
    58
    setupUrl(sampler, contentEncoding);
    78
    setupUrl(sampler, contentEncoding);
    69
    setupUrl(sampler, contentEncoding);
    79
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    59
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    80
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    60
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    81
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    61
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    82
    res = executeSampler(sampler);
    62
    res = executeSampler(sampler);
    83
    expectedPostBody = titleValue + descriptionValue;
    63
    expectedPostBody = titleValue + descriptionValue;
    84
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    64
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    85
    sampler = createHttpSampler(samplerType);
    65
    sampler = createHttpSampler(samplerType);
    86
    contentEncoding = "UTF-8";
    66
    contentEncoding = "UTF-8";
    87
    titleValue = "mytitle++";
    87
    titleValue = "mytitle++";
    67
    titleValue = "mytitle%2F%3D";
    Differences
    Expression1Expression2Difference
    "mytitle++""mytitle%2F%3D"LITERAL_VALUE_MISMATCH
    67
    titleValue = "mytitle%2F%3D";
    88
    descriptionValue = "mydescription+";
    88
    descriptionValue = "mydescription+";
    68
    descriptionValue = "mydescription+++%2F%5C";
    Differences
    Expression1Expression2Difference
    "mydescription+""mydescription+++%2F%5C"LITERAL_VALUE_MISMATCH
    68
    descriptionValue = "mydescription+++%2F%5C";
    89
    setupUrl(sampler, contentEncoding);
    69
    setupUrl(sampler, contentEncoding);
    90
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    90
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    70
    setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
    Differences
    Expression1Expression2Difference
    falsetrueLITERAL_VALUE_MISMATCH
    70
    setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables sampler, titleValue, descriptionValue, contentEncoding , while Clone fragment #2 returns variables sampler, titleValue, descriptionValue, contentEncoding