View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
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.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  public class MockTestRunContext extends AbstractSubmitContext implements TestRunContext
24  {
25  	private final MockTestRunner mockTestRunner;
26  	private final WsdlTestStep testStep;
27  
28  	public MockTestRunContext(MockTestRunner mockTestRunner, WsdlTestStep testStep )
29  	{
30  		this.mockTestRunner = mockTestRunner;
31  		this.testStep = testStep;
32  		setProperty( "log", mockTestRunner.getLog() );
33  	}
34  
35  	public TestStep getCurrentStep()
36  	{
37  		return testStep;
38  	}
39  
40  	public int getCurrentStepIndex()
41  	{
42  		return testStep.getTestCase().getIndexOfTestStep( testStep );
43  	}
44  
45  	public TestRunner getTestRunner()
46  	{
47  		return mockTestRunner;
48  	}
49  
50  	public Object getProperty(String name)
51  	{
52  		return getProperty( name, testStep, (WsdlTestCase) testStep.getTestCase() );
53  	}
54  
55  	public Object getProperty(String testStepName, String propertyName)
56  	{
57  		TestStep ts = testStep.getTestCase().getTestStepByName( testStepName );
58  		return ts == null ? null : ts.getPropertyValue( propertyName );
59  	}
60  
61  	public TestCase getTestCase()
62  	{
63  		return testStep.getTestCase();
64  	}
65  }