Source Code Cross Referenced for ParamModifier.java in  » Testing » jakarta-jmeter » org » apache » jmeter » protocol » http » modifier » 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.protocol.http.modifier 
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.protocol.http.modifier;
020:
021:        import java.io.Serializable;
022:
023:        import org.apache.jmeter.config.Argument;
024:        import org.apache.jmeter.engine.event.LoopIterationEvent;
025:        import org.apache.jmeter.processor.PreProcessor;
026:        import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
027:        import org.apache.jmeter.samplers.Sampler;
028:        import org.apache.jmeter.testelement.AbstractTestElement;
029:        import org.apache.jmeter.testelement.TestListener;
030:        import org.apache.jmeter.testelement.property.PropertyIterator;
031:        import org.apache.jmeter.testelement.property.TestElementProperty;
032:
033:        /**
034:         * This modifier will replace any single http sampler's url parameter value with
035:         * a value from a given range - thereby "masking" the value set in the http
036:         * sampler. The parameter names must match exactly, and the parameter value must
037:         * be preset to "*" to diferentiate between duplicate parameter names.
038:         * <P>
039:         * For example, if you set up the modifier with a lower bound of 1, an upper
040:         * bound of 10, and an increment of 2, and run the loop 12 times, the parameter
041:         * will have the following values (one per loop): 1, 3, 5, 7, 9, 1, 3, 5, 7, 9,
042:         * 1, 3
043:         * <P>
044:         * The {@link ParamMask} object contains most of the logic for stepping through
045:         * this loop. You can make large modifications to this modifier's behaviour by
046:         * changing one or two method implementations there.
047:         * 
048:         * @author David La France
049:         * @see ParamMask
050:         * @version $Revision: 493789 $ updated on $Date: 2007-01-07 18:10:21 +0000 (Sun, 07 Jan 2007) $
051:         */
052:        public class ParamModifier extends AbstractTestElement implements 
053:                TestListener, PreProcessor, Serializable {
054:
055:            /*
056:             * ------------------------------------------------------------------------
057:             * Fields
058:             * ------------------------------------------------------------------------
059:             */
060:
061:            /**
062:             * The key used to find the ParamMask object in the HashMap.
063:             */
064:            private final static String MASK = "ParamModifier.mask";
065:
066:            /*
067:             * ------------------------------------------------------------------------
068:             * Constructors
069:             * ------------------------------------------------------------------------
070:             */
071:
072:            /**
073:             * Default constructor.
074:             */
075:            public ParamModifier() {
076:                setProperty(new TestElementProperty(MASK, new ParamMask()));
077:            }
078:
079:            public ParamMask getMask() {
080:                return (ParamMask) getProperty(MASK).getObjectValue();
081:            }
082:
083:            public void testStarted() {
084:                getMask().resetValue();
085:            }
086:
087:            public void testStarted(String host) {
088:                getMask().resetValue();
089:            }
090:
091:            public void testEnded() {
092:            }
093:
094:            public void testEnded(String host) {
095:            }
096:
097:            /*
098:             * ------------------------------------------------------------------------
099:             * Methods implemented from interface org.apache.jmeter.config.Modifier
100:             * ------------------------------------------------------------------------
101:             */
102:
103:            /**
104:             * Modifies an entry object to replace the value of any url parameter that
105:             * matches a defined mask.
106:             * 
107:             */
108:            public void process() {
109:                Sampler sam = getThreadContext().getCurrentSampler();
110:                HTTPSamplerBase sampler = null;
111:                if (!(sam instanceof  HTTPSamplerBase)) {
112:                    return;
113:                } else {
114:                    sampler = (HTTPSamplerBase) sam;
115:                }
116:                boolean modified = false;
117:                PropertyIterator iter = sampler.getArguments().iterator();
118:                while (iter.hasNext()) {
119:                    Argument arg = (Argument) iter.next().getObjectValue();
120:                    modified = modifyArgument(arg);
121:                    if (modified) {
122:                        break;
123:                    }
124:                }
125:            }
126:
127:            /*
128:             * ------------------------------------------------------------------------
129:             * Methods
130:             * ------------------------------------------------------------------------
131:             */
132:
133:            /**
134:             * Helper method for {@link #modifyEntry} Replaces a parameter's value if
135:             * the parameter name matches the mask name and the value is a '*'.
136:             * 
137:             * @param arg
138:             *            an {@link Argument} representing a http parameter
139:             * @return <code>true</code>if the value was replaced
140:             */
141:            private boolean modifyArgument(Argument arg) {
142:                // if a mask for this argument exists
143:                if (arg.getName().equals(getMask().getFieldName())) {
144:                    // values to be masked must be set in the WebApp to "*"
145:                    if ("*".equals(arg.getValue())) {
146:                        arg.setValue(getMask().getNextValue());
147:                        return true;
148:                    }
149:                }
150:                return false;
151:            }
152:
153:            /**
154:             * @see TestListener#testIterationStart(LoopIterationEvent)
155:             */
156:            public void testIterationStart(LoopIterationEvent event) {
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.