View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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.TestRunContext;
19  import com.eviware.soapui.model.testsuite.TestRunner;
20  import com.eviware.soapui.model.testsuite.TestStep;
21  
22  public class MockTestRunContext extends AbstractSubmitContext implements TestRunContext
23  {
24  	private final MockTestRunner mockTestRunner;
25  	private final WsdlTestStep testStep;
26  
27  	public MockTestRunContext(MockTestRunner mockTestRunner, WsdlTestStep testStep )
28  	{
29  		this.mockTestRunner = mockTestRunner;
30  		this.testStep = testStep;
31  		setProperty( "log", mockTestRunner.getLog() );
32  	}
33  
34  	public TestStep getCurrentStep()
35  	{
36  		return testStep;
37  	}
38  
39  	public int getCurrentStepIndex()
40  	{
41  		return testStep.getTestCase().getIndexOfTestStep( testStep );
42  	}
43  
44  	public TestRunner getTestRunner()
45  	{
46  		return mockTestRunner;
47  	}
48  
49  	public Object getProperty(String name)
50  	{
51  		return getProperty( name, testStep, (WsdlTestCase) testStep.getTestCase() );
52  	}
53  
54  	public Object getProperty(String testStepName, String propertyName)
55  	{
56  		TestStep ts = testStep.getTestCase().getTestStepByName( testStepName );
57  		return ts == null ? null : ts.getPropertyValue( propertyName );
58  	}
59  }