Source Code Cross Referenced for BurstLoadStrategy.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.JTextField;
019:        import javax.swing.text.Document;
020:
021:        import org.apache.xmlbeans.XmlObject;
022:
023:        import com.eviware.soapui.SoapUI;
024:        import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTestRunner;
025:        import com.eviware.soapui.model.testsuite.LoadTestRunContext;
026:        import com.eviware.soapui.model.testsuite.LoadTestRunner;
027:        import com.eviware.soapui.model.testsuite.TestRunContext;
028:        import com.eviware.soapui.model.testsuite.TestRunner;
029:        import com.eviware.soapui.support.DocumentListenerAdapter;
030:        import com.eviware.soapui.support.UISupport;
031:        import com.eviware.soapui.support.xml.XmlObjectConfigurationBuilder;
032:        import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
033:        import com.jgoodies.forms.builder.ButtonBarBuilder;
034:
035:        /**
036:         * Burst LoadStrategy that pauses for a certain amount of time
037:         * 
038:         * @author Ole.Matzura
039:         */
040:
041:        public class BurstLoadStrategy extends AbstractLoadStrategy {
042:            private static final String BURST_DURATION_ELEMENT = "burstDuration";
043:            private static final String BURST_DELAY_ELEMENT = "burstDelay";
044:            private static final int DEFAULT_BURST_DURATION = 10000;
045:            private static final int DEFAULT_BURST_DELAY = 60000;
046:            private static final int SLEEP_DELAY = 500;
047:            public static final String STRATEGY_TYPE = "Burst";
048:            private JPanel configPanel;
049:
050:            private int burstDelay = DEFAULT_BURST_DELAY;
051:            private int burstDuration = DEFAULT_BURST_DURATION;
052:            private long startTime;
053:            private JTextField delayField;
054:            private JTextField durationField;
055:            private JLabel infoLabel = new JLabel();
056:
057:            public BurstLoadStrategy() {
058:                super (STRATEGY_TYPE);
059:
060:                burstDelay = DEFAULT_BURST_DELAY;
061:                burstDuration = DEFAULT_BURST_DURATION;
062:            }
063:
064:            public BurstLoadStrategy(XmlObject config) {
065:                super (STRATEGY_TYPE);
066:
067:                XmlObjectConfigurationReader reader = new XmlObjectConfigurationReader(
068:                        config);
069:                burstDelay = reader.readInt(BURST_DELAY_ELEMENT,
070:                        DEFAULT_BURST_DELAY);
071:                burstDuration = reader.readInt(BURST_DURATION_ELEMENT,
072:                        DEFAULT_BURST_DURATION);
073:            }
074:
075:            public void beforeLoadTest(LoadTestRunner loadTestRunner,
076:                    LoadTestRunContext context) {
077:                startTime = System.currentTimeMillis();
078:                infoLabel.setText("starting..");
079:            }
080:
081:            public void beforeTestCase(LoadTestRunner loadTestRunner,
082:                    LoadTestRunContext context, TestRunner testRunner,
083:                    TestRunContext runContext) {
084:                // get time passed since start of test
085:                long timePassed = System.currentTimeMillis() - startTime;
086:
087:                // wait during burstDelay period
088:                long mod = timePassed % (burstDelay + burstDuration);
089:                while ((mod < burstDelay)
090:                        && (testRunner.getStatus() == TestRunner.Status.RUNNING || testRunner
091:                                .getStatus() == TestRunner.Status.INITIALIZED)) {
092:                    try {
093:                        String label = (burstDelay - mod) / 1000
094:                                + "s delay left";
095:                        if (!infoLabel.getText().equals(label))
096:                            infoLabel.setText(label);
097:
098:                        Thread.sleep(SLEEP_DELAY);
099:                        if (((WsdlLoadTestRunner) loadTestRunner).getProgress() >= 1) {
100:                            infoLabel.setText("");
101:                            return;
102:                        }
103:
104:                        timePassed = System.currentTimeMillis() - startTime;
105:                        mod = timePassed % (burstDelay + burstDuration);
106:                    } catch (InterruptedException e) {
107:                        SoapUI.logError(e);
108:                    }
109:                }
110:
111:                if (testRunner.getStatus() == TestRunner.Status.RUNNING) {
112:                    String label = ((burstDelay + burstDuration) - mod) / 1000
113:                            + "s burst left";
114:                    if (!infoLabel.getText().equals(label))
115:                        infoLabel.setText(label);
116:                }
117:            }
118:
119:            public void afterLoadTest(LoadTestRunner loadTestRunner,
120:                    LoadTestRunContext context) {
121:                infoLabel.setText("");
122:            }
123:
124:            public JComponent getConfigurationPanel() {
125:                if (configPanel == null) {
126:                    ButtonBarBuilder builder = new ButtonBarBuilder();
127:
128:                    delayField = new JTextField(4);
129:                    UISupport.setPreferredHeight(delayField, 18);
130:                    delayField.setHorizontalAlignment(JTextField.RIGHT);
131:                    delayField.setText(String.valueOf(burstDelay / 1000));
132:                    delayField
133:                            .setToolTipText("Sets the delay before each burst run in seconds");
134:                    delayField.getDocument().addDocumentListener(
135:                            new DocumentListenerAdapter() {
136:
137:                                public void update(Document doc) {
138:                                    try {
139:                                        burstDelay = Integer
140:                                                .parseInt(delayField.getText()) * 1000;
141:                                        notifyConfigurationChanged();
142:                                    } catch (NumberFormatException e) {
143:                                    }
144:                                }
145:                            });
146:
147:                    builder.addFixed(new JLabel("Burst Delay"));
148:                    builder.addRelatedGap();
149:
150:                    builder.addFixed(delayField);
151:                    builder.addRelatedGap();
152:
153:                    durationField = new JTextField(4);
154:                    UISupport.setPreferredHeight(durationField, 18);
155:                    durationField.setHorizontalAlignment(JTextField.RIGHT);
156:                    durationField.setText(String.valueOf(burstDuration / 1000));
157:                    durationField
158:                            .setToolTipText("Specifies the duration of a burst run in seconds");
159:                    durationField.getDocument().addDocumentListener(
160:                            new DocumentListenerAdapter() {
161:
162:                                public void update(Document doc) {
163:                                    try {
164:                                        burstDuration = Integer
165:                                                .parseInt(durationField
166:                                                        .getText()) * 1000;
167:                                        notifyConfigurationChanged();
168:                                    } catch (NumberFormatException e) {
169:                                    }
170:                                }
171:                            });
172:
173:                    builder.addFixed(new JLabel("Burst Duration"));
174:                    builder.addRelatedGap();
175:                    builder.addFixed(durationField);
176:                    builder.addRelatedGap();
177:                    builder.addFixed(infoLabel);
178:
179:                    configPanel = builder.getPanel();
180:                }
181:
182:                return configPanel;
183:            }
184:
185:            public XmlObject getConfig() {
186:                XmlObjectConfigurationBuilder builder = new XmlObjectConfigurationBuilder();
187:                builder.add(BURST_DELAY_ELEMENT, burstDelay);
188:                builder.add(BURST_DURATION_ELEMENT, burstDuration);
189:                return builder.finish();
190:            }
191:
192:            /**
193:             * Factory for BurstLoadStrategy class
194:             * 
195:             * @author Ole.Matzura
196:             */
197:
198:            public static class Factory implements  LoadStrategyFactory {
199:                public String getType() {
200:                    return STRATEGY_TYPE;
201:                }
202:
203:                public LoadStrategy build(XmlObject config) {
204:                    return new BurstLoadStrategy(config);
205:                }
206:
207:                public LoadStrategy create() {
208:                    return new BurstLoadStrategy();
209:                }
210:            }
211:        }
w__ww__.__j__a___va___2__s.c__o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.