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);
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);
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 that have been urlencoded
2
        // Test sending data as UTF-8
3
        sampler = createHttpSampler(samplerType);
3
        sampler = createHttpSampler(samplerType);
4
        contentEncoding = "UTF-8";
4
        contentEncoding = "UTF-8";
5
        titleValue = "mytitle%2F%3D";
5
        titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
6
        descriptionValue = "mydescription+++%2F%5C";
6
        descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
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
        // Test sending data as UTF-8, with values that have been urlencoded, and
14
        // Test sending data as UTF-8, with values that 
15
        // where we tell the sampler to urlencode the parameter values
15
will change when urlencoded
16
        sampler = createHttpSampler(samplerType);
16
        sampler = createHttpSampler(samplerType);
17
        contentEncoding = "UTF-8";
17
        contentEncoding = "UTF-8";
18
        titleValue = "mytitle%2F%3D";
18
        titleValue = "mytitle/=";
19
        descriptionValue = "mydescription+++%2F%5C";
19
        descriptionValue = "mydescription   /\\";
20
        setupUrl(sampler, contentEncoding);
20
        setupUrl(sampler, contentEncoding);
21
        setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
21
        setupFormData(sampler, false, 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 comparisons116
  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 fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    53
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    22
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    54
    sampler = createHttpSampler(samplerType);
    23
    sampler = createHttpSampler(samplerType);
    55
    contentEncoding = "UTF-8";
    24
    contentEncoding = "UTF-8";
    56
    titleValue = "mytitle%2F%3D";
    56
    titleValue = "mytitle%2F%3D";
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    Differences
    Expression1Expression2Difference
    "mytitle%2F%3D""mytitle\u0153\u20a1\u0115\u00c5"LITERAL_VALUE_MISMATCH
    25
    titleValue = "mytitle\u0153\u20a1\u0115\u00c5";
    57
    descriptionValue = "mydescription+++%2F%5C";
    57
    descriptionValue = "mydescription+++%2F%5C";
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    Differences
    Expression1Expression2Difference
    "mydescription+++%2F%5C""mydescription\u0153\u20a1\u0115\u00c5"LITERAL_VALUE_MISMATCH
    26
    descriptionValue = "mydescription\u0153\u20a1\u0115\u00c5";
    58
    setupUrl(sampler, contentEncoding);
    27
    setupUrl(sampler, contentEncoding);
    59
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    28
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    60
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    29
    ((HTTPArgument)sampler.getArguments().getArgument(0)).setAlwaysEncoded(false);
    61
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    30
    ((HTTPArgument)sampler.getArguments().getArgument(1)).setAlwaysEncoded(false);
    62
    res = executeSampler(sampler);
    31
    res = executeSampler(sampler);
    63
    expectedPostBody = titleValue + descriptionValue;
    32
    expectedPostBody = titleValue + descriptionValue;
    64
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    33
    checkPostRequestBody(sampler, res, samplerDefaultEncoding, contentEncoding, expectedPostBody);
    65
    sampler = createHttpSampler(samplerType);
    34
    sampler = createHttpSampler(samplerType);
    66
    contentEncoding = "UTF-8";
    35
    contentEncoding = "UTF-8";
    67
    titleValue = "mytitle%2F%3D";
    67
    titleValue = "mytitle%2F%3D";
    36
    titleValue = "mytitle/=";
    Differences
    Expression1Expression2Difference
    "mytitle%2F%3D""mytitle/="LITERAL_VALUE_MISMATCH
    36
    titleValue = "mytitle/=";
    68
    descriptionValue = "mydescription+++%2F%5C";
    68
    descriptionValue = "mydescription+++%2F%5C";
    37
    descriptionValue = "mydescription /\\";
    Differences
    Expression1Expression2Difference
    "mydescription+++%2F%5C""mydescription /\\"LITERAL_VALUE_MISMATCH
    37
    descriptionValue = "mydescription   /\\";
    69
    setupUrl(sampler, contentEncoding);
    38
    setupUrl(sampler, contentEncoding);
    70
    setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
    70
    setupFormData(sampler, true, titleField, titleValue, descriptionField, descriptionValue);
    39
    setupFormData(sampler, false, titleField, titleValue, descriptionField, descriptionValue);
    Differences
    Expression1Expression2Difference
    truefalseLITERAL_VALUE_MISMATCH
    39
    setupFormData(sampler, false, 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