View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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 java.util.ArrayList;
16  import java.util.List;
17  
18  import org.apache.log4j.Logger;
19  
20  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
21  import com.eviware.soapui.model.testsuite.TestCaseRunContext;
22  import com.eviware.soapui.model.testsuite.TestCaseRunner;
23  import com.eviware.soapui.model.testsuite.TestStep;
24  import com.eviware.soapui.model.testsuite.TestStepResult;
25  
26  /***
27   * Dummy TestRunner used when executing TestSteps one by one
28   * 
29   * @author ole.matzura
30   */
31  
32  public class MockTestRunner extends AbstractMockTestRunner<WsdlTestCase> implements TestCaseRunner
33  {
34  	private MockTestRunContext mockRunContext;
35  
36  	public MockTestRunner( WsdlTestCase testCase )
37  	{
38  		this( testCase, null );
39  	}
40  
41  	public MockTestRunner( WsdlTestCase testCase, Logger logger )
42  	{
43  		super( testCase, logger );
44  	}
45  
46  	public WsdlTestCase getTestCase()
47  	{
48  		return getTestRunnable();
49  	}
50  
51  	public List<TestStepResult> getResults()
52  	{
53  		return new ArrayList<TestStepResult>();
54  	}
55  
56  	public TestCaseRunContext getRunContext()
57  	{
58  		return mockRunContext;
59  	}
60  	
61  	public TestStepResult runTestStep( TestStep testStep )
62  	{
63  		return testStep.run( this, mockRunContext );
64  	}
65  
66  	public TestStepResult runTestStepByName( String name )
67  	{
68  		return getTestCase().getTestStepByName( name ).run( this, mockRunContext );
69  	}
70  
71  	public void gotoStep( int index )
72  	{
73  		getLog().info( "Going to step " + index + " [" + getTestCase().getTestStepAt( index ).getName() + "]" );
74  	}
75  
76  	public void gotoStepByName( String stepName )
77  	{
78  		getLog().info( "Going to step [" + stepName + "]" );
79  	}
80  
81  	public void setMockRunContext( MockTestRunContext mockRunContext )
82  	{
83  		this.mockRunContext = mockRunContext;
84  	}
85  }