git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@591425 13f79535-47bb-0310-9956-ffa450edef68master
@@ -52,14 +52,22 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
* @ant.task category="control" | * @ant.task category="control" | ||||
*/ | */ | ||||
public class WaitFor extends ConditionBase { | public class WaitFor extends ConditionBase { | ||||
/** a millisecond */ | |||||
public static final long ONE_MILLISECOND = 1L; | public static final long ONE_MILLISECOND = 1L; | ||||
/** a second in milliseconds */ | |||||
public static final long ONE_SECOND = 1000L; | public static final long ONE_SECOND = 1000L; | ||||
/** a minute in milliseconds */ | |||||
public static final long ONE_MINUTE = ONE_SECOND * 60L; | public static final long ONE_MINUTE = ONE_SECOND * 60L; | ||||
/** an hour in milliseconds */ | |||||
public static final long ONE_HOUR = ONE_MINUTE * 60L; | public static final long ONE_HOUR = ONE_MINUTE * 60L; | ||||
/** a day in milliseconds */ | |||||
public static final long ONE_DAY = ONE_HOUR * 24L; | public static final long ONE_DAY = ONE_HOUR * 24L; | ||||
/** a week in milliseconds */ | |||||
public static final long ONE_WEEK = ONE_DAY * 7L; | public static final long ONE_WEEK = ONE_DAY * 7L; | ||||
/** default wait time */ | |||||
public static final long DEFAULT_MAX_WAIT_MILLIS = ONE_MINUTE * 3L; | public static final long DEFAULT_MAX_WAIT_MILLIS = ONE_MINUTE * 3L; | ||||
/** default check time */ | |||||
public static final long DEFAULT_CHECK_MILLIS = 500L; | public static final long DEFAULT_CHECK_MILLIS = 500L; | ||||
/** default max wait time in the current unit*/ | /** default max wait time in the current unit*/ | ||||
@@ -1080,7 +1080,8 @@ public class JUnitTask extends Task { | |||||
* @return true if the run should be withoutput and error | * @return true if the run should be withoutput and error | ||||
*/ | */ | ||||
private boolean equalsWithOutAndErr(String summaryOption) { | private boolean equalsWithOutAndErr(String summaryOption) { | ||||
return summaryOption != null && "withoutanderr".equals(summaryOption.toLowerCase(Locale.ENGLISH)); | |||||
return summaryOption != null && "withoutanderr".equals( | |||||
summaryOption.toLowerCase(Locale.ENGLISH)); | |||||
} | } | ||||
private void checkIncludeSummary(CommandlineJava cmd) { | private void checkIncludeSummary(CommandlineJava cmd) { | ||||
@@ -1,9 +1,10 @@ | |||||
/* | /* | ||||
* Copyright 2007 The Apache Software Foundation | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | * | ||||
@@ -38,7 +39,7 @@ public class BlockFor extends WaitFor { | |||||
*/ | */ | ||||
public BlockFor() { | public BlockFor() { | ||||
super("blockfor"); | super("blockfor"); | ||||
text=getTaskName()+" timed out"; | |||||
text = getTaskName() + " timed out"; | |||||
} | } | ||||
/** | /** | ||||
@@ -1,9 +1,10 @@ | |||||
/* | /* | ||||
* Copyright 2007 The Apache Software Foundation | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | * | ||||
@@ -14,6 +15,7 @@ | |||||
* limitations under the License. | * limitations under the License. | ||||
* | * | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.testing; | package org.apache.tools.ant.taskdefs.optional.testing; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
@@ -1,9 +1,10 @@ | |||||
/* | /* | ||||
* Copyright 2007 The Apache Software Foundation | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | * | ||||
@@ -38,14 +39,19 @@ import org.apache.tools.ant.taskdefs.WaitFor; | |||||
* <li>A reporting sequence that runs after the tests have finished</li> | * <li>A reporting sequence that runs after the tests have finished</li> | ||||
* <li>A "teardown" clause that runs after the rest.</li> | * <li>A "teardown" clause that runs after the rest.</li> | ||||
* <li>Automated termination of the program it executes, if a timeout is not met</li> | * <li>Automated termination of the program it executes, if a timeout is not met</li> | ||||
* <li>Checking of a failure property and automatic raising of a fault (with the text in failureText) | |||||
* <li>Checking of a failure property and automatic raising of a fault | |||||
* (with the text in failureText) | |||||
* if test shutdown and reporting succeeded</li> | * if test shutdown and reporting succeeded</li> | ||||
* </ul> | * </ul> | ||||
* | * | ||||
* The task is designed to be framework neutral; it will work with JUnit, TestNG and other test frameworks That can be | |||||
* executed from Ant. It bears a resemblance to the FunctionalTest task from SmartFrog, as the attribute names were | |||||
* chosen to make migration easier. However, this task benefits from the ability to tweak Ant's internals, and so | |||||
* simplify the workflow, and from the experience of using the SmartFrog task. No code has been shared. | |||||
* The task is designed to be framework neutral; it will work with JUnit, | |||||
* TestNG and other test frameworks That can be | |||||
* executed from Ant. It bears a resemblance to the FunctionalTest task from | |||||
* SmartFrog, as the attribute names were | |||||
* chosen to make migration easier. However, this task benefits from the | |||||
* ability to tweak Ant's internals, and so | |||||
* simplify the workflow, and from the experience of using the SmartFrog task. | |||||
* No code has been shared. | |||||
* | * | ||||
* @since Ant 1.8 | * @since Ant 1.8 | ||||
*/ | */ | ||||
@@ -53,7 +59,8 @@ import org.apache.tools.ant.taskdefs.WaitFor; | |||||
public class Funtest extends Task { | public class Funtest extends Task { | ||||
/** | /** | ||||
* A condition that must be true before the tests are run. This makes it easier to define complex tests that only | |||||
* A condition that must be true before the tests are run. This makes it | |||||
* easier to define complex tests that only | |||||
* run if certain conditions are met, such as OS or network state. | * run if certain conditions are met, such as OS or network state. | ||||
*/ | */ | ||||
private Condition condition; | private Condition condition; | ||||
@@ -65,7 +72,8 @@ public class Funtest extends Task { | |||||
private Parallel timedTests; | private Parallel timedTests; | ||||
/** | /** | ||||
* Setup runs if the condition is met. Once setup is complete, teardown will be run when the task finishes | |||||
* Setup runs if the condition is met. Once setup is complete, teardown | |||||
* will be run when the task finishes | |||||
*/ | */ | ||||
private Sequential setup; | private Sequential setup; | ||||
@@ -85,7 +93,8 @@ public class Funtest extends Task { | |||||
private Sequential tests; | private Sequential tests; | ||||
/** | /** | ||||
* Reporting only runs if the tests were executed. If the block stopped them, reporting is skipped. | |||||
* Reporting only runs if the tests were executed. If the block stopped | |||||
* them, reporting is skipped. | |||||
*/ | */ | ||||
private Sequential reporting; | private Sequential reporting; | ||||
@@ -99,12 +108,12 @@ public class Funtest extends Task { | |||||
*/ | */ | ||||
private long timeout; | private long timeout; | ||||
private long timeoutUnitMultiplier= WaitFor.ONE_MILLISECOND; | |||||
private long timeoutUnitMultiplier = WaitFor.ONE_MILLISECOND; | |||||
/** | /** | ||||
* time for the execution to time out. | * time for the execution to time out. | ||||
*/ | */ | ||||
private long shutdownTime = 10*WaitFor.ONE_SECOND; | |||||
private long shutdownTime = 10 * WaitFor.ONE_SECOND; | |||||
private long shutdownUnitMultiplier = WaitFor.ONE_MILLISECOND; | private long shutdownUnitMultiplier = WaitFor.ONE_MILLISECOND; | ||||
@@ -116,7 +125,7 @@ public class Funtest extends Task { | |||||
/** | /** | ||||
* Message to send when tests failed | * Message to send when tests failed | ||||
*/ | */ | ||||
private String failureMessage="Tests failed"; | |||||
private String failureMessage = "Tests failed"; | |||||
/** | /** | ||||
* Flag to set to true if you don't care about any shutdown errors. | * Flag to set to true if you don't care about any shutdown errors. | ||||
@@ -125,7 +134,7 @@ public class Funtest extends Task { | |||||
* turned into BuildFault events. Similar to catching and ignoring | * turned into BuildFault events. Similar to catching and ignoring | ||||
* <code>finally {}</code> clauses in Java/ | * <code>finally {}</code> clauses in Java/ | ||||
*/ | */ | ||||
private boolean failOnTeardownErrors=true; | |||||
private boolean failOnTeardownErrors = true; | |||||
/** | /** | ||||
@@ -153,7 +162,9 @@ public class Funtest extends Task { | |||||
public static final String APPLICATION_FORCIBLY_SHUT_DOWN = "Application forcibly shut down"; | public static final String APPLICATION_FORCIBLY_SHUT_DOWN = "Application forcibly shut down"; | ||||
/** {@value} */ | /** {@value} */ | ||||
public static final String SHUTDOWN_INTERRUPTED = "Shutdown interrupted"; | public static final String SHUTDOWN_INTERRUPTED = "Shutdown interrupted"; | ||||
public static final String SKIPPING_TESTS = "Condition failed -skipping tests"; | |||||
/** {@value} */ | |||||
public static final String SKIPPING_TESTS | |||||
= "Condition failed -skipping tests"; | |||||
/** | /** | ||||
* Log if the definition is overriding something | * Log if the definition is overriding something | ||||
@@ -224,7 +235,7 @@ public class Funtest extends Task { | |||||
} | } | ||||
public void setTimeoutUnit(WaitFor.Unit unit) { | public void setTimeoutUnit(WaitFor.Unit unit) { | ||||
timeoutUnitMultiplier=unit.getMultiplier(); | |||||
timeoutUnitMultiplier = unit.getMultiplier(); | |||||
} | } | ||||
public void setShutdownUnit(WaitFor.Unit unit) { | public void setShutdownUnit(WaitFor.Unit unit) { | ||||
@@ -263,7 +274,7 @@ public class Funtest extends Task { | |||||
* @return a bound and initialised parallel instance. | * @return a bound and initialised parallel instance. | ||||
*/ | */ | ||||
private Parallel newParallel(long parallelTimeout) { | private Parallel newParallel(long parallelTimeout) { | ||||
Parallel par=new Parallel(); | |||||
Parallel par = new Parallel(); | |||||
bind(par); | bind(par); | ||||
par.setFailOnAny(true); | par.setFailOnAny(true); | ||||
par.setTimeout(parallelTimeout); | par.setTimeout(parallelTimeout); | ||||
@@ -275,7 +286,7 @@ public class Funtest extends Task { | |||||
* @param parallelTimeout timeout | * @param parallelTimeout timeout | ||||
* @return a bound and initialised parallel instance. | * @return a bound and initialised parallel instance. | ||||
*/ | */ | ||||
private Parallel newParallel(long parallelTimeout,Task child) { | |||||
private Parallel newParallel(long parallelTimeout, Task child) { | |||||
Parallel par = newParallel(parallelTimeout); | Parallel par = newParallel(parallelTimeout); | ||||
par.addTask(child); | par.addTask(child); | ||||
return par; | return par; | ||||
@@ -443,7 +454,7 @@ public class Funtest extends Task { | |||||
&& getProject().getProperty(failureProperty) != null) { | && getProject().getProperty(failureProperty) != null) { | ||||
//we've failed | //we've failed | ||||
log(failureMessage); | log(failureMessage); | ||||
if(taskException == null) { | |||||
if (taskException == null) { | |||||
taskException = new BuildException(failureMessage); | taskException = new BuildException(failureMessage); | ||||
} | } | ||||
} | } | ||||
@@ -209,7 +209,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
cmd.createArgument().setValue("-classpath"); | cmd.createArgument().setValue("-classpath"); | ||||
cmd.createArgument().setPath(classpath); | cmd.createArgument().setPath(classpath); | ||||
String stubOption=addStubVersionOptions(); | |||||
String stubOption = addStubVersionOptions(); | |||||
if (stubOption != null) { | if (stubOption != null) { | ||||
//set the non-null stubOption | //set the non-null stubOption | ||||
cmd.createArgument().setValue(stubOption); | cmd.createArgument().setValue(stubOption); | ||||
@@ -19,8 +19,6 @@ | |||||
package org.apache.tools.ant.taskdefs.rmic; | package org.apache.tools.ant.taskdefs.rmic; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.util.List; | |||||
import java.util.ArrayList; | |||||
import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
@@ -51,6 +49,7 @@ public class WLRmic extends DefaultRmicAdapter { | |||||
public static final String WL_RMI_STUB_SUFFIX = "_WLStub"; | public static final String WL_RMI_STUB_SUFFIX = "_WLStub"; | ||||
/** The skeleton suffix */ | /** The skeleton suffix */ | ||||
public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel"; | public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel"; | ||||
/** upsupported error message */ | |||||
public static final String UNSUPPORTED_STUB_OPTION = "Unsupported stub option: "; | public static final String UNSUPPORTED_STUB_OPTION = "Unsupported stub option: "; | ||||
/** | /** | ||||
@@ -128,7 +127,8 @@ public class WLRmic extends DefaultRmicAdapter { | |||||
//handle the many different stub options. | //handle the many different stub options. | ||||
String stubVersion = getRmic().getStubVersion(); | String stubVersion = getRmic().getStubVersion(); | ||||
if (null != stubVersion) { | if (null != stubVersion) { | ||||
getRmic().log(UNSUPPORTED_STUB_OPTION + stubVersion,Project.MSG_WARN); | |||||
getRmic().log(UNSUPPORTED_STUB_OPTION + stubVersion, | |||||
Project.MSG_WARN); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -1,9 +1,10 @@ | |||||
/* | /* | ||||
* Copyright 2007 The Apache Software Foundation | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | * | ||||
@@ -14,6 +15,7 @@ | |||||
* limitations under the License. | * limitations under the License. | ||||
* | * | ||||
*/ | */ | ||||
package org.apache.tools.ant.util; | package org.apache.tools.ant.util; | ||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
@@ -35,7 +37,7 @@ public class WorkerAnt extends Thread { | |||||
private Task task; | private Task task; | ||||
private Object notify; | private Object notify; | ||||
private volatile boolean finished=false; | |||||
private volatile boolean finished = false; | |||||
private volatile BuildException buildException; | private volatile BuildException buildException; | ||||
private volatile Throwable exception; | private volatile Throwable exception; | ||||
@@ -64,12 +66,13 @@ public class WorkerAnt extends Thread { | |||||
* @param task the task | * @param task the task | ||||
*/ | */ | ||||
public WorkerAnt(Task task) { | public WorkerAnt(Task task) { | ||||
this(task,null); | |||||
this(task, null); | |||||
} | } | ||||
/** | /** | ||||
* Get any build exception. | * Get any build exception. | ||||
* This would seem to be oversynchronised, but know that Java pre-1.5 can reorder volatile access. | |||||
* This would seem to be oversynchronised, but know that Java pre-1.5 can | |||||
* reorder volatile access. | |||||
* The synchronized attribute is to force an ordering. | * The synchronized attribute is to force an ordering. | ||||
* | * | ||||
* @return the exception or null | * @return the exception or null | ||||
@@ -81,7 +84,7 @@ public class WorkerAnt extends Thread { | |||||
/** | /** | ||||
* Get whatever was thrown, which may or may not be a buildException. | * Get whatever was thrown, which may or may not be a buildException. | ||||
* Assertion: getException() instanceof BuildException <=> getBuildException()==getException() | * Assertion: getException() instanceof BuildException <=> getBuildException()==getException() | ||||
* @return | |||||
* @return the exception. | |||||
*/ | */ | ||||
public synchronized Throwable getException() { | public synchronized Throwable getException() { | ||||
return exception; | return exception; | ||||
@@ -99,7 +102,8 @@ public class WorkerAnt extends Thread { | |||||
/** | /** | ||||
* Query the task/thread for being finished. | * Query the task/thread for being finished. | ||||
* This would seem to be oversynchronised, but know that Java pre-1.5 can reorder volatile access. | |||||
* This would seem to be oversynchronised, but know that Java pre-1.5 can | |||||
* reorder volatile access. | |||||
* The synchronized attribute is to force an ordering. | * The synchronized attribute is to force an ordering. | ||||
* @return true if the task is finished. | * @return true if the task is finished. | ||||
*/ | */ | ||||
@@ -113,8 +117,8 @@ public class WorkerAnt extends Thread { | |||||
* @throws InterruptedException if the execution was interrupted | * @throws InterruptedException if the execution was interrupted | ||||
*/ | */ | ||||
public void waitUntilFinished(long timeout) throws InterruptedException { | public void waitUntilFinished(long timeout) throws InterruptedException { | ||||
synchronized(notify) { | |||||
if(!finished) { | |||||
synchronized (notify) { | |||||
if (!finished) { | |||||
notify.wait(timeout); | notify.wait(timeout); | ||||
} | } | ||||
} | } | ||||
@@ -140,9 +144,9 @@ public class WorkerAnt extends Thread { | |||||
*/ | */ | ||||
private synchronized void caught(Throwable thrown) { | private synchronized void caught(Throwable thrown) { | ||||
exception = thrown; | exception = thrown; | ||||
buildException = (thrown instanceof BuildException)? | |||||
(BuildException)thrown | |||||
:new BuildException(thrown); | |||||
buildException = (thrown instanceof BuildException) | |||||
? (BuildException) thrown | |||||
: new BuildException(thrown); | |||||
} | } | ||||
/** | /** | ||||
@@ -158,7 +162,7 @@ public class WorkerAnt extends Thread { | |||||
caught(thrown); | caught(thrown); | ||||
} finally { | } finally { | ||||
synchronized (notify) { | synchronized (notify) { | ||||
finished=true; | |||||
finished = true; | |||||
//reset the task. | //reset the task. | ||||
//wake up our owner, if it is waiting | //wake up our owner, if it is waiting | ||||
notify.notifyAll(); | notify.notifyAll(); | ||||