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.loadtest.strategy;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  
18  import javax.swing.JComponent;
19  
20  import org.apache.xmlbeans.XmlObject;
21  
22  import com.eviware.soapui.config.LoadTestLimitTypesConfig;
23  import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
24  import com.eviware.soapui.model.testsuite.LoadTestRunContext;
25  import com.eviware.soapui.model.testsuite.LoadTestRunner;
26  import com.eviware.soapui.model.testsuite.TestCaseRunContext;
27  import com.eviware.soapui.model.testsuite.TestCaseRunner;
28  import com.eviware.soapui.model.testsuite.TestStep;
29  import com.eviware.soapui.model.testsuite.TestStepResult;
30  
31  /***
32   * LoadStrategy allowing maximum runs and request delays
33   * 
34   * @author Ole.Matzura
35   */
36  
37  public abstract class AbstractLoadStrategy implements LoadStrategy
38  {
39  	private PropertyChangeSupport propertyChangeSupport;
40  	private final String type;
41  	private final WsdlLoadTest loadTest;
42  
43  	public AbstractLoadStrategy( String type, WsdlLoadTest loadTest )
44  	{
45  		this.type = type;
46  		this.loadTest = loadTest;
47  		propertyChangeSupport = new PropertyChangeSupport( this );
48  	}
49  
50  	public XmlObject getConfig()
51  	{
52  		return null;
53  	}
54  
55  	public JComponent getConfigurationPanel()
56  	{
57  		return null;
58  	}
59  
60  	public String getType()
61  	{
62  		return type;
63  	}
64  
65  	public WsdlLoadTest getLoadTest()
66  	{
67  		return loadTest;
68  	}
69  
70  	public void addConfigurationChangeListener( PropertyChangeListener listener )
71  	{
72  		propertyChangeSupport.addPropertyChangeListener( CONFIGURATION_PROPERTY, listener );
73  	}
74  
75  	public void removeConfigurationChangeListener( PropertyChangeListener listener )
76  	{
77  		propertyChangeSupport.removePropertyChangeListener( CONFIGURATION_PROPERTY, listener );
78  	}
79  
80  	public void notifyConfigurationChanged()
81  	{
82  		propertyChangeSupport.firePropertyChange( CONFIGURATION_PROPERTY, null, null );
83  	}
84  
85  	public boolean allowThreadCountChangeDuringRun()
86  	{
87  		return true;
88  	}
89  
90  	public void afterLoadTest( LoadTestRunner loadTestRunner, LoadTestRunContext context )
91  	{
92  	}
93  
94  	public void afterTestCase( LoadTestRunner loadTestRunner, LoadTestRunContext context, TestCaseRunner testRunner,
95  			TestCaseRunContext runContext )
96  	{
97  	}
98  
99  	public void afterTestStep( LoadTestRunner loadTestRunner, LoadTestRunContext context, TestCaseRunner testRunner,
100 			TestCaseRunContext runContext, TestStepResult testStepResult )
101 	{
102 	}
103 
104 	public void beforeLoadTest( LoadTestRunner loadTestRunner, LoadTestRunContext context )
105 	{
106 		if( getLoadTest().getLimitType() == LoadTestLimitTypesConfig.COUNT
107 				&& getLoadTest().getTestLimit() < getLoadTest().getThreadCount() )
108 		{
109 			getLoadTest().setThreadCount( getLoadTest().getTestLimit() );
110 		}
111 	}
112 
113 	public void beforeTestCase( LoadTestRunner loadTestRunner, LoadTestRunContext context, TestCaseRunner testRunner,
114 			TestCaseRunContext runContext )
115 	{
116 	}
117 
118 	public void beforeTestStep( LoadTestRunner loadTestRunner, LoadTestRunContext context, TestCaseRunner testRunner,
119 			TestCaseRunContext runContext, TestStep testStep )
120 	{
121 	}
122 
123 	public void loadTestStarted( LoadTestRunner loadTestRunner, LoadTestRunContext context )
124 	{
125 	}
126 
127 	public void loadTestStopped( LoadTestRunner loadTestRunner, LoadTestRunContext context )
128 	{
129 	}
130 
131 	public void recalculate( LoadTestRunner loadTestRunner, LoadTestRunContext context )
132 	{
133 	}
134 
135 	public void updateConfig( XmlObject config )
136 	{
137 	}
138 }