01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.panels.support;
14:
15: import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
16: import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
17: import com.eviware.soapui.model.support.AbstractSubmitContext;
18: import com.eviware.soapui.model.testsuite.TestCase;
19: import com.eviware.soapui.model.testsuite.TestRunContext;
20: import com.eviware.soapui.model.testsuite.TestRunner;
21: import com.eviware.soapui.model.testsuite.TestStep;
22:
23: /**
24: * Dummy TestRunContext used when executing TestSteps one by one
25: *
26: * @author ole.matzura
27: */
28:
29: public class MockTestRunContext extends AbstractSubmitContext implements
30: TestRunContext {
31: private final MockTestRunner mockTestRunner;
32: private final WsdlTestStep testStep;
33:
34: public MockTestRunContext(MockTestRunner mockTestRunner,
35: WsdlTestStep testStep) {
36: this .mockTestRunner = mockTestRunner;
37: this .testStep = testStep;
38: setProperty("log", mockTestRunner.getLog());
39: }
40:
41: public TestStep getCurrentStep() {
42: return testStep;
43: }
44:
45: @Override
46: public void setProperty(String name, Object value) {
47: super .setProperty(name, value, getTestCase());
48: }
49:
50: public int getCurrentStepIndex() {
51: return testStep.getTestCase().getIndexOfTestStep(testStep);
52: }
53:
54: public TestRunner getTestRunner() {
55: return mockTestRunner;
56: }
57:
58: public Object getProperty(String name) {
59: return getProperty(name, testStep, (WsdlTestCase) testStep
60: .getTestCase());
61: }
62:
63: public Object getProperty(String testStepName, String propertyName) {
64: TestStep ts = testStep.getTestCase().getTestStepByName(
65: testStepName);
66: return ts == null ? null : ts.getPropertyValue(propertyName);
67: }
68:
69: public TestCase getTestCase() {
70: return testStep == null ? null : testStep.getTestCase();
71: }
72: }
|