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);
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);
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: 12 Number of AST nodes: 12
1
checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
1
checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
2
        
3
        // Test sending data as UTF-8, with + as part of the value,
2
        // Test sending data as UTF-8, with 
4
        // where the value is set in sampler as not urluencoded, but the 
5
        // isalwaysencoded flag of the argument is set to false.
6
        // This mimics the HTTPSamplerBase.addNonEncodedArgument, which the
7
        // Proxy server calls in some cases
3
values that have been urlencoded
8
        sampler = createHttpSampler(samplerType);
4
        sampler = createHttpSampler(samplerType);
9
        contentEncoding = "UTF-8";
5
        contentEncoding = "UTF-8";
10
        titleValue = "mytitle++";
6
        titleValue = "mytitle%2F%3D";
11
        descriptionValue = "mydescription+";
7
        descriptionValue = "mydescription+++%2F%5C";
12
        setupUrl(sampler, contentEncoding);
8
        setupUrl(sampler, contentEncoding);
13
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
9
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
14
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
10
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
15
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
11
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
16
        res = executeSampler(sampler);
12
        res = executeSampler(sampler);
17
        expectedPostBody = titleValue + descriptionValue;
13
        expectedPostBody = titleValue + descriptionValue;
18
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
14
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in the same method
Number of node comparisons114
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                
    53
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    84
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    64
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    85
    sampler = createHttpSampler(samplerType);
    54
    sampler = createHttpSampler(samplerType);
    86
    contentEncoding = "UTF-8";
    55
    contentEncoding = "UTF-8";
    87
    titleValue = "mytitle++";
    87
    titleValue = "mytitle++";
    56
    titleValue = "mytitle%2F%3D";
    Differences
    Expression1Expression2Difference
    "mytitle++""mytitle%2F%3D"LITERAL_VALUE_MISMATCH
    56
    titleValue = "mytitle%2F%3D";
    88
    descriptionValue = "mydescription+";
    88
    descriptionValue = "mydescription+";
    57
    descriptionValue = "mydescription+++%2F%5C";
    Differences
    Expression1Expression2Difference
    "mydescription+""mydescription+++%2F%5C"LITERAL_VALUE_MISMATCH
    57
    descriptionValue = "mydescription+++%2F%5C";
    89
    setupUrl(sampler, contentEncoding);
    58
    setupUrl(sampler, contentEncoding);
    90
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    59
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    91
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    60
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    92
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    61
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    93
    res = executeSampler(sampler);
    62
    res = executeSampler(sampler);
    94
    expectedPostBody = titleValue + descriptionValue;
    63
    expectedPostBody = titleValue + descriptionValue;
    95
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    64
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    Precondition Violations (0)
    Row Violation