01: // Copyright © 2002-2005 Canoo Engineering AG, Switzerland.
02: package com.canoo.webtest.ant;
03:
04: import java.util.Iterator;
05:
06: import org.apache.log4j.Logger;
07: import org.apache.tools.ant.Task;
08:
09: import com.canoo.webtest.steps.AbstractStepContainer;
10:
11: /**
12: * @webtest.step
13: * category="General"
14: * name="steps"
15: * description="This is a nested task of <stepref name='webtest' category='General'/> and is used to define the sequence of test steps to be executed."
16: */
17: public class TestStepSequence extends AbstractStepContainer {
18: private static final Logger LOG = Logger
19: .getLogger(TestStepSequence.class);
20:
21: public TestStepSequence() {
22: LOG.debug("Creating TestStepSequence");
23: }
24:
25: public void doExecute() throws Exception {
26: LOG.debug("TestStepSequence: doExecute()");
27:
28: if (getSteps().isEmpty()) {
29: throw new IllegalArgumentException(
30: "At least one step is required in the WebTestSpec!");
31: }
32:
33: executeSteps();
34: }
35:
36: /**
37: */
38: protected void executeSteps() {
39: Task currentStep = null;
40: LOG.debug("Executing steps...");
41: for (final Iterator iterator = getSteps().iterator(); iterator
42: .hasNext();) {
43: currentStep = (Task) iterator.next();
44: LOG.debug("Executing step " + currentStep.getTaskName()
45: + " " + currentStep);
46: currentStep.perform();
47: getContext().increaseStepNumber();
48: }
49: LOG.debug("Step execution finished");
50: }
51: }
|