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 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);
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);
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
setupUrl(sampler, contentEncoding);
1
setupUrl(sampler, contentEncoding);
2
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
2
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
3
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
3
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
4
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
4
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
5
        res = executeSampler(sampler);
5
        res = executeSampler(sampler);
6
        expectedPostBody = titleValue + descriptionValue;
6
        expectedPostBody = titleValue + descriptionValue;
7
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
7
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
8
        
8
        // Test sending data as UTF-8
9
        // Test sending data as UTF-8, with + as part of the value,
10
        // where the value is set in sampler as not urluencoded, but the 
11
        // isalwaysencoded flag of the argument is set to false.
12
        // This mimics the HTTPSamplerBase.addNonEncodedArgument, which the
13
        // Proxy server calls in some cases
9
        sampler = createHttpSampler(samplerType);
14
        sampler = createHttpSampler(samplerType);
10
        contentEncoding = "UTF-8";
15
        contentEncoding = "UTF-8";
11
        titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
16
        titleValue = "mytitle++";
12
        descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
17
        descriptionValue = "mydescription+";
13
        setupUrl(sampler, contentEncoding);
18
        setupUrl(sampler, contentEncoding);
14
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
19
        setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
15
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
20
        ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
16
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
21
        ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
17
        res = executeSampler(sampler);
22
        res = executeSampler(sampler);
18
        expectedPostBody = titleValue + descriptionValue;
23
        expectedPostBody = titleValue + descriptionValue;
19
        checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
24
        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 comparisons44
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    16
    setupUrl(sampler, contentEncoding);
    78
    setupUrl(sampler, contentEncoding);
    17
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    79
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    18
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    80
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    19
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    81
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    20
    res = executeSampler(sampler);
    82
    res = executeSampler(sampler);
    21
    expectedPostBody = titleValue + descriptionValue;
    83
    expectedPostBody = titleValue + descriptionValue;
    22
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    84
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    23
    sampler = createHttpSampler(samplerType);
    85
    sampler = createHttpSampler(samplerType);
    24
    contentEncoding = "UTF-8";
    86
    contentEncoding = "UTF-8";
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    87
    titleValue = "mytitle++";
    Differences
    Expression1Expression2Difference
    "mytitle\u0153\u20a1\u0115\u00c5""mytitle++"LITERAL_VALUE_MISMATCH
    87
    titleValue = "mytitle++";
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    88
    descriptionValue = "mydescription+";
    Differences
    Expression1Expression2Difference
    "mydescription\u0153\u20a1\u0115\u00c5""mydescription+"LITERAL_VALUE_MISMATCH
    88
    descriptionValue = "mydescription+";
    27
    setupUrl(sampler, contentEncoding);
    89
    setupUrl(sampler, contentEncoding);
    28
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    90
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    29
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    91
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    30
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    92
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    31
    res = executeSampler(sampler);
    93
    res = executeSampler(sampler);
    32
    expectedPostBody = titleValue + descriptionValue;
    94
    expectedPostBody = titleValue + descriptionValue;
    33
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    95
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    Precondition Violations (0)
    Row Violation