View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.actions.teststep;
14  
15  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
16  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner;
17  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
18  import com.eviware.soapui.model.testsuite.TestCaseRunContext;
19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
20  import com.eviware.soapui.support.types.StringToObjectMap;
21  
22  /***
23   * Renames a WsdlTestStep
24   * 
25   * @author Ole.Matzura
26   */
27  
28  public class RunFromTestStepAction extends AbstractSoapUIAction<WsdlTestStep>
29  {
30  	public RunFromTestStepAction()
31  	{
32  		super( "Run from here", "Runs the TestCase starting at this step" );
33  	}
34  
35  	public void perform( WsdlTestStep testStep, Object param )
36  	{
37  		StringToObjectMap properties = recoverContextProperties( testStep );
38  		properties.put( TestCaseRunContext.INTERACTIVE, Boolean.TRUE );
39  
40  		
41  		WsdlTestCaseRunner testCaseRunner = new WsdlTestCaseRunner( testStep.getTestCase(), properties );
42  		testCaseRunner.setStartStep( testStep.getTestCase().getIndexOfTestStep( testStep ) );
43  		testCaseRunner.start( true );
44  	}
45  
46  
47  
48  	private StringToObjectMap recoverContextProperties( WsdlTestStep testStep )
49  	{
50  		StringToObjectMap properties = null;
51  		try
52  		{
53  			if( testStep.getParent() instanceof WsdlTestCase )
54  			{
55  				properties = ( ( WsdlTestCase )testStep.getParent() ).getRunFromHereContext();
56  			}
57  			else
58  			{
59  				properties = new StringToObjectMap();
60  			}
61  		}
62  		catch( Exception e )
63  		{
64  			properties = new StringToObjectMap();
65  		}
66  		return properties;
67  	}
68  }