Source Code Cross Referenced for WhileController.java in  » Testing » jakarta-jmeter » org » apache » jmeter » control » 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 » Testing » jakarta jmeter » org.apache.jmeter.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.control;
020:
021:        import java.io.Serializable;
022:
023:        import org.apache.jmeter.samplers.Sampler;
024:        import org.apache.jmeter.testelement.property.JMeterProperty;
025:        import org.apache.jmeter.testelement.property.StringProperty;
026:        import org.apache.jmeter.threads.JMeterContextService;
027:        import org.apache.jmeter.threads.JMeterThread;
028:        import org.apache.jmeter.threads.JMeterVariables;
029:        import org.apache.jorphan.logging.LoggingManager;
030:        import org.apache.log.Logger;
031:
032:        // @see TestWhileController for unit tests
033:
034:        /**
035:         * @version $Revision: 595966 $
036:         */
037:        public class WhileController extends GenericController implements 
038:                Serializable {
039:            private static Logger log = LoggingManager.getLoggerForClass();
040:
041:            private final static String CONDITION = "WhileController.condition"; // $NON-NLS-1$
042:
043:            boolean testMode = false; // To make testing easier
044:
045:            boolean testModeResult = false; // dummy sample result
046:
047:            public WhileController() {
048:            }
049:
050:            /*
051:             * (non-Javadoc)
052:             * 
053:             * @see org.apache.jmeter.control.Controller#isDone()
054:             */
055:            public boolean isDone() {
056:                if (getSubControllers().size() == 0) // Nothing left to run
057:                {
058:                    return true;
059:                }
060:                return false;// Never want to remove the controller from the tree
061:            }
062:
063:            /*
064:             * Evaluate the condition, which can be: blank or LAST = was the last
065:             * sampler OK? otherwise, evaluate the condition to see if it is not "false"
066:             * If blank, only evaluate at the end of the loop
067:             * 
068:             * Must only be called at start and end of loop
069:             * 
070:             * @param loopEnd - are we at loop end? @return true means OK to continue
071:             */
072:            private boolean endOfLoop(boolean loopEnd) {
073:                String cnd = getCondition();
074:                log.debug("Condition string:" + cnd);
075:                boolean res;
076:                // If blank, only check previous sample when at end of loop
077:                if ((loopEnd && cnd.length() == 0)
078:                        || "LAST".equalsIgnoreCase(cnd)) {// $NON-NLS-1$
079:                    if (testMode) {
080:                        res = !testModeResult;
081:                    } else {
082:                        JMeterVariables threadVars = JMeterContextService
083:                                .getContext().getVariables();
084:                        // Use !false rather than true, so that null is treated as true
085:                        res = "false".equalsIgnoreCase(threadVars
086:                                .get(JMeterThread.LAST_SAMPLE_OK));// $NON-NLS-1$
087:                    }
088:                } else {
089:                    // cnd may be blank if next() called us
090:                    res = "false".equalsIgnoreCase(cnd);// $NON-NLS-1$
091:                }
092:                log.debug("Condition value: " + res);
093:                return res;
094:            }
095:
096:            /*
097:             * (non-Javadoc) Only called at End of Loop
098:             * 
099:             * @see org.apache.jmeter.control.GenericController#nextIsNull()
100:             */
101:            protected Sampler nextIsNull() throws NextIsNullException {
102:                reInitialize();
103:                if (!endOfLoop(true)) {
104:                    return super .next();
105:                }
106:                setDone(true);
107:                return null;
108:            }
109:
110:            /*
111:             * This skips controller entirely if the condition is false
112:             * 
113:             * TODO consider checking for previous sampler failure here - would need to
114:             * distinguish this from previous failure *inside* loop
115:             * 
116:             */
117:            public Sampler next() {
118:                if (current != 0) { // in the middle of the loop
119:                    return super .next();
120:                }
121:                // Must be start of loop
122:                if (!endOfLoop(false)) {
123:                    return super .next(); // OK to continue
124:                }
125:                reInitialize(); // Don't even start the loop
126:                return null;
127:            }
128:
129:            /**
130:             * @param string
131:             *            the condition to save
132:             */
133:            public void setCondition(String string) {
134:                log.debug("setCondition(" + string + ")");
135:                setProperty(new StringProperty(CONDITION, string));
136:            }
137:
138:            /**
139:             * @return the condition
140:             */
141:            public String getCondition() {
142:                String cnd;
143:                JMeterProperty prop = getProperty(CONDITION);
144:                prop.recoverRunningVersion(this );
145:                cnd = prop.getStringValue();
146:                log.debug("getCondition() => " + cnd);
147:                return cnd;
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.