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  /***
24   * Dummy TestRunContext used when executing TestSteps one by one
25   * 
26   * @author ole.matzura
27   */
28  
29  public class MockTestRunContext extends AbstractSubmitContext implements TestRunContext
30  {
31  	private final MockTestRunner mockTestRunner;
32  	private final WsdlTestStep testStep;
33  
34  	public MockTestRunContext(MockTestRunner mockTestRunner, WsdlTestStep testStep )
35  	{
36  		this.mockTestRunner = mockTestRunner;
37  		this.testStep = testStep;
38  		setProperty( "log", mockTestRunner.getLog() );
39  	}
40  
41  	public TestStep getCurrentStep()
42  	{
43  		return testStep;
44  	}
45  	
46  	@Override
47  	public void setProperty( String name, Object value )
48  	{
49  		super.setProperty( name, value, getTestCase() );
50  	}
51  
52  	public int getCurrentStepIndex()
53  	{
54  		return testStep.getTestCase().getIndexOfTestStep( testStep );
55  	}
56  
57  	public TestRunner getTestRunner()
58  	{
59  		return mockTestRunner;
60  	}
61  
62  	public Object getProperty(String name)
63  	{
64  		return getProperty( name, testStep, (WsdlTestCase) testStep.getTestCase() );
65  	}
66  
67  	public Object getProperty(String testStepName, String propertyName)
68  	{
69  		TestStep ts = testStep.getTestCase().getTestStepByName( testStepName );
70  		return ts == null ? null : ts.getPropertyValue( propertyName );
71  	}
72  
73  	public TestCase getTestCase()
74  	{
75  		return testStep == null ? null : testStep.getTestCase();
76  	}
77  }