File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java | File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java | |||
Method name: void testTimeOut()
|
Method name: void testTimeOut()
|
|||
Number of AST nodes: 8 | Number of AST nodes: 8 | |||
1 | Process process = getProcess(TIME_OUT*2);↵ | |||
2 | long now = System.currentTimeMillis();↵ | |||
3 | watchdog.start(process);↵ | |||
4 | int retCode = process.waitFor(↵ | 1 | Commandline cmd = getCommandline(TIME_OUT*2);↵ | |
2 | ej.setJavaCommand(cmd);↵ | |||
3 | long now = System.currentTimeMillis();↵ | |||
5 | );↵ | 4 | ej.execute(project);↵ | |
6 | long elapsed = System.currentTimeMillis() - now;↵ | 5 | long elapsed = System.currentTimeMillis() - now;↵ | |
7 | assertTrue("process should have been killed", watchdog.killedProcess());↵ | 6 | assertTrue("process should have been killed", ej.killedProcess());↵ | |
8 | // assertTrue("return code is invalid: " + retCode, retCode!=0);↵ | |||
9 | assertTrue("elapse time of "+elapsed↵ | 7 | assertTrue("elapse time of "+elapsed↵ | |
10 | +" ms is less than timeout value of "+TIME_OUT_TEST+" ms",↵ | 8 | +" ms is less than timeout value of "+TIME_OUT_TEST+" ms",↵ | |
11 | elapsed >= TIME_OUT_TEST);↵ | 9 | elapsed >= TIME_OUT_TEST);↵ | |
12 | assertTrue("elapse time of "+elapsed↵ | 10 | assertTrue("elapse time of "+elapsed↵ | |
13 | +" ms is greater than run value of "+(TIME_OUT*2)+" ms",↵ | 11 | +" ms is greater than run value of "+(TIME_OUT*2)+" ms",↵ | |
14 | elapsed < TIME_OUT*2); | 12 | elapsed < TIME_OUT*2); | |
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.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 64 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Commandline cmd = getCommandline(TIME_OUT * 2); | ||||||||||||||||||||||||
1 | Process process = getProcess(TIME_OUT * 2); | | ||||||||||||||||||||||||
| 2 | ej.setJavaCommand(cmd); | ||||||||||||||||||||||||
2 | long now = System.currentTimeMillis(); | 3 | long now = System.currentTimeMillis(); | |||||||||||||||||||||||
3 | watchdog.start(process); |
| 8 | assertTrue("elapse time of " + elapsed + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", elapsed < TIME_OUT * 2); | ||||||||||||||||||||||
4 | int retCode = process.waitFor(); | | ||||||||||||||||||||||||
5 | long elapsed = System.currentTimeMillis() - now; | 5 | long elapsed = System.currentTimeMillis() - now; | |||||||||||||||||||||||
6 | assertTrue("process should have been killed", watchdog.killedProcess()); |
| 6 | assertTrue("process should have been killed", ej.killedProcess()); | ||||||||||||||||||||||
7 | assertTrue("elapse time of " + elapsed + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", elapsed >= TIME_OUT_TEST); |
| 7 | assertTrue("elapse time of " + elapsed + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", elapsed >= TIME_OUT_TEST); | ||||||||||||||||||||||
8 | assertTrue("elapse time of " + elapsed + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", elapsed < TIME_OUT * 2); |
| 4 | ej.execute(project); |
Row | Violation |
---|---|
1 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression watchdog.start(process) is a void method call, and thus it cannot be parameterized |
3 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) is a void method call, and thus it cannot be parameterized |
4 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression watchdog.start(process) is a void method call, and thus it cannot be parameterized |
6 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) is a void method call, and thus it cannot be parameterized |
7 | Type org.apache.tools.ant.taskdefs.ExecuteWatchdog of variable watchdog does not match with type org.apache.tools.ant.taskdefs.ExecuteJava of variable ej |
8 | Type long of variable TIME_OUT_TEST does not match with type int of variable TIME_OUT_TEST |
9 | Type long of variable TIME_OUT_TEST does not match with type int of variable TIME_OUT_TEST |
10 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) is a void method call, and thus it cannot be parameterized |
12 | Expression ej.execute(project) is a void method call, and thus it cannot be parameterized |
13 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression assertTrue("elapse time of " + elapsed + " ms is greater than run value of "+ (TIME_OUT * 2)+ " ms",elapsed < TIME_OUT * 2) is a void method call, and thus it cannot be parameterized |
15 | Expression ej.execute(project) is a void method call, and thus it cannot be parameterized |