001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.impl.wsdl.panels.support;
014:
015: import java.util.ArrayList;
016: import java.util.List;
017:
018: import org.apache.log4j.Logger;
019:
020: import com.eviware.soapui.SoapUI;
021: import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
022: import com.eviware.soapui.model.testsuite.TestCase;
023: import com.eviware.soapui.model.testsuite.TestRunner;
024: import com.eviware.soapui.model.testsuite.TestStepResult;
025:
026: /**
027: * Dummy TestRunner used when executing TestSteps one by one
028: *
029: * @author ole.matzura
030: */
031:
032: public class MockTestRunner implements TestRunner {
033: private long startTime;
034: private String reason;
035: private final WsdlTestCase testCase;
036: private final Logger logger;
037:
038: public MockTestRunner(WsdlTestCase testCase) {
039: this (testCase, null);
040: }
041:
042: public MockTestRunner(WsdlTestCase testCase, Logger logger) {
043: this .testCase = testCase;
044: this .logger = logger == null ? SoapUI.ensureGroovyLog()
045: : logger;
046: startTime = System.currentTimeMillis();
047: }
048:
049: public Logger getLog() {
050: return logger;
051: }
052:
053: public TestCase getTestCase() {
054: return testCase;
055: }
056:
057: public List<TestStepResult> getResults() {
058: return new ArrayList<TestStepResult>();
059: }
060:
061: public Status getStatus() {
062: return Status.RUNNING;
063: }
064:
065: public void start(boolean async) {
066:
067: }
068:
069: public long getTimeTaken() {
070: return System.currentTimeMillis() - startTime;
071: }
072:
073: public Status waitUntilFinished() {
074: return Status.FINISHED;
075: }
076:
077: public void cancel(String reason) {
078: this .reason = reason;
079: logger.info("Canceled with reason [" + reason + "]");
080: }
081:
082: public void gotoStep(int index) {
083: logger.info("Going to step " + index + " ["
084: + testCase.getTestStepAt(index).getName() + "]");
085: }
086:
087: public void gotoStepByName(String stepName) {
088: logger.info("Going to step [" + stepName + "]");
089: }
090:
091: public void fail(String reason) {
092: this .reason = reason;
093: logger.error("Failed with reason [" + reason + "]");
094: }
095:
096: public long getStartTime() {
097: return startTime;
098: }
099:
100: public String getReason() {
101: return reason;
102: }
103: }
|