Source Code Cross Referenced for AbstractLoadTestAssertion.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » loadtest » assertions » 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.assertions 
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.assertions;
014:
015:        import java.awt.event.ActionEvent;
016:        import java.beans.PropertyChangeEvent;
017:        import java.beans.PropertyChangeListener;
018:        import java.beans.PropertyChangeSupport;
019:
020:        import javax.swing.AbstractAction;
021:        import javax.swing.Action;
022:        import javax.swing.ImageIcon;
023:
024:        import org.apache.log4j.Logger;
025:        import org.apache.xmlbeans.XmlObject;
026:
027:        import com.eviware.soapui.config.LoadTestAssertionConfig;
028:        import com.eviware.soapui.impl.wsdl.loadtest.LoadTestAssertion;
029:        import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
030:        import com.eviware.soapui.impl.wsdl.support.Configurable;
031:        import com.eviware.soapui.model.support.ModelSupport;
032:        import com.eviware.soapui.model.support.TestSuiteListenerAdapter;
033:        import com.eviware.soapui.model.testsuite.LoadTestRunContext;
034:        import com.eviware.soapui.model.testsuite.LoadTestRunner;
035:        import com.eviware.soapui.model.testsuite.TestStep;
036:        import com.eviware.soapui.support.UISupport;
037:
038:        /**
039:         * Base class for LoadTestAssertions
040:         * 
041:         * @author Ole.Matzura
042:         */
043:
044:        public abstract class AbstractLoadTestAssertion implements 
045:                LoadTestAssertion {
046:            private LoadTestAssertionConfig assertionConfig;
047:            @SuppressWarnings("unused")
048:            private final static Logger log = Logger
049:                    .getLogger(AbstractLoadTestAssertion.class);
050:            private ImageIcon icon;
051:            private final WsdlLoadTest loadTest;
052:            private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
053:                    this );
054:            private String testStepName;
055:            private TestStep testStep;
056:            private TestStepPropertyChangeListener testStepPropertyChangeListener = new TestStepPropertyChangeListener();
057:            private InternalTestSuiteListener testSuiteListener = new InternalTestSuiteListener();
058:
059:            protected static final String TEST_STEP_ELEMENT = "test-step";
060:            protected static final String TEST_STEP_FIELD = "TestStep";
061:
062:            public AbstractLoadTestAssertion(
063:                    LoadTestAssertionConfig assertionConfig,
064:                    WsdlLoadTest loadTest) {
065:                this .assertionConfig = assertionConfig;
066:                this .loadTest = loadTest;
067:
068:                loadTest.getTestCase().getTestSuite().addTestSuiteListener(
069:                        testSuiteListener);
070:            }
071:
072:            public void initIcon(String url) {
073:                icon = UISupport.createImageIcon(url);
074:            }
075:
076:            public LoadTestAssertionConfig getConfiguration() {
077:                return assertionConfig;
078:            }
079:
080:            public void updateConfiguration(
081:                    LoadTestAssertionConfig configuration) {
082:                assertionConfig = configuration;
083:            }
084:
085:            protected void setConfiguration(XmlObject configuration) {
086:                XmlObject oldConfig = assertionConfig.getConfiguration();
087:                assertionConfig.setConfiguration(configuration);
088:                propertyChangeSupport.firePropertyChange(
089:                        AbstractLoadTestAssertion.CONFIGURATION_PROPERTY,
090:                        oldConfig, configuration);
091:            }
092:
093:            public String getName() {
094:                return assertionConfig.isSetName() ? assertionConfig.getName()
095:                        : assertionConfig.getType();
096:            }
097:
098:            public void setName(String name) {
099:                String old = getName();
100:                assertionConfig.setName(name);
101:                propertyChangeSupport.firePropertyChange(NAME_PROPERTY, old,
102:                        name);
103:            }
104:
105:            public WsdlLoadTest getLoadTest() {
106:                return loadTest;
107:            }
108:
109:            public class RenameAssertionAction extends AbstractAction {
110:                public RenameAssertionAction() {
111:                    super ("Rename");
112:                    putValue(Action.SHORT_DESCRIPTION, "Renames this assertion");
113:                }
114:
115:                public void actionPerformed(ActionEvent e) {
116:                    String name = UISupport.prompt(
117:                            "Specify name for this assertion",
118:                            "Rename Assertion", AbstractLoadTestAssertion.this 
119:                                    .getName());
120:                    if (name == null
121:                            || name.equals(AbstractLoadTestAssertion.this 
122:                                    .getName()))
123:                        return;
124:
125:                    setName(name);
126:                }
127:            }
128:
129:            public class ConfigureAssertionAction extends AbstractAction {
130:                public ConfigureAssertionAction() {
131:                    super ("Configure");
132:                    putValue(Action.SHORT_DESCRIPTION,
133:                            "Configures this assertion");
134:                }
135:
136:                public void actionPerformed(ActionEvent e) {
137:                    ((Configurable) AbstractLoadTestAssertion.this ).configure();
138:                }
139:            }
140:
141:            public ImageIcon getIcon() {
142:                return icon;
143:            }
144:
145:            public void addPropertyChangeListener(
146:                    PropertyChangeListener listener) {
147:                propertyChangeSupport.addPropertyChangeListener(listener);
148:            }
149:
150:            public void addPropertyChangeListener(String propertyName,
151:                    PropertyChangeListener listener) {
152:                propertyChangeSupport.addPropertyChangeListener(propertyName,
153:                        listener);
154:            }
155:
156:            public void removePropertyChangeListener(
157:                    PropertyChangeListener listener) {
158:                propertyChangeSupport.removePropertyChangeListener(listener);
159:            }
160:
161:            public void removePropertyChangeListener(String propertyName,
162:                    PropertyChangeListener listener) {
163:                propertyChangeSupport.removePropertyChangeListener(
164:                        propertyName, listener);
165:            }
166:
167:            protected String returnErrorOrFail(String message, int maxErrors,
168:                    LoadTestRunner testRunner, LoadTestRunContext context) {
169:                String propertyKey = getClass().getName() + hashCode();
170:                Long errorCount = (Long) context.getProperty(propertyKey);
171:
172:                if (errorCount == null) {
173:                    errorCount = 1L;
174:                } else {
175:                    errorCount = new Long(errorCount.longValue() + 1);
176:                }
177:
178:                if (maxErrors >= 0 && errorCount >= maxErrors) {
179:                    testRunner.fail("Maximum number of errors [" + maxErrors
180:                            + "] for assertion [" + getName() + "] exceeded");
181:                }
182:
183:                context.setProperty(propertyKey, errorCount);
184:
185:                return message;
186:            }
187:
188:            public String getTargetStep() {
189:                return testStepName;
190:            }
191:
192:            public void setTargetStep(String name) {
193:                testStepName = name;
194:                initTestStep();
195:            }
196:
197:            abstract protected void updateConfiguration();
198:
199:            protected boolean targetStepMatches(TestStep testStep) {
200:                return testStepName == null
201:                        || testStepName.equals(ANY_TEST_STEP)
202:                        || testStep.getName().equals(testStepName);
203:            }
204:
205:            protected String[] getTargetStepOptions(boolean includeAll) {
206:                if (includeAll)
207:                    return ModelSupport.getNames(new String[] { ANY_TEST_STEP,
208:                            ALL_TEST_STEPS }, getLoadTest().getTestCase()
209:                            .getTestStepList());
210:                else
211:                    return ModelSupport.getNames(
212:                            new String[] { ANY_TEST_STEP }, getLoadTest()
213:                                    .getTestCase().getTestStepList());
214:            }
215:
216:            private void initTestStep() {
217:                if (testStep != null) {
218:                    testStep
219:                            .removePropertyChangeListener(testStepPropertyChangeListener);
220:                }
221:
222:                testStep = getLoadTest().getTestCase().getTestStepByName(
223:                        testStepName);
224:                if (testStep != null) {
225:                    testStep.addPropertyChangeListener(TestStep.NAME_PROPERTY,
226:                            testStepPropertyChangeListener);
227:                }
228:            }
229:
230:            public void release() {
231:                if (testStep != null) {
232:                    testStep
233:                            .removePropertyChangeListener(testStepPropertyChangeListener);
234:                    loadTest.getTestCase().getTestSuite()
235:                            .removeTestSuiteListener(testSuiteListener);
236:                }
237:            }
238:
239:            private final class InternalTestSuiteListener extends
240:                    TestSuiteListenerAdapter {
241:                public void testStepRemoved(TestStep removedTestStep, int index) {
242:                    if (removedTestStep.getName().equals(testStepName)
243:                            && removedTestStep.getTestCase() == testStep
244:                                    .getTestCase()) {
245:                        testStepName = ANY_TEST_STEP;
246:                        updateConfiguration();
247:                    }
248:                }
249:            }
250:
251:            private final class TestStepPropertyChangeListener implements 
252:                    PropertyChangeListener {
253:                public void propertyChange(PropertyChangeEvent evt) {
254:                    testStepName = evt.getNewValue().toString();
255:                    updateConfiguration();
256:                }
257:            }
258:        }
w_ww_._j___a_v_a_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.