1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.panels.support;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.apache.log4j.Logger;
19
20 import com.eviware.soapui.SoapUI;
21 import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
22 import com.eviware.soapui.model.testsuite.TestCase;
23 import com.eviware.soapui.model.testsuite.TestRunner;
24 import com.eviware.soapui.model.testsuite.TestStepResult;
25
26 public class MockTestRunner implements TestRunner
27 {
28 private long startTime;
29 private String reason;
30 private final WsdlTestCase testCase;
31 private final Logger logger;
32
33 public MockTestRunner( WsdlTestCase testCase )
34 {
35 this( testCase, null );
36 }
37
38 public MockTestRunner( WsdlTestCase testCase, Logger logger )
39 {
40 this.testCase = testCase;
41 this.logger = logger == null ? SoapUI.ensureGroovyLog() : logger;
42 startTime = System.currentTimeMillis();
43 }
44
45 public Logger getLog()
46 {
47 return logger;
48 }
49
50 public TestCase getTestCase()
51 {
52 return testCase;
53 }
54
55 public List<TestStepResult> getResults()
56 {
57 return new ArrayList<TestStepResult>();
58 }
59
60 public Status getStatus()
61 {
62 return Status.RUNNING;
63 }
64
65 public void start( boolean async )
66 {
67
68 }
69
70 public long getTimeTaken()
71 {
72 return System.currentTimeMillis()-startTime;
73 }
74
75 public Status waitUntilFinished()
76 {
77 return Status.FINISHED;
78 }
79
80 public void cancel(String reason)
81 {
82 this.reason = reason;
83 logger.info( "Canceled with reason [" + reason + "]" );
84 }
85
86 public void gotoStep(int index)
87 {
88 logger.info( "Going to step " + index + " [" +
89 testCase.getTestStepAt( index ).getName() + "]");
90 }
91
92 public void gotoStepByName(String stepName)
93 {
94 logger.info( "Going to step [" + stepName + "]" );
95 }
96
97 public void fail(String reason)
98 {
99 this.reason = reason;
100 logger.error( "Failed with reason [" + reason + "]" );
101 }
102
103 public long getStartTime()
104 {
105 return startTime;
106 }
107
108 public String getReason()
109 {
110 return reason;
111 }
112 }