Source Code Cross Referenced for ThreadCountChangeLoadStrategy.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » loadtest » strategy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.loadtest.strategy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.loadtest.strategy;
014:
015:        import javax.swing.JComponent;
016:        import javax.swing.JLabel;
017:        import javax.swing.JPanel;
018:        import javax.swing.JSpinner;
019:        import javax.swing.SpinnerNumberModel;
020:        import javax.swing.event.ChangeEvent;
021:        import javax.swing.event.ChangeListener;
022:
023:        import org.apache.log4j.Logger;
024:        import org.apache.xmlbeans.XmlObject;
025:
026:        import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
027:        import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTestRunner;
028:        import com.eviware.soapui.model.testsuite.LoadTestRunContext;
029:        import com.eviware.soapui.model.testsuite.LoadTestRunner;
030:        import com.eviware.soapui.model.testsuite.TestRunContext;
031:        import com.eviware.soapui.model.testsuite.TestRunner;
032:        import com.eviware.soapui.support.UISupport;
033:        import com.eviware.soapui.support.swing.ComponentBag;
034:        import com.eviware.soapui.support.xml.XmlObjectConfigurationBuilder;
035:        import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
036:        import com.jgoodies.forms.builder.ButtonBarBuilder;
037:
038:        /**
039:         * LoadStrategy allowing maximum runs and request delays
040:         * 
041:         * @author Ole.Matzura
042:         */
043:
044:        public class ThreadCountChangeLoadStrategy extends AbstractLoadStrategy {
045:            private final static Logger log = Logger
046:                    .getLogger(ThreadCountChangeLoadStrategy.class);
047:
048:            private static final int DEFAULT_END_THREAD_COUNT = 10;
049:            private static final int DEFAULT_START_THREAD_COUNT = 1;
050:            public static final String STRATEGY_TYPE = "Thread";
051:
052:            private int startThreadCount = DEFAULT_START_THREAD_COUNT;
053:            private int endThreadCount = DEFAULT_END_THREAD_COUNT;
054:
055:            private JPanel configPanel;
056:            private ComponentBag stateDependantComponents = new ComponentBag();
057:
058:            private SpinnerNumberModel startThreadCountSpinnerNumberModel;
059:            private JSpinner startThreadCountSpinner;
060:            private SpinnerNumberModel endThreadCountSpinnerNumberModel;
061:            private JSpinner endThreadCountSpinner;
062:
063:            public ThreadCountChangeLoadStrategy(XmlObject config) {
064:                super (STRATEGY_TYPE);
065:
066:                if (config != null) {
067:                    XmlObjectConfigurationReader reader = new XmlObjectConfigurationReader(
068:                            config);
069:                    startThreadCount = reader.readInt("startThreadCount",
070:                            DEFAULT_START_THREAD_COUNT);
071:                    endThreadCount = reader.readInt("endThreadCount",
072:                            DEFAULT_END_THREAD_COUNT);
073:                }
074:            }
075:
076:            public XmlObject getConfig() {
077:                XmlObjectConfigurationBuilder builder = new XmlObjectConfigurationBuilder();
078:                builder.add("startThreadCount", startThreadCount);
079:                builder.add("endThreadCount", endThreadCount);
080:                return builder.finish();
081:            }
082:
083:            public void beforeLoadTest(LoadTestRunner loadTestRunner,
084:                    LoadTestRunContext context) {
085:                stateDependantComponents.setEnabled(false);
086:
087:                WsdlLoadTest wsdlLoadTest = ((WsdlLoadTest) loadTestRunner
088:                        .getLoadTest());
089:                wsdlLoadTest.setThreadCount(startThreadCount);
090:            }
091:
092:            public void afterLoadTest(LoadTestRunner loadTestRunner,
093:                    LoadTestRunContext context) {
094:                stateDependantComponents.setEnabled(true);
095:            }
096:
097:            public boolean allowThreadCountChangeDuringRun() {
098:                return false;
099:            }
100:
101:            public void beforeTestCase(LoadTestRunner loadTestRunner,
102:                    LoadTestRunContext context, TestRunner testRunner,
103:                    TestRunContext runContext) {
104:                // calculate thread count
105:                WsdlLoadTestRunner runner = (WsdlLoadTestRunner) loadTestRunner;
106:                float progress = runner.getProgress();
107:                if ((int) progress != -1) {
108:                    WsdlLoadTest wsdlLoadTest = ((WsdlLoadTest) loadTestRunner
109:                            .getLoadTest());
110:                    synchronized (wsdlLoadTest) {
111:                        int newThreadCount = (int) (startThreadCount + (progress
112:                                * (endThreadCount - startThreadCount) + 0.5));
113:                        if (newThreadCount != wsdlLoadTest.getThreadCount()) {
114:                            log.debug("Changing threadcount to "
115:                                    + newThreadCount + ", progress = "
116:                                    + progress);
117:                            wsdlLoadTest.setThreadCount(newThreadCount);
118:                        }
119:                    }
120:                }
121:            }
122:
123:            public JComponent getConfigurationPanel() {
124:                if (configPanel == null) {
125:                    ButtonBarBuilder builder = new ButtonBarBuilder();
126:
127:                    startThreadCountSpinnerNumberModel = new SpinnerNumberModel(
128:                            startThreadCount, 1, 10000, 1);
129:                    startThreadCountSpinner = new JSpinner(
130:                            startThreadCountSpinnerNumberModel);
131:                    UISupport.setPreferredHeight(startThreadCountSpinner, 18);
132:                    startThreadCountSpinner
133:                            .setToolTipText("Sets the initial thread-count");
134:                    startThreadCountSpinnerNumberModel
135:                            .addChangeListener(new ChangeListener() {
136:
137:                                public void stateChanged(ChangeEvent e) {
138:                                    startThreadCount = startThreadCountSpinnerNumberModel
139:                                            .getNumber().intValue();
140:                                    notifyConfigurationChanged();
141:                                }
142:                            });
143:
144:                    builder.addFixed(new JLabel("Start Threads"));
145:                    builder.addRelatedGap();
146:
147:                    builder.addFixed(startThreadCountSpinner);
148:                    builder.addRelatedGap();
149:
150:                    endThreadCountSpinnerNumberModel = new SpinnerNumberModel(
151:                            endThreadCount, 1, 10000, 1);
152:                    endThreadCountSpinner = new JSpinner(
153:                            endThreadCountSpinnerNumberModel);
154:                    UISupport.setPreferredHeight(endThreadCountSpinner, 18);
155:                    endThreadCountSpinner
156:                            .setToolTipText("Sets the final thread-count");
157:                    endThreadCountSpinnerNumberModel
158:                            .addChangeListener(new ChangeListener() {
159:
160:                                public void stateChanged(ChangeEvent e) {
161:                                    endThreadCount = endThreadCountSpinnerNumberModel
162:                                            .getNumber().intValue();
163:                                    notifyConfigurationChanged();
164:                                }
165:                            });
166:
167:                    builder.addFixed(new JLabel("End Threads"));
168:                    builder.addRelatedGap();
169:                    builder.addFixed(endThreadCountSpinner);
170:
171:                    configPanel = builder.getPanel();
172:
173:                    stateDependantComponents.add(startThreadCountSpinner);
174:                    stateDependantComponents.add(endThreadCountSpinner);
175:                }
176:
177:                return configPanel;
178:            }
179:
180:            /**
181:             * Factory for ThreadCountChangeLoadStrategy class
182:             * 
183:             * @author Ole.Matzura
184:             */
185:
186:            public static class Factory implements  LoadStrategyFactory {
187:                public String getType() {
188:                    return STRATEGY_TYPE;
189:                }
190:
191:                public LoadStrategy build(XmlObject config) {
192:                    return new ThreadCountChangeLoadStrategy(config);
193:                }
194:
195:                public LoadStrategy create() {
196:                    return new ThreadCountChangeLoadStrategy(null);
197:                }
198:            }
199:        }
w_w___w___.___j___a__v_a__2__s___._com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.