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: 17 | Number of AST nodes: 17 | |||
1 | bos.close();↵ | 1 | bos.close();↵ | |
2 | // Write the headers and body↵ | |||
2 | outputStream.write(bos.toByteArray());↵ | 3 | outputStream.write(bos.toByteArray());↵ | |
3 | ↵ | |||
4 | // Read the response↵ | 4 | // Read the response↵ | |
5 | ByteArrayOutputStream response = new ByteArrayOutputStream(); ↵ | 5 | ByteArrayOutputStream response = new ByteArrayOutputStream(); ↵ | |
6 | byte[] buffer = new byte[1024];↵ | 6 | byte[] buffer = new byte[1024];↵ | |
7 | int length = 0;↵ | 7 | int length = 0;↵ | |
8 | while(( length = inputStream.read(buffer)) != -1) {↵ | 8 | while((length = inputStream.read(buffer)) != -1) {↵ | |
9 | response.write(buffer, 0, length);↵ | 9 | response.write(buffer, 0, length);↵ | |
10 | }↵ | 10 | }↵ | |
11 | response.close();↵ | 11 | response.close();↵ | |
12 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); ↵ | 12 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); ↵ | |
13 | // Check that the request and response matches↵ | 13 | // Check that the request and response matches↵ | |
14 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);↵ | 14 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);↵ | |
15 | // Close the connection↵ | 15 | // Close the connection↵ | |
16 | clientSocket.close();↵ | 16 | clientSocket.close();↵ | |
17 | // Connect to the http server, and do a simple http get, with↵ | 17 | // Connect to the http server, and do a simple http post, with↵ | |
18 | // a pause in the middle of transmitting the header↵ | 18 | // a pause after transmitting the headers↵ | |
19 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT);↵ | 19 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT);↵ | |
20 | outputStream = clientSocket.getOutputStream();↵ | 20 | outputStream = clientSocket.getOutputStream();↵ | |
21 | inputStream = clientSocket.getInputStream();↵ | 21 | inputStream = clientSocket.getInputStream();↵ | |
22 | ↵ | 22 | ↵ | |
23 | // Write to the socket↵ | 23 | // Write to the socket↵ | |
24 | bos = new ByteArrayOutputStream();↵ | 24 | bos = new ByteArrayOutputStream();↵ | |
25 | // Headers↵ | 25 | // Headers↵ | |
26 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));↵ | 26 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1));↵ | |
27 | bos.write(CRLF); | 27 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 202 |
Number of mapped statements | 17 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 12.3 |
Clone type | Type 1 |
ID | Statement | ID | Statement | |
---|---|---|---|---|
10 | bos.close(); | 19 | bos.close(); | |
11 | outputStream.write(bos.toByteArray()); | 20 | outputStream.write(bos.toByteArray()); | |
12 | ByteArrayOutputStream response = new ByteArrayOutputStream(); | 21 | ByteArrayOutputStream response = new ByteArrayOutputStream(); | |
13 | byte[] buffer = new byte[1024]; | 22 | byte[] buffer = new byte[1024]; | |
14 | int length = 0; | 23 | int length = 0; | |
15 | while ((length = inputStream.read(buffer)) != -1) | 24 | while ((length = inputStream.read(buffer)) != -1) | |
16 | response.write(buffer, 0, length); | 25 | response.write(buffer, 0, length); | |
17 | response.close(); | 26 | response.close(); | |
18 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); | 27 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); | |
19 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); | 28 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); | |
20 | clientSocket.close(); | 29 | clientSocket.close(); | |
21 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT); | 30 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT); | |
22 | outputStream = clientSocket.getOutputStream(); | 31 | outputStream = clientSocket.getOutputStream(); | |
23 | inputStream = clientSocket.getInputStream(); | 32 | inputStream = clientSocket.getInputStream(); | |
24 | bos = new ByteArrayOutputStream(); | 33 | bos = new ByteArrayOutputStream(); | |
25 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1)); | 34 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1)); | |
26 | bos.write(CRLF); | 35 | bos.write(CRLF); |
Row | Violation |
---|---|
1 | Clone fragment #1 returns variables bos, outputStream, response, buffer, inputStream, mirroredResponse, clientSocket , while Clone fragment #2 returns variables bos, outputStream, response, buffer, inputStream, mirroredResponse, clientSocket |