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 testPostRequest()
|
Method name: void testGetRequest()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 17 | |||
1 | bos.write(postBody);↵ | 1 | bos.write(CRLF);↵ | |
2 | bos.close();↵ | 2 | bos.close();↵ | |
3 | // Write the headers and body↵ | |||
4 | outputStream.write(bos.toByteArray());↵ | 3 | outputStream.write(bos.toByteArray());↵ | |
4 | ↵ | |||
5 | // Read the response↵ | 5 | // Read the response↵ | |
6 | ByteArrayOutputStream response = new ByteArrayOutputStream(); ↵ | 6 | ByteArrayOutputStream response = new ByteArrayOutputStream(); ↵ | |
7 | byte[] buffer = new byte[1024];↵ | 7 | byte[] buffer = new byte[1024];↵ | |
8 | int length = 0;↵ | 8 | int length = 0;↵ | |
9 | while((length = inputStream.read(buffer)) != -1) {↵ | 9 | while(( length = inputStream.read(buffer)) != -1) {↵ | |
10 | response.write(buffer, 0, length);↵ | 10 | response.write(buffer, 0, length);↵ | |
11 | }↵ | 11 | }↵ | |
12 | response.close();↵ | 12 | response.close();↵ | |
13 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); ↵ | 13 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); ↵ | |
14 | // Check that the request and response matches↵ | 14 | // Check that the request and response matches↵ | |
15 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);↵ | 15 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse);↵ | |
16 | // Close the connection↵ | 16 | // Close the connection↵ | |
17 | clientSocket.close();↵ | 17 | clientSocket.close();↵ | |
18 | // Connect to the http server, and do a simple http post, with↵ | 18 | // Connect to the http server, and do a simple http get, with↵ | |
19 | // a pause after transmitting the headers↵ | 19 | // a pause in the middle of transmitting the header↵ | |
20 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT);↵ | 20 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT);↵ | |
21 | outputStream = clientSocket.getOutputStream();↵ | 21 | outputStream = clientSocket.getOutputStream();↵ | |
22 | inputStream = clientSocket.getInputStream();↵ | 22 | inputStream = clientSocket.getInputStream();↵ | |
23 | ↵ | 23 | ↵ | |
24 | // Write to the socket↵ | 24 | // Write to the socket↵ | |
25 | bos = new ByteArrayOutputStream();↵ | 25 | bos = new ByteArrayOutputStream();↵ | |
26 | // Headers↵ | 26 | // Headers↵ | |
27 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1)); | 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.4 |
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) | 24.5 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
18 | bos.write(postBody); |
| 10 | bos.close(); | |||||||||||||||||||||
19 | bos.close(); |
| 9 | bos.write(CRLF); | |||||||||||||||||||||
20 | outputStream.write(bos.toByteArray()); | 11 | outputStream.write(bos.toByteArray()); | ||||||||||||||||||||||
21 | ByteArrayOutputStream response = new ByteArrayOutputStream(); | 12 | ByteArrayOutputStream response = new ByteArrayOutputStream(); | ||||||||||||||||||||||
22 | byte[] buffer = new byte[1024]; | 13 | byte[] buffer = new byte[1024]; | ||||||||||||||||||||||
23 | int length = 0; | 14 | int length = 0; | ||||||||||||||||||||||
24 | while ((length = inputStream.read(buffer)) != -1) | 15 | while ((length = inputStream.read(buffer)) != -1) | ||||||||||||||||||||||
25 | response.write(buffer, 0, length); | 16 | response.write(buffer, 0, length); | ||||||||||||||||||||||
26 | response.close(); | 17 | response.close(); | ||||||||||||||||||||||
27 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); | 18 | byte[] mirroredResponse = getMirroredResponse(response.toByteArray()); | ||||||||||||||||||||||
28 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); | 19 | checkArraysHaveSameContent(bos.toByteArray(), mirroredResponse); | ||||||||||||||||||||||
29 | clientSocket.close(); | 20 | clientSocket.close(); | ||||||||||||||||||||||
30 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT); | 21 | clientSocket = new Socket("localhost", HTTP_SERVER_PORT); | ||||||||||||||||||||||
31 | outputStream = clientSocket.getOutputStream(); | 22 | outputStream = clientSocket.getOutputStream(); | ||||||||||||||||||||||
32 | inputStream = clientSocket.getInputStream(); | 23 | inputStream = clientSocket.getInputStream(); | ||||||||||||||||||||||
33 | bos = new ByteArrayOutputStream(); | 24 | bos = new ByteArrayOutputStream(); | ||||||||||||||||||||||
34 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1)); | 25 | bos.write("GET / HTTP 1.1".getBytes(ISO_8859_1)); |
Row | Violation |
---|---|
1 | Expression bos.write(postBody) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression bos.close() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression bos.write(postBody) is a void method call, and thus it cannot be parameterized |
4 | Expression bos.close() is a void method call, and thus it cannot be parameterized |
5 | Expression bos.write(postBody) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression bos.close() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression bos.write(postBody) is a void method call, and thus it cannot be parameterized |
8 | Expression bos.close() is a void method call, and thus it cannot be parameterized |
9 | Expression bos.close() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression bos.write(CRLF) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression bos.close() is a void method call, and thus it cannot be parameterized |
12 | Expression bos.write(CRLF) is a void method call, and thus it cannot be parameterized |
13 | Expression bos.close() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression bos.write(CRLF) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression bos.close() is a void method call, and thus it cannot be parameterized |
16 | Expression bos.write(CRLF) is a void method call, and thus it cannot be parameterized |
17 | Clone fragment #1 returns variables bos, outputStream, response, buffer, length, inputStream, mirroredResponse, clientSocket , while Clone fragment #2 returns variables bos, outputStream, response, buffer, length, inputStream, mirroredResponse, clientSocket |