|
|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
/* |
|
|
* Copyright 2001-2004 The Apache Software Foundation |
|
|
|
|
|
|
|
|
* Copyright 2001-2005 The Apache Software Foundation |
|
|
* |
|
|
* |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* you may not use this file except in compliance with the License. |
|
|
* you may not use this file except in compliance with the License. |
|
|
@@ -56,7 +56,8 @@ public class WaitFor extends ConditionBase { |
|
|
private String timeoutProperty; |
|
|
private String timeoutProperty; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the maximum length of time to wait |
|
|
|
|
|
|
|
|
* Set the maximum length of time to wait. |
|
|
|
|
|
* @param time a <code>long</code> value |
|
|
*/ |
|
|
*/ |
|
|
public void setMaxWait(long time) { |
|
|
public void setMaxWait(long time) { |
|
|
maxWaitMillis = time; |
|
|
maxWaitMillis = time; |
|
|
@@ -64,6 +65,7 @@ public class WaitFor extends ConditionBase { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the max wait time unit |
|
|
* Set the max wait time unit |
|
|
|
|
|
* @param unit an enumerated <code>Unit</code> value |
|
|
*/ |
|
|
*/ |
|
|
public void setMaxWaitUnit(Unit unit) { |
|
|
public void setMaxWaitUnit(Unit unit) { |
|
|
maxWaitMultiplier = unit.getMultiplier(); |
|
|
maxWaitMultiplier = unit.getMultiplier(); |
|
|
@@ -71,6 +73,7 @@ public class WaitFor extends ConditionBase { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the time between each check |
|
|
* Set the time between each check |
|
|
|
|
|
* @param time a <code>long</code> value |
|
|
*/ |
|
|
*/ |
|
|
public void setCheckEvery(long time) { |
|
|
public void setCheckEvery(long time) { |
|
|
checkEveryMillis = time; |
|
|
checkEveryMillis = time; |
|
|
@@ -78,6 +81,7 @@ public class WaitFor extends ConditionBase { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set the check every time unit |
|
|
* Set the check every time unit |
|
|
|
|
|
* @param unit an enumerated <code>Unit</code> value |
|
|
*/ |
|
|
*/ |
|
|
public void setCheckEveryUnit(Unit unit) { |
|
|
public void setCheckEveryUnit(Unit unit) { |
|
|
checkEveryMultiplier = unit.getMultiplier(); |
|
|
checkEveryMultiplier = unit.getMultiplier(); |
|
|
@@ -85,6 +89,7 @@ public class WaitFor extends ConditionBase { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Name the property to set after a timeout. |
|
|
* Name the property to set after a timeout. |
|
|
|
|
|
* @param p the property name |
|
|
*/ |
|
|
*/ |
|
|
public void setTimeoutProperty(String p) { |
|
|
public void setTimeoutProperty(String p) { |
|
|
timeoutProperty = p; |
|
|
timeoutProperty = p; |
|
|
@@ -93,6 +98,7 @@ public class WaitFor extends ConditionBase { |
|
|
/** |
|
|
/** |
|
|
* Check repeatedly for the specified conditions until they become |
|
|
* Check repeatedly for the specified conditions until they become |
|
|
* true or the timeout expires. |
|
|
* true or the timeout expires. |
|
|
|
|
|
* @throws BuildException on error |
|
|
*/ |
|
|
*/ |
|
|
public void execute() throws BuildException { |
|
|
public void execute() throws BuildException { |
|
|
if (countConditions() > 1) { |
|
|
if (countConditions() > 1) { |
|
|
@@ -147,12 +153,13 @@ public class WaitFor extends ConditionBase { |
|
|
private static final String DAY = "day"; |
|
|
private static final String DAY = "day"; |
|
|
private static final String WEEK = "week"; |
|
|
private static final String WEEK = "week"; |
|
|
|
|
|
|
|
|
private static final String[] units = { |
|
|
|
|
|
|
|
|
private static final String[] UNITS = { |
|
|
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK |
|
|
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
private Hashtable timeTable = new Hashtable(); |
|
|
private Hashtable timeTable = new Hashtable(); |
|
|
|
|
|
|
|
|
|
|
|
/** Constructor the Unit enumerated type. */ |
|
|
public Unit() { |
|
|
public Unit() { |
|
|
timeTable.put(MILLISECOND, new Long(1L)); |
|
|
timeTable.put(MILLISECOND, new Long(1L)); |
|
|
timeTable.put(SECOND, new Long(1000L)); |
|
|
timeTable.put(SECOND, new Long(1000L)); |
|
|
@@ -162,14 +169,21 @@ public class WaitFor extends ConditionBase { |
|
|
timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L)); |
|
|
timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Convert the value to a multipler (millisecond to unit). |
|
|
|
|
|
* @return a multipler (a long value) |
|
|
|
|
|
*/ |
|
|
public long getMultiplier() { |
|
|
public long getMultiplier() { |
|
|
String key = getValue().toLowerCase(); |
|
|
String key = getValue().toLowerCase(); |
|
|
Long l = (Long) timeTable.get(key); |
|
|
Long l = (Long) timeTable.get(key); |
|
|
return l.longValue(); |
|
|
return l.longValue(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @see EnumeratedAttribute#getValues() |
|
|
|
|
|
*/ |
|
|
public String[] getValues() { |
|
|
public String[] getValues() { |
|
|
return units; |
|
|
|
|
|
|
|
|
return UNITS; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |