res = executeSampler(sampler); expectedPostBody = titleValue + descriptionValue; 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); ((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);
res = executeSampler(sampler); expectedPostBody = titleValue + descriptionValue; checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody); // Test sending data as UTF-8 sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "mytitle\u0153\u20a1\u0115\u00c5"; descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5"; 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 will change when urlencoded sampler = createHttpSampler(samplerType); contentEncoding = "UTF-8"; titleValue = "mytitle/="; 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);
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: 25 Number of AST nodes: 25
1
res = executeSampler(sampler);
1
res = executeSampler(sampler);
2
        expectedPostBody = titleValue + descriptionValue;
2
        expectedPostBody = titleValue + descriptionValue;
3
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
3
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
4
        // Test sending data as UTF-8, with values similar to __VIEWSTATE parameter that .net uses
4
        // Test sending data as UTF-8
5
        sampler = createHttpSampler(samplerType);
5
        sampler = createHttpSampler(samplerType);
6
        contentEncoding = "UTF-8";
6
        contentEncoding = "UTF-8";
7
        titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
7
        titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
8
        descriptionValue = "mydescription";
8
        descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
9
        setupUrl(sampler, contentEncoding);
9
        setupUrl(sampler, contentEncoding);
10
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
10
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
11
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
11
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
12
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
12
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
13
        res = executeSampler(sampler);
13
        res = executeSampler(sampler);
14
        expectedPostBody = titleValue + descriptionValue;
14
        expectedPostBody = titleValue + descriptionValue;
15
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
15
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
16
        
17
        // Test sending data as UTF-8, with + as part of the value,
16
        // Test sending data as UTF-8, with 
18
        // where the value is set in sampler as not urluencoded, but the 
19
        // isalwaysencoded flag of the argument is set to false.
20
        // This mimics the HTTPSamplerBase.addNonEncodedArgument, which the
21
        // Proxy server calls in some cases
17
values that will change when urlencoded
22
        sampler = createHttpSampler(samplerType);
18
        sampler = createHttpSampler(samplerType);
23
        contentEncoding = "UTF-8";
19
        contentEncoding = "UTF-8";
24
        titleValue = "mytitle++";
20
        titleValue = "mytitle/=";
25
        descriptionValue = "mydescription+";
21
        descriptionValue = "mydescription   /\\";
26
        setupUrl(sampler, contentEncoding);
22
        setupUrl(sampler, contentEncoding);
27
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
23
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
28
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
24
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
29
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
25
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
30
        res = executeSampler(sampler);
26
        res = executeSampler(sampler);
31
        expectedPostBody = titleValue + descriptionValue;
27
        expectedPostBody = titleValue + descriptionValue;
32
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
28
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
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 comparisons115
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements25
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment12
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                    
    20
    res = executeSampler(sampler);
                                                                                                          
    21
    expectedPostBody = titleValue + descriptionValue;
                                                                                                                                                                                                
    22
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
                                                                                          
    23
    sampler = createHttpSampler(samplerType);
                                                            
    24
    contentEncoding = "UTF-8";
                                                                                
    27
    setupUrl(sampler, contentEncoding);
                                                                                                                                                                                      
    28
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    Preondition Violations
    Unmatched statement setupFormData(sampler,false,titleField,titleValue,descriptionField,descriptionValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    28
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
                                                                                                                                                                        
    29
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
                                                                                                                                                                        
    30
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
                                                                    
    31
    res = executeSampler(sampler);
                                                                                                          
    32
    expectedPostBody = titleValue + descriptionValue;
    Preondition Violations
    Unmatched statement expectedPostBody=titleValue + descriptionValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    32
    expectedPostBody = titleValue + descriptionValue;
                                                                                                                                                                                                
    33
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    71
    res = executeSampler(sampler);
    42
    res = executeSampler(sampler);
    72
    expectedPostBody = titleValue + descriptionValue;
    43
    expectedPostBody = titleValue + descriptionValue;
    73
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    44
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    74
    sampler = createHttpSampler(samplerType);
    34
    sampler = createHttpSampler(samplerType);
    75
    contentEncoding = "UTF-8";
    35
    contentEncoding = "UTF-8";
    76
    titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
    76
    titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    Differences
    Expression1Expression2Difference
    "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=""mytitle\u0153\u20a1\u0115\u00c5"LITERAL_VALUE_MISMATCH
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    77
    descriptionValue = "mydescription";
    77
    descriptionValue = "mydescription";
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    Differences
    Expression1Expression2Difference
    "mydescription""mydescription\u0153\u20a1\u0115\u00c5"LITERAL_VALUE_MISMATCH
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    78
    setupUrl(sampler, contentEncoding);
    38
    setupUrl(sampler, contentEncoding);
    79
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    39
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    80
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    40
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    81
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    41
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    82
    res = executeSampler(sampler);
    42
    res = executeSampler(sampler);
    83
    expectedPostBody = titleValue + descriptionValue;
    43
    expectedPostBody = titleValue + descriptionValue;
    84
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    44
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    85
    sampler = createHttpSampler(samplerType);
    34
    sampler = createHttpSampler(samplerType);
    86
    contentEncoding = "UTF-8";
    35
    contentEncoding = "UTF-8";
    87
    titleValue = "mytitle++";
    87
    titleValue = "mytitle++";
    36
    titleValue = "mytitle/=";
    Differences
    Expression1Expression2Difference
    "mytitle++""mytitle/="LITERAL_VALUE_MISMATCH
    36
    titleValue = "mytitle/=";
    88
    descriptionValue = "mydescription+";
    88
    descriptionValue = "mydescription+";
    37
    descriptionValue = "mydescription /\\";
    Differences
    Expression1Expression2Difference
    "mydescription+""mydescription /\\"LITERAL_VALUE_MISMATCH
    37
    descriptionValue = "mydescription   /\\";
    89
    setupUrl(sampler, contentEncoding);
    38
    setupUrl(sampler, contentEncoding);
    90
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    39
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    91
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    40
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    92
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    41
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    93
    res = executeSampler(sampler);
    42
    res = executeSampler(sampler);
    94
    expectedPostBody = titleValue + descriptionValue;
    43
    expectedPostBody = titleValue + descriptionValue;
    95
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    44
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    Precondition Violations (3)
    Row Violation
    1Unmatched statement setupFormData(sampler,false,titleField,titleValue,descriptionField,descriptionValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement expectedPostBody=titleValue + descriptionValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables , while Clone fragment #2 returns variables titleValue, descriptionValue