Source Code Cross Referenced for PackageTest.java in  » Testing » jakarta-jmeter » org » apache » jmeter » engine » util » 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.engine.util 
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:        /*
020:         * Created on Jul 25, 2003
021:         */
022:        package org.apache.jmeter.engine.util;
023:
024:        import java.util.HashMap;
025:        import java.util.Map;
026:
027:        import junit.framework.TestCase;
028:
029:        import org.apache.jmeter.samplers.SampleResult;
030:        import org.apache.jmeter.testelement.property.JMeterProperty;
031:        import org.apache.jmeter.testelement.property.StringProperty;
032:        import org.apache.jmeter.threads.JMeterContext;
033:        import org.apache.jmeter.threads.JMeterContextService;
034:        import org.apache.jmeter.threads.JMeterVariables;
035:
036:        public class PackageTest extends TestCase {
037:            Map variables;
038:
039:            SampleResult result;
040:
041:            ReplaceStringWithFunctions transformer;
042:
043:            /**
044:             * @param arg0
045:             */
046:            public PackageTest(String arg0) {
047:                super (arg0);
048:                // TODO Auto-generated constructor stub
049:            }
050:
051:            private JMeterContext jmctx = null;
052:
053:            public void setUp() {
054:                jmctx = JMeterContextService.getContext();
055:                variables = new HashMap();
056:                variables.put("my_regex", ".*");
057:                variables.put("server", "jakarta.apache.org");
058:                result = new SampleResult();
059:                result
060:                        .setResponseData("<html>hello world</html> costs: $3.47,$5.67"
061:                                .getBytes());
062:                transformer = new ReplaceStringWithFunctions(
063:                        new CompoundVariable(), variables);
064:                jmctx.setVariables(new JMeterVariables());
065:                jmctx.setSamplingStarted(true);
066:                jmctx.setPreviousResult(result);
067:                jmctx.getVariables().put("server", "jakarta.apache.org");
068:                jmctx.getVariables().put("my_regex", ".*");
069:            }
070:
071:            public void testFunctionParse1() throws Exception {
072:                StringProperty prop = new StringProperty(
073:                        "date",
074:                        "${__javaScript((new Date().getDate() / 100).toString()."
075:                                + "substr(${__javaScript(1+1,d\\,ay)}\\,2),heute)}");
076:                JMeterProperty newProp = transformer.transformValue(prop);
077:                newProp.setRunningVersion(true);
078:                assertEquals(
079:                        "org.apache.jmeter.testelement.property.FunctionProperty",
080:                        newProp.getClass().getName());
081:                newProp.recoverRunningVersion(null);
082:                assertTrue(Integer.parseInt(newProp.getStringValue()) > -1);
083:                assertEquals("2", jmctx.getVariables().getObject("d,ay"));
084:            }
085:
086:            public void testParseExample1() throws Exception {
087:                StringProperty prop = new StringProperty("html",
088:                        "${__regexFunction(<html>(.*)</html>,$1$)}");
089:                JMeterProperty newProp = transformer.transformValue(prop);
090:                newProp.setRunningVersion(true);
091:                assertEquals(
092:                        "org.apache.jmeter.testelement.property.FunctionProperty",
093:                        newProp.getClass().getName());
094:                assertEquals("hello world", newProp.getStringValue());
095:            }
096:
097:            public void testParseExample2() throws Exception {
098:                StringProperty prop = new StringProperty("html",
099:                        "It should say:\\${${__regexFunction(<html>(.*)</html>,$1$)}}");
100:                JMeterProperty newProp = transformer.transformValue(prop);
101:                newProp.setRunningVersion(true);
102:                assertEquals(
103:                        "org.apache.jmeter.testelement.property.FunctionProperty",
104:                        newProp.getClass().getName());
105:                assertEquals("It should say:${hello world}", newProp
106:                        .getStringValue());
107:            }
108:
109:            public void testParseExample3() throws Exception {
110:                StringProperty prop = new StringProperty(
111:                        "html",
112:                        "${__regexFunction(<html>(.*)</html>,$1$)}"
113:                                + "${__regexFunction(<html>(.*o)(.*o)(.*)</html>,"
114:                                + "$1$$3$)}");
115:                JMeterProperty newProp = transformer.transformValue(prop);
116:                newProp.setRunningVersion(true);
117:                assertEquals(
118:                        "org.apache.jmeter.testelement.property.FunctionProperty",
119:                        newProp.getClass().getName());
120:                assertEquals("hello worldhellorld", newProp.getStringValue());
121:            }
122:
123:            public void testParseExample4() throws Exception {
124:                StringProperty prop = new StringProperty("html",
125:                        "${non-existing function}");
126:                JMeterProperty newProp = transformer.transformValue(prop);
127:                newProp.setRunningVersion(true);
128:                assertEquals(
129:                        "org.apache.jmeter.testelement.property.FunctionProperty",
130:                        newProp.getClass().getName());
131:                assertEquals("${non-existing function}", newProp
132:                        .getStringValue());
133:            }
134:
135:            public void testParseExample6() throws Exception {
136:                StringProperty prop = new StringProperty("html", "${server}");
137:                JMeterProperty newProp = transformer.transformValue(prop);
138:                newProp.setRunningVersion(true);
139:                assertEquals(
140:                        "org.apache.jmeter.testelement.property.FunctionProperty",
141:                        newProp.getClass().getName());
142:                assertEquals("jakarta.apache.org", newProp.getStringValue());
143:            }
144:
145:            public void testParseExample5() throws Exception {
146:                StringProperty prop = new StringProperty("html", "");
147:                JMeterProperty newProp = transformer.transformValue(prop);
148:                newProp.setRunningVersion(true);
149:                assertEquals(
150:                        "org.apache.jmeter.testelement.property.StringProperty",
151:                        newProp.getClass().getName());
152:                assertEquals("", newProp.getStringValue());
153:            }
154:
155:            public void testParseExample7() throws Exception {
156:                StringProperty prop = new StringProperty("html",
157:                        "${__regexFunction(\\<([a-z]*)\\>,$1$)}");
158:                JMeterProperty newProp = transformer.transformValue(prop);
159:                newProp.setRunningVersion(true);
160:                assertEquals(
161:                        "org.apache.jmeter.testelement.property.FunctionProperty",
162:                        newProp.getClass().getName());
163:                assertEquals("html", newProp.getStringValue());
164:            }
165:
166:            public void testParseExample8() throws Exception {
167:                StringProperty prop = new StringProperty("html",
168:                        "${__regexFunction((\\\\$\\d+\\.\\d+),$1$)}");
169:                JMeterProperty newProp = transformer.transformValue(prop);
170:                newProp.setRunningVersion(true);
171:                assertEquals(
172:                        "org.apache.jmeter.testelement.property.FunctionProperty",
173:                        newProp.getClass().getName());
174:                assertEquals("$3.47", newProp.getStringValue());
175:            }
176:
177:            public void testParseExample9() throws Exception {
178:                StringProperty prop = new StringProperty("html",
179:                        "${__regexFunction(([$]\\d+\\.\\d+),$1$)}");
180:                JMeterProperty newProp = transformer.transformValue(prop);
181:                newProp.setRunningVersion(true);
182:                assertEquals(
183:                        "org.apache.jmeter.testelement.property.FunctionProperty",
184:                        newProp.getClass().getName());
185:                assertEquals("$3.47", newProp.getStringValue());
186:            }
187:
188:            public void testParseExample10() throws Exception {
189:                StringProperty prop = new StringProperty(
190:                        "html",
191:                        "${__regexFunction(\\ "
192:                                + "(\\\\\\$\\d+\\.\\d+\\,\\\\$\\d+\\.\\d+),$1$)}");
193:                JMeterProperty newProp = transformer.transformValue(prop);
194:                newProp.setRunningVersion(true);
195:                assertEquals(
196:                        "org.apache.jmeter.testelement.property.FunctionProperty",
197:                        newProp.getClass().getName());
198:                assertEquals("$3.47,$5.67", newProp.getStringValue());
199:            }
200:
201:            public void testNestedExample1() throws Exception {
202:                StringProperty prop = new StringProperty("html",
203:                        "${__regexFunction(<html>(${my_regex})</html>,"
204:                                + "$1$)}${__regexFunction(<html>(.*o)(.*o)(.*)"
205:                                + "</html>,$1$$3$)}");
206:                JMeterProperty newProp = transformer.transformValue(prop);
207:                newProp.setRunningVersion(true);
208:                assertEquals(
209:                        "org.apache.jmeter.testelement.property.FunctionProperty",
210:                        newProp.getClass().getName());
211:                assertEquals("hello worldhellorld", newProp.getStringValue());
212:            }
213:
214:            public void testNestedExample2() throws Exception {
215:                StringProperty prop = new StringProperty("html",
216:                        "${__regexFunction(<html>(${my_regex})</html>,$1$)}");
217:                JMeterProperty newProp = transformer.transformValue(prop);
218:                newProp.setRunningVersion(true);
219:                assertEquals(
220:                        "org.apache.jmeter.testelement.property.FunctionProperty",
221:                        newProp.getClass().getName());
222:                assertEquals("hello world", newProp.getStringValue());
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.