2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
19
package org.apache.tools.ant.taskdefs;
21
import org.apache.tools.ant.BuildFileTest;
23
* @created 01 May 2001
25
public class SleepTest extends BuildFileTest {
28
private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/";
29
private final static boolean TRACE=false;
30
private final static int ERROR_RANGE=1000;
32
public SleepTest(String name) {
37
configureProject(TASKDEFS_DIR + "sleep.xml");
41
Timer timer=new Timer();
42
executeTarget("test1");
44
if(TRACE) System.out.println(" test1 elapsed time="+timer.time());
45
assertTrue(timer.time()>=0);
49
Timer timer=new Timer();
50
executeTarget("test2");
52
if(TRACE) System.out.println(" test2 elapsed time="+timer.time());
53
assertTrue(timer.time()>=0);
57
Timer timer=new Timer();
58
executeTarget("test3");
60
if(TRACE) System.out.println(" test3 elapsed time="+timer.time());
61
assertTrue(timer.time()>=(2000-ERROR_RANGE));
65
Timer timer=new Timer();
66
executeTarget("test3");
68
if(TRACE) System.out.println(" test4 elapsed time="+timer.time());
69
assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000);
73
expectBuildException("test5",
74
"Negative sleep periods are not supported");
78
Timer timer=new Timer();
79
executeTarget("test6");
81
if(TRACE) System.out.println(" test6 elapsed time="+timer.time());
82
assertTrue(timer.time()<2000);
89
private static class Timer {
98
start=System.currentTimeMillis();
102
stop=System.currentTimeMillis();
2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
19
package org.apache.tools.ant.taskdefs;
21
import org.apache.tools.ant.BuildFileTest;
23
* @created 01 May 2001
25
public class SleepTest extends BuildFileTest {
28
private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/";
29
private final static boolean TRACE=false;
30
private final static int ERROR_RANGE=1000;
32
public SleepTest(String name) {
37
configureProject(TASKDEFS_DIR + "sleep.xml");
41
Timer timer=new Timer();
42
executeTarget("test1");
44
if(TRACE) System.out.println(" test1 elapsed time="+timer.time());
45
assertTrue(timer.time()>=0);
49
Timer timer=new Timer();
50
executeTarget("test2");
52
if(TRACE) System.out.println(" test2 elapsed time="+timer.time());
53
assertTrue(timer.time()>=0);
57
Timer timer=new Timer();
58
executeTarget("test3");
60
if(TRACE) System.out.println(" test3 elapsed time="+timer.time());
61
assertTrue(timer.time()>=(2000-ERROR_RANGE));
65
Timer timer=new Timer();
66
executeTarget("test3");
68
if(TRACE) System.out.println(" test4 elapsed time="+timer.time());
69
assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000);
73
expectBuildException("test5",
74
"Negative sleep periods are not supported");
78
Timer timer=new Timer();
79
executeTarget("test6");
81
if(TRACE) System.out.println(" test6 elapsed time="+timer.time());
82
assertTrue(timer.time()<2000);
89
private static class Timer {
98
start=System.currentTimeMillis();
102
stop=System.currentTimeMillis();