1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.testcase;
14
15 import com.eviware.soapui.model.support.AbstractSubmitContext;
16 import com.eviware.soapui.model.support.PropertiesMap;
17 import com.eviware.soapui.model.testsuite.TestCase;
18 import com.eviware.soapui.model.testsuite.TestRunContext;
19 import com.eviware.soapui.model.testsuite.TestRunner;
20 import com.eviware.soapui.model.testsuite.TestStep;
21
22 /***
23 * TestRunContext for WsdlTestCase runners
24 *
25 * @author Ole.Matzura
26 */
27
28 public class WsdlTestRunContext extends AbstractSubmitContext implements TestRunContext
29 {
30 private final TestRunner testRunner;
31 private int currentStepIndex;
32 private TestCase testCase;
33
34 public WsdlTestRunContext( TestRunner testRunner, PropertiesMap properties )
35 {
36 super( properties );
37 this.testRunner = testRunner;
38 }
39
40 public WsdlTestRunContext( TestStep testStep )
41 {
42 this( null, null );
43
44 testCase = testStep.getTestCase();
45 currentStepIndex = testCase.getIndexOfTestStep( testStep );
46 }
47
48 public TestStep getCurrentStep()
49 {
50 if( currentStepIndex < 0 || currentStepIndex >= getTestCase().getTestStepCount() )
51 return null;
52
53 return getTestCase().getTestStepAt( currentStepIndex );
54 }
55
56 public int getCurrentStepIndex()
57 {
58 return currentStepIndex;
59 }
60
61 public void setCurrentStep( int index )
62 {
63 currentStepIndex = index;
64 }
65
66 public TestRunner getTestRunner()
67 {
68 return testRunner;
69 }
70
71 public Object getProperty(String testStepName, String propertyName)
72 {
73 TestStep testStep = getTestCase().getTestStepByName( testStepName );
74 return testStep == null ? null : testStep.getPropertyValue( propertyName );
75 }
76
77 public TestCase getTestCase()
78 {
79 return testRunner == null ? testCase : testRunner.getTestCase();
80 }
81
82 public Object getProperty(String name)
83 {
84 WsdlTestCase testCase = (WsdlTestCase) getTestCase();
85 TestStep testStep = currentStepIndex >= 0 && currentStepIndex < testCase.getTestStepCount() ?
86 testCase.getTestStepAt( currentStepIndex ) : null;
87
88 return getProperty( name, testStep, testCase);
89 }
90
91 public void reset()
92 {
93 resetProperties();
94 currentStepIndex = 0;
95 }
96 }