1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.loadtest;
14
15 import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
16 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
17 import com.eviware.soapui.model.settings.Settings;
18 import com.eviware.soapui.settings.HttpSettings;
19 import com.eviware.soapui.support.UISupport;
20 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21 import com.eviware.x.form.XFormDialog;
22 import com.eviware.x.form.XFormField;
23 import com.eviware.x.form.XFormFieldListener;
24 import com.eviware.x.form.support.ADialogBuilder;
25 import com.eviware.x.form.support.AField;
26 import com.eviware.x.form.support.AForm;
27 import com.eviware.x.form.support.APage;
28 import com.eviware.x.form.support.AField.AFieldType;
29
30 /***
31 * Displays the LoadTest Options dialog
32 *
33 * @author Ole.Matzura
34 */
35
36 public class LoadTestOptionsAction extends AbstractSoapUIAction<WsdlLoadTest>
37 {
38 public static final String SOAPUI_ACTION_ID = "LoadTestOptionsAction";
39 private XFormDialog dialog;
40
41 public LoadTestOptionsAction()
42 {
43 super( "Options", "Sets options for this LoadTest" );
44 }
45
46 public void perform( WsdlLoadTest loadTest, Object param )
47 {
48 if( dialog == null )
49 buildDialog();
50
51 dialog.setIntValue( SettingsForm.THREAD_STARTUP_DELAY, loadTest.getStartDelay() );
52 dialog.setBooleanValue( SettingsForm.RESET_STATISTICS, loadTest.getResetStatisticsOnThreadCountChange() );
53 dialog.setBooleanValue( SettingsForm.CALC_TPS, loadTest.getCalculateTPSOnTimePassed() );
54 dialog.setIntValue( SettingsForm.SAMPLE_INTERVAL, ( int ) loadTest.getSampleInterval() );
55 dialog.setBooleanValue( SettingsForm.DISABLE_HISTORY, loadTest.getHistoryLimit() == 0 );
56 dialog.setIntValue( SettingsForm.MAX_ASSERTIONS, ( int ) loadTest.getMaxAssertionErrors() );
57 dialog.setBooleanValue( SettingsForm.CANCEL_RUNNING, loadTest.getCancelOnReachedLimit() );
58
59 Settings settings = loadTest.getSettings();
60
61 dialog.setBooleanValue( SettingsForm.INCLUDE_REQUEST, settings.getBoolean( HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN ) );
62 dialog.setBooleanValue( SettingsForm.INCLUDE_RESPONSE, settings.getBoolean( HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN ) );
63 dialog.setBooleanValue( SettingsForm.CLOSE_CONNECTIONS, settings.getBoolean( HttpSettings.CLOSE_CONNECTIONS ) );
64
65 dialog.setValue( LogForm.LOG_FOLDER, loadTest.getStatisticsLogFolder() );
66 dialog.setIntValue( LogForm.LOG_INTERVAL, ( int ) loadTest.getStatisticsLogInterval() );
67 dialog.setBooleanValue( LogForm.LOG_ON_THREADCOUNT_CHANGE, loadTest.getLogStatisticsOnThreadChange() );
68
69 if( dialog.show() )
70 {
71 try
72 {
73 loadTest.setStartDelay( dialog.getIntValue( SettingsForm.THREAD_STARTUP_DELAY, loadTest.getStartDelay() ) );
74 loadTest.setResetStatisticsOnThreadCountChange( dialog.getBooleanValue( SettingsForm.RESET_STATISTICS ) );
75 loadTest.setCalculateTPSOnTimePassed( dialog.getBooleanValue( SettingsForm.CALC_TPS ) );
76 loadTest.setSampleInterval( dialog.getIntValue( SettingsForm.SAMPLE_INTERVAL, ( int ) loadTest.getSampleInterval() ) );
77 loadTest.setHistoryLimit( dialog.getBooleanValue( SettingsForm.DISABLE_HISTORY ) ? 0 : -1 );
78 loadTest.setMaxAssertionErrors( dialog.getIntValue( SettingsForm.MAX_ASSERTIONS, 1000 ) );
79 loadTest.setCancelOnReachedLimit( dialog.getBooleanValue( SettingsForm.CANCEL_RUNNING ) );
80
81 settings.setBoolean( HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, dialog
82 .getBooleanValue( SettingsForm.INCLUDE_REQUEST ) );
83 settings.setBoolean( HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN, dialog
84 .getBooleanValue( SettingsForm.INCLUDE_RESPONSE ) );
85 settings.setBoolean( HttpSettings.CLOSE_CONNECTIONS, dialog.getBooleanValue( SettingsForm.CLOSE_CONNECTIONS ) );
86
87 loadTest.setLogStatisticsOnThreadChange( dialog.getBooleanValue( LogForm.LOG_ON_THREADCOUNT_CHANGE ) );
88 loadTest.setStatisticsLogFolder( dialog.getValue( LogForm.LOG_FOLDER ) );
89 loadTest.setStatisticsLogInterval( dialog.getIntValue( LogForm.LOG_INTERVAL, ( int ) loadTest.getStatisticsLogInterval() ) );
90 }
91 catch( NumberFormatException ex )
92 {
93 }
94 }
95 }
96
97 private void buildDialog()
98 {
99 dialog = ADialogBuilder.buildTabbedDialog( WizardForm.class, null );
100 dialog.getFormField( SettingsForm.DISABLE_HISTORY ).addFormFieldListener( new XFormFieldListener()
101 {
102 public void valueChanged( XFormField sourceField, String newValue, String oldValue )
103 {
104 dialog.getFormField( SettingsForm.SAMPLE_INTERVAL ).setEnabled( !Boolean.parseBoolean( newValue ) );
105 }
106 } );
107 }
108
109 @AForm( description = "Set options for this LoadTest", name = "LoadTest Options", helpUrl = HelpUrls.UPDATE_INTERFACE_HELP_URL, icon = UISupport.TOOL_ICON_PATH )
110 private interface WizardForm
111 {
112 @APage( name = "Settings" )
113 public final static SettingsForm INPUT = null;
114
115 @APage( name = "Statistics Log" )
116 public final static LogForm LogForm = null;
117 }
118
119 @AForm( name = "LoadTest Options", description = "", helpUrl = HelpUrls.LOADTESTOPTIONS_HELP_URL, icon = UISupport.OPTIONS_ICON_PATH )
120 private interface SettingsForm
121 {
122 @AField( name = "Thread startup delay", description = "The delay before starting a thread in ms", type = AFieldType.INT )
123 public final static String THREAD_STARTUP_DELAY = "Thread startup delay";
124
125 @AField( name = "Reset statistics", description = "when the number of threads changes", type = AFieldType.BOOLEAN )
126 public final static String RESET_STATISTICS = "Reset statistics";
127
128 @AField( name = "Calculate TPS/BPS", description = "based on actual time passed", type = AFieldType.BOOLEAN )
129 public final static String CALC_TPS = "Calculate TPS/BPS";
130
131 @AField( name = "Include request write", description = "in calculated time", type = AFieldType.BOOLEAN )
132 public final static String INCLUDE_REQUEST = "Include request write";
133
134 @AField( name = "Include response read", description = "in calculated time", type = AFieldType.BOOLEAN )
135 public final static String INCLUDE_RESPONSE = "Include response read";
136
137 @AField( name = "Close connections", description = "between each request", type = AFieldType.BOOLEAN )
138 public final static String CLOSE_CONNECTIONS = "Close connections";
139
140 @AField( name = "Sample interval", description = "statistics sample interval in milliseconds", type = AFieldType.INT )
141 public final static String SAMPLE_INTERVAL = "Sample interval";
142
143 @AField( name = "Disable History", description = "to preserve memory (will disable diagrams)", type = AFieldType.BOOLEAN )
144 public final static String DISABLE_HISTORY = "Disable History";
145
146 @AField( name = "Max Assertions in Log", description = "the maximum number of assertion errors to keep in log (to preserve memory)", type = AFieldType.INT )
147 public final static String MAX_ASSERTIONS = "Max Assertions in Log";
148
149 @AField( name = "Cancel Running", description = "Cancel running TestCases when Limit has been reached", type = AFieldType.BOOLEAN )
150 public final static String CANCEL_RUNNING = "Cancel Running";
151 }
152
153 @AForm( name = "Logging", description = "", helpUrl = HelpUrls.LOADTESTOPTIONS_HELP_URL, icon = UISupport.OPTIONS_ICON_PATH )
154 private interface LogForm
155 {
156 @AField( name = "Log Folder", description = "The folder in which to create log files", type = AFieldType.FOLDER )
157 public final static String LOG_FOLDER = "Log Folder";
158
159 @AField( name = "Log Interval", description = "The log interval in milliseconds, 0 only logs at end", type = AFieldType.INT )
160 public final static String LOG_INTERVAL = "Log Interval";
161
162 @AField( name = "Log on ThreadCount change", description = "Log every time the number of threads changes", type = AFieldType.BOOLEAN )
163 public final static String LOG_ON_THREADCOUNT_CHANGE = "Log on ThreadCount change";
164 }
165 }