outputStream.write(secondChunk); // Read the response response = new ByteArrayOutputStream(); buffer = new byte[1024]; length = 0; while((length = inputStream.read(buffer)) != -1) { response.write(buffer, 0, length); } response.close(); mirroredResponse = getMirroredResponse(response.toByteArray()); // The content sent bos = new ByteArrayOutputStream(); bos.write(firstChunk); bos.write(secondChunk); bos.close(); // Check that the request and response matches checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); // Close the connection clientSocket.close();
outputStream.write(secondChunk); // Read the response response = new ByteArrayOutputStream(); buffer = new byte[1024]; length = 0; while((length = inputStream.read(buffer)) != -1) { response.write(buffer, 0, length); } response.close(); mirroredResponse = getMirroredResponse(response.toByteArray()); // The content sent bos = new ByteArrayOutputStream(); bos.write(firstChunk); bos.write(secondChunk); bos.close(); // Check that the request and response matches checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); // Close the connection clientSocket.close();
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java File path: /jakarta-jmeter-2.3.2/test/src/org/apache/jmeter/protocol/http/control/TestHTTPMirrorThread.java
Method name: void testGetRequest() Method name: void testPostRequest()
Number of AST nodes: 14 Number of AST nodes: 14
1
outputStream.write(secondChunk);
1
outputStream.write(secondChunk);
2
        // Read the response
2
        // Read the response
3
        response = new ByteArrayOutputStream();        
3
        response = new ByteArrayOutputStream();        
4
        buffer = new byte[1024];
4
        buffer = new byte[1024];
5
        length = 0;
5
        length = 0;
6
        while((length = inputStream.read(buffer)) != -1) {
6
        while((length = inputStream.read(buffer)) != -1) {
7
        	response.write(buffer, 0, length);
7
        	response.write(buffer, 0, length);
8
        }
8
        }
9
        response.close();
9
        response.close();
10
        mirroredResponse = getMirroredResponse(response.toByteArray());
10
        mirroredResponse = getMirroredResponse(response.toByteArray());
11
        // The content sent
11
        // The content sent
12
        bos = new ByteArrayOutputStream();
12
        bos = new ByteArrayOutputStream();
13
        bos.write(firstChunk);
13
        bos.write(firstChunk);
14
        bos.write(secondChunk);
14
        bos.write(secondChunk);
15
        bos.close();        
15
        bos.close();        
16
        // Check that the request and response matches
16
        // Check that the request and response matches
17
        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
17
        checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
18
        // Close the connection
18
        // Close the connection
19
        clientSocket.close();
19
        clientSocket.close();
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.2
Clones locationClones are declared in the same class
Number of node comparisons151
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)16.3
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    37
    outputStream.write(secondChunk);
    49
    outputStream.write(secondChunk);
    38
    response = new ByteArrayOutputStream();
    50
    response = new ByteArrayOutputStream();
    39
    buffer = new byte[1024];
    51
    buffer = new byte[1024];
    40
    length = 0;
    52
    length = 0;
    41
    while ((length = inputStream.read(buffer)) != -1)
    53
    while ((length = inputStream.read(buffer)) != -1)
    42
    response.write(buffer, 0, length);
    54
    response.write(buffer, 0, length);
    43
    response.close();
    55
    response.close();
    44
    mirroredResponse = getMirroredResponse(response.toByteArray());
    56
    mirroredResponse = getMirroredResponse(response.toByteArray());
    45
    bos = new ByteArrayOutputStream();
    57
    bos = new ByteArrayOutputStream();
    46
    bos.write(firstChunk);
    58
    bos.write(firstChunk);
    47
    bos.write(secondChunk);
    59
    bos.write(secondChunk);
    48
    bos.close();
    60
    bos.close();
    49
    checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
    61
    checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);
    50
    clientSocket.close();
    62
    clientSocket.close();
    Precondition Violations (0)
    Row Violation