Source Code Cross Referenced for PackageTest.java in  » Testing » jakarta-jmeter » org » apache » jmeter » testelement » property » 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.testelement.property 
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.testelement.property;
020:
021:        import junit.framework.TestCase;
022:
023:        import org.apache.jmeter.config.LoginConfig;
024:
025:        /**
026:         * Class for testing the property package.
027:         */
028:        public class PackageTest extends TestCase {
029:
030:            public PackageTest(String name) {
031:                super (name);
032:            }
033:
034:            public void testStringProperty() throws Exception {
035:                StringProperty prop = new StringProperty("name", "value");
036:                prop.setRunningVersion(true);
037:                prop.setObjectValue("new Value");
038:                assertEquals("new Value", prop.getStringValue());
039:                prop.recoverRunningVersion(null);
040:                assertEquals("value", prop.getStringValue());
041:                prop.setObjectValue("new Value");
042:                prop.setObjectValue("2nd Value");
043:                assertEquals("2nd Value", prop.getStringValue());
044:                prop.recoverRunningVersion(null);
045:                assertEquals("value", prop.getStringValue());
046:            }
047:
048:            public void testElementProperty() throws Exception {
049:                LoginConfig config = new LoginConfig();
050:                config.setUsername("username");
051:                config.setPassword("password");
052:                TestElementProperty prop = new TestElementProperty("name",
053:                        config);
054:                prop.setRunningVersion(true);
055:                config = new LoginConfig();
056:                config.setUsername("user2");
057:                config.setPassword("pass2");
058:                prop.setObjectValue(config);
059:                assertEquals("user2=pass2", prop.getStringValue());
060:                prop.recoverRunningVersion(null);
061:                assertEquals("username=password", prop.getStringValue());
062:                config = new LoginConfig();
063:                config.setUsername("user2");
064:                config.setPassword("pass2");
065:                prop.setObjectValue(config);
066:                config = new LoginConfig();
067:                config.setUsername("user3");
068:                config.setPassword("pass3");
069:                prop.setObjectValue(config);
070:                assertEquals("user3=pass3", prop.getStringValue());
071:                prop.recoverRunningVersion(null);
072:                assertEquals("username=password", prop.getStringValue());
073:            }
074:
075:            private void checkEquals(JMeterProperty jp1, JMeterProperty jp2) {
076:                assertEquals(jp1, jp2);
077:                assertEquals(jp2, jp1);
078:                assertEquals(jp1, jp1);
079:                assertEquals(jp2, jp2);
080:                assertEquals(jp1.hashCode(), jp2.hashCode());
081:
082:            }
083:
084:            private void checkNotEquals(JMeterProperty jp1, JMeterProperty jp2) {
085:                assertEquals(jp1, jp1);
086:                assertEquals(jp2, jp2);
087:                assertFalse(jp1.equals(jp2));
088:                assertFalse(jp2.equals(jp1));
089:                // Not an absolute requirement:
090:                if (jp1.hashCode() == jp2.hashCode()) {
091:                    System.out.println("Expected different hashCodes for "
092:                            + jp1.getClass().getName());
093:
094:                }
095:
096:            }
097:
098:            public void testBooleanEquality() throws Exception {
099:                BooleanProperty jpn1 = new BooleanProperty();
100:                BooleanProperty jpn2 = new BooleanProperty();
101:                BooleanProperty jp1 = new BooleanProperty("name1", true);
102:                BooleanProperty jp2 = new BooleanProperty("name1", true);
103:                BooleanProperty jp3 = new BooleanProperty("name2", true);
104:                BooleanProperty jp4 = new BooleanProperty("name2", false);
105:                checkEquals(jpn1, jpn2);
106:                checkNotEquals(jpn1, jp1);
107:                checkNotEquals(jpn1, jp2);
108:                checkEquals(jp1, jp2);
109:                checkNotEquals(jp1, jp3);
110:                checkNotEquals(jp2, jp3);
111:                checkNotEquals(jp3, jp4);
112:            }
113:
114:            public void testDoubleEquality() throws Exception {
115:                DoubleProperty jpn1 = new DoubleProperty();
116:                DoubleProperty jpn2 = new DoubleProperty();
117:                DoubleProperty jp1 = new DoubleProperty("name1", 123.4);
118:                DoubleProperty jp2 = new DoubleProperty("name1", 123.4);
119:                DoubleProperty jp3 = new DoubleProperty("name2", -123.4);
120:                DoubleProperty jp4 = new DoubleProperty("name2", 123.4);
121:                DoubleProperty jp5 = new DoubleProperty("name2",
122:                        Double.NEGATIVE_INFINITY);
123:                DoubleProperty jp6 = new DoubleProperty("name2",
124:                        Double.NEGATIVE_INFINITY);
125:                DoubleProperty jp7 = new DoubleProperty("name2",
126:                        Double.POSITIVE_INFINITY);
127:                DoubleProperty jp8 = new DoubleProperty("name2",
128:                        Double.POSITIVE_INFINITY);
129:                DoubleProperty jp9 = new DoubleProperty("name2", Double.NaN);
130:                DoubleProperty jp10 = new DoubleProperty("name2", Double.NaN);
131:                DoubleProperty jp11 = new DoubleProperty("name1", Double.NaN);
132:                DoubleProperty jp12 = new DoubleProperty("name1",
133:                        Double.MIN_VALUE);
134:                DoubleProperty jp13 = new DoubleProperty("name2",
135:                        Double.MIN_VALUE);
136:                DoubleProperty jp14 = new DoubleProperty("name2",
137:                        Double.MIN_VALUE);
138:                DoubleProperty jp15 = new DoubleProperty("name1",
139:                        Double.MAX_VALUE);
140:                DoubleProperty jp16 = new DoubleProperty("name2",
141:                        Double.MAX_VALUE);
142:                DoubleProperty jp17 = new DoubleProperty("name2",
143:                        Double.MAX_VALUE);
144:                checkEquals(jpn1, jpn2);
145:                checkNotEquals(jpn1, jp1);
146:                checkNotEquals(jpn1, jp2);
147:                checkEquals(jp1, jp2);
148:                checkNotEquals(jp1, jp3);
149:                checkNotEquals(jp2, jp3);
150:                checkNotEquals(jp3, jp4);
151:                checkEquals(jp5, jp6);
152:                checkNotEquals(jp3, jp6);
153:                checkEquals(jp7, jp8);
154:                checkNotEquals(jp4, jp7);
155:                checkNotEquals(jp8, jp9);
156:                checkEquals(jp9, jp10);
157:                checkNotEquals(jp10, jp11);
158:                checkNotEquals(jp5, jp10);
159:                checkNotEquals(jp12, jp14);
160:                checkEquals(jp13, jp14);
161:                checkNotEquals(jp15, jp16);
162:                checkEquals(jp16, jp17);
163:            }
164:
165:            public void testFloatEquality() throws Exception {
166:                FloatProperty jp1 = new FloatProperty("name1", 123.4f);
167:                FloatProperty jp2 = new FloatProperty("name1", 123.4f);
168:                FloatProperty jp3 = new FloatProperty("name2", -123.4f);
169:                FloatProperty jp4 = new FloatProperty("name2", 123.4f);
170:                FloatProperty jp5 = new FloatProperty("name2",
171:                        Float.NEGATIVE_INFINITY);
172:                FloatProperty jp6 = new FloatProperty("name2",
173:                        Float.NEGATIVE_INFINITY);
174:                FloatProperty jp7 = new FloatProperty("name2",
175:                        Float.POSITIVE_INFINITY);
176:                FloatProperty jp8 = new FloatProperty("name2",
177:                        Float.POSITIVE_INFINITY);
178:                FloatProperty jp9 = new FloatProperty("name2", Float.NaN);
179:                FloatProperty jp10 = new FloatProperty("name2", Float.NaN);
180:                FloatProperty jp11 = new FloatProperty("name1", Float.NaN);
181:                FloatProperty jp12 = new FloatProperty("name1", Float.MIN_VALUE);
182:                FloatProperty jp13 = new FloatProperty("name2", Float.MIN_VALUE);
183:                FloatProperty jp14 = new FloatProperty("name2", Float.MIN_VALUE);
184:                FloatProperty jp15 = new FloatProperty("name1", Float.MAX_VALUE);
185:                FloatProperty jp16 = new FloatProperty("name2", Float.MAX_VALUE);
186:                FloatProperty jp17 = new FloatProperty("name2", Float.MAX_VALUE);
187:                checkEquals(jp1, jp2);
188:                checkNotEquals(jp1, jp3);
189:                checkNotEquals(jp2, jp3);
190:                checkNotEquals(jp3, jp4);
191:                checkEquals(jp5, jp6);
192:                checkNotEquals(jp3, jp6);
193:                checkEquals(jp7, jp8);
194:                checkNotEquals(jp4, jp7);
195:                checkNotEquals(jp8, jp9);
196:                checkEquals(jp9, jp10);
197:                checkNotEquals(jp10, jp11);
198:                checkNotEquals(jp5, jp10);
199:                checkNotEquals(jp12, jp14);
200:                checkEquals(jp13, jp14);
201:                checkNotEquals(jp15, jp16);
202:                checkEquals(jp16, jp17);
203:            }
204:
205:            public void testIntegerEquality() throws Exception {
206:                IntegerProperty jp1 = new IntegerProperty("name1", 123);
207:                IntegerProperty jp2 = new IntegerProperty("name1", 123);
208:                IntegerProperty jp3 = new IntegerProperty("name2", -123);
209:                IntegerProperty jp4 = new IntegerProperty("name2", 123);
210:                IntegerProperty jp5 = new IntegerProperty("name2",
211:                        Integer.MIN_VALUE);
212:                IntegerProperty jp6 = new IntegerProperty("name2",
213:                        Integer.MIN_VALUE);
214:                IntegerProperty jp7 = new IntegerProperty("name2",
215:                        Integer.MAX_VALUE);
216:                IntegerProperty jp8 = new IntegerProperty("name2",
217:                        Integer.MAX_VALUE);
218:                IntegerProperty jp9 = new IntegerProperty("name1",
219:                        Integer.MIN_VALUE);
220:                IntegerProperty jp10 = new IntegerProperty("name1",
221:                        Integer.MAX_VALUE);
222:                checkEquals(jp1, jp2);
223:                checkNotEquals(jp1, jp3);
224:                checkNotEquals(jp2, jp3);
225:                checkNotEquals(jp3, jp4);
226:                checkEquals(jp5, jp6);
227:                checkNotEquals(jp3, jp6);
228:                checkEquals(jp7, jp8);
229:                checkNotEquals(jp4, jp7);
230:                checkNotEquals(jp9, jp5);
231:                checkNotEquals(jp10, jp7);
232:                checkNotEquals(jp9, jp10);
233:                try {
234:                    new IntegerProperty(null);
235:                    fail("Should have generated an Illegal Argument Exception");
236:                } catch (IllegalArgumentException e) {
237:                }
238:                try {
239:                    new IntegerProperty(null, 0);
240:                    fail("Should have generated an Illegal Argument Exception");
241:                } catch (IllegalArgumentException e) {
242:                }
243:            }
244:
245:            public void testLongEquality() throws Exception {
246:                LongProperty jp1 = new LongProperty("name1", 123);
247:                LongProperty jp2 = new LongProperty("name1", 123);
248:                LongProperty jp3 = new LongProperty("name2", -123);
249:                LongProperty jp4 = new LongProperty("name2", 123);
250:                LongProperty jp5 = new LongProperty("name2", Long.MIN_VALUE);
251:                LongProperty jp6 = new LongProperty("name2", Long.MIN_VALUE);
252:                LongProperty jp7 = new LongProperty("name2", Long.MAX_VALUE);
253:                LongProperty jp8 = new LongProperty("name2", Long.MAX_VALUE);
254:                LongProperty jp9 = new LongProperty("name1", Long.MIN_VALUE);
255:                LongProperty jp10 = new LongProperty("name1", Long.MAX_VALUE);
256:                checkEquals(jp1, jp2);
257:                checkNotEquals(jp1, jp3);
258:                checkNotEquals(jp2, jp3);
259:                checkNotEquals(jp3, jp4);
260:                checkEquals(jp5, jp6);
261:                checkNotEquals(jp3, jp6);
262:                checkEquals(jp7, jp8);
263:                checkNotEquals(jp4, jp7);
264:                checkNotEquals(jp9, jp5);
265:                checkNotEquals(jp10, jp7);
266:                checkNotEquals(jp9, jp10);
267:                try {
268:                    new LongProperty(null, 0L);
269:                    fail("Should have generated an Illegal Argument Exception");
270:                } catch (IllegalArgumentException e) {
271:                }
272:            }
273:
274:            public void testMapEquality() throws Exception {
275:                try {
276:                    new MapProperty(null, null);
277:                    fail("Should have generated an Illegal Argument Exception");
278:                } catch (IllegalArgumentException e) {
279:                }
280:
281:            }
282:
283:            public void testNullEquality() throws Exception {
284:                NullProperty jpn1 = new NullProperty();
285:                NullProperty jpn2 = new NullProperty();
286:                try {
287:                    new NullProperty(null);
288:                    fail("Should have generated an Illegal Argument Exception");
289:                } catch (IllegalArgumentException e) {
290:                }
291:                NullProperty jp1 = new NullProperty("name1");
292:                NullProperty jp2 = new NullProperty("name1");
293:                NullProperty jp3 = new NullProperty("name2");
294:                NullProperty jp4 = new NullProperty("name2");
295:                checkEquals(jpn1, jpn2);
296:                checkNotEquals(jpn1, jp1);
297:                checkEquals(jp1, jp2);
298:                checkNotEquals(jp1, jp3);
299:                checkNotEquals(jp2, jp3);
300:                checkEquals(jp3, jp4);
301:            }
302:
303:            public void testStringEquality() throws Exception {
304:                StringProperty jpn1 = new StringProperty();
305:                StringProperty jpn2 = new StringProperty();
306:                StringProperty jp1 = new StringProperty("name1", "value1");
307:                StringProperty jp2 = new StringProperty("name1", "value1");
308:                StringProperty jp3 = new StringProperty("name2", "value1");
309:                StringProperty jp4 = new StringProperty("name2", "value2");
310:                StringProperty jp5 = new StringProperty("name1", null);
311:                StringProperty jp6 = new StringProperty("name1", null);
312:                StringProperty jp7 = new StringProperty("name2", null);
313:                checkEquals(jpn1, jpn2);
314:                checkNotEquals(jpn1, jp1);
315:                checkEquals(jp1, jp2);
316:                checkNotEquals(jp1, jp3);
317:                checkNotEquals(jp2, jp3);
318:                checkNotEquals(jp3, jp4);
319:                checkEquals(jp5, jp6);
320:                checkNotEquals(jp3, jp5);
321:                checkNotEquals(jp6, jp7);
322:                try {
323:                    new StringProperty(null, "");
324:                    fail("Should have generated an Illegal Argument Exception");
325:                } catch (IllegalArgumentException e) {
326:                }
327:                try {
328:                    new StringProperty(null, null);
329:                    fail("Should have generated an Illegal Argument Exception");
330:                } catch (IllegalArgumentException e) {
331:                }
332:
333:            }
334:
335:            public void testAddingProperties() throws Exception {
336:                CollectionProperty coll = new CollectionProperty();
337:                coll.addItem("joe");
338:                coll.addProperty(new FunctionProperty());
339:                assertEquals("joe", coll.get(0).getStringValue());
340:                assertEquals(
341:                        "org.apache.jmeter.testelement.property.FunctionProperty",
342:                        coll.get(1).getClass().getName());
343:            }
344:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.