Source Code Cross Referenced for ClassConfigurationTest.java in  » Testing » htmlunit » com » gargoylesoftware » htmlunit » javascript » configuration » 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 » htmlunit » com.gargoylesoftware.htmlunit.javascript.configuration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2008 Gargoyle Software Inc. All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * 1. Redistributions of source code must retain the above copyright notice,
008:         *    this list of conditions and the following disclaimer.
009:         * 2. Redistributions in binary form must reproduce the above copyright notice,
010:         *    this list of conditions and the following disclaimer in the documentation
011:         *    and/or other materials provided with the distribution.
012:         * 3. The end-user documentation included with the redistribution, if any, must
013:         *    include the following acknowledgment:
014:         *
015:         *       "This product includes software developed by Gargoyle Software Inc.
016:         *        (http://www.GargoyleSoftware.com/)."
017:         *
018:         *    Alternately, this acknowledgment may appear in the software itself, if
019:         *    and wherever such third-party acknowledgments normally appear.
020:         * 4. The name "Gargoyle Software" must not be used to endorse or promote
021:         *    products derived from this software without prior written permission.
022:         *    For written permission, please contact info@GargoyleSoftware.com.
023:         * 5. Products derived from this software may not be called "HtmlUnit", nor may
024:         *    "HtmlUnit" appear in their name, without prior written permission of
025:         *    Gargoyle Software Inc.
026:         *
027:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
028:         * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
029:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
030:         * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
031:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
032:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
033:         * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
036:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037:         */
038:        package com.gargoylesoftware.htmlunit.javascript.configuration;
039:
040:        import com.gargoylesoftware.htmlunit.WebTestCase;
041:
042:        /**
043:         * Tests for {@link JavaScriptConfiguration}.
044:         *
045:         * @version $Revision: 2132 $
046:         * @author Chris Erskine
047:         * @author Ahmed Ashour
048:         */
049:        public class ClassConfigurationTest extends WebTestCase {
050:            /**
051:             * Create an instance
052:             * @param name The name of the test
053:             */
054:            public ClassConfigurationTest(final String name) {
055:                super (name);
056:            }
057:
058:            /**
059:             * Reset the JavaScriptConfiguration file for each test to it's inital clean state.
060:             *
061:             * @throws Exception if the test fails
062:             */
063:            protected void setUp() throws Exception {
064:                super .setUp();
065:                JavaScriptConfiguration.resetClassForTesting();
066:            }
067:
068:            /**
069:             * Test equality on a class configuration
070:             * @throws Exception - Exception on error
071:             */
072:            public void testConfigurationSimplePropertyEquality()
073:                    throws Exception {
074:                final ClassConfiguration config1 = new ClassConfiguration("c1",
075:                        ConfigTestClass.class.getName(), null, null, null, true);
076:                final ClassConfiguration config2 = new ClassConfiguration("c2",
077:                        ConfigTestClass.class.getName(), null, null, null, true);
078:
079:                config1.addProperty("test", true, true);
080:                assertFalse("Configs should not be equal", config1
081:                        .equals(config2));
082:                config2.addProperty("test", true, true);
083:                assertTrue("Configs should now be equal", config1
084:                        .equals(config2));
085:            }
086:
087:            /**
088:             * Test equality on a class configuration for function
089:             * @throws Exception - Exception on error
090:             */
091:            public void testConfigurationSimpleFunctionEquality()
092:                    throws Exception {
093:                final ClassConfiguration config1 = new ClassConfiguration("c1",
094:                        ConfigTestClass.class.getName(), null, null, null, true);
095:                final ClassConfiguration config2 = new ClassConfiguration("c2",
096:                        ConfigTestClass.class.getName(), null, null, null, true);
097:
098:                config1.addFunction("testFunction");
099:                assertFalse("Configs should not be equal", config1
100:                        .equals(config2));
101:                config2.addFunction("testFunction");
102:                assertTrue("Configs should now be equal", config1
103:                        .equals(config2));
104:            }
105:
106:            /**
107:             * Test equality on a class configuration
108:             *
109:             * @throws Exception - Exception on error
110:             */
111:            public void testConfigurationSimpleUnequalProperties()
112:                    throws Exception {
113:                final ClassConfiguration config1 = new ClassConfiguration("c1",
114:                        ConfigTestClass.class.getName(), null, null, null, true);
115:                final ClassConfiguration config2 = new ClassConfiguration("c2",
116:                        ConfigTestClass.class.getName(), null, null, null, true);
117:
118:                config1.addProperty("test", true, true);
119:                assertFalse("Configs should not be equal", config1
120:                        .equals(config2));
121:                config2.addProperty("test", true, false);
122:                assertFalse(
123:                        "Configs should not be equal due to different property values",
124:                        config1.equals(config2));
125:            }
126:
127:            /**
128:             * @throws Exception on error
129:             */
130:            public void testForJSFlagTrue() throws Exception {
131:                final ClassConfiguration config1 = new ClassConfiguration("c1",
132:                        ConfigTestClass.class.getName(), null, null, null, true);
133:                assertTrue("JSObject Flag should have been set", config1
134:                        .isJsObject());
135:            }
136:
137:            /**
138:             * @throws Exception on error
139:             */
140:            public void testForJSFlagFalse() throws Exception {
141:                final ClassConfiguration config1 = new ClassConfiguration("c1",
142:                        ConfigTestClass.class.getName(), null, null, null,
143:                        false);
144:                assertFalse("JSObject Flag should not have been set", config1
145:                        .isJsObject());
146:            }
147:
148:            /**
149:             * Test equality on a class configuration
150:             *
151:             * @throws Exception - Exception on error
152:             */
153:            public void testConfigurationPropertyEqualityWithBrowser()
154:                    throws Exception {
155:                final ClassConfiguration config1 = new ClassConfiguration("c1",
156:                        ConfigTestClass.class.getName(), null, null, null, true);
157:                final ClassConfiguration config2 = new ClassConfiguration("c2",
158:                        ConfigTestClass.class.getName(), null, null, null, true);
159:
160:                config1.addProperty("test", true, true);
161:                config2.addProperty("test", true, true);
162:                config1.setBrowser("test", "Netscape");
163:                assertFalse("Should not be equal with browser added", config1
164:                        .equals(config2));
165:                config2.setBrowser("test", "Netscape");
166:                assertTrue("Should be equal with browser added", config1
167:                        .equals(config2));
168:            }
169:
170:            /**
171:             * Test equality on a class configuration mis-matched browsers
172:             *
173:             * @throws Exception - Exception on error
174:             */
175:            public void testConfigurationPropertyEqualityWithDifferentBrowsers()
176:                    throws Exception {
177:                final ClassConfiguration config1 = new ClassConfiguration("c1",
178:                        ConfigTestClass.class.getName(), null, null, null, true);
179:                final ClassConfiguration config2 = new ClassConfiguration("c2",
180:                        ConfigTestClass.class.getName(), null, null, null, true);
181:
182:                config1.addProperty("test", true, true);
183:                config2.addProperty("test", true, true);
184:                config1.setBrowser("test", "Netscape");
185:                assertFalse("Should not be equal with browser added", config1
186:                        .equals(config2));
187:                config2.setBrowser("test", "Microsoft Internet Explorer");
188:                assertFalse("Should be equal with different browser added",
189:                        config1.equals(config2));
190:            }
191:
192:            /**
193:             * Test for throwing exception when setter method is not defined
194:             *
195:             * @throws Exception - Exception on error
196:             */
197:            public void testNoSetterMethod() throws Exception {
198:                final ClassConfiguration config1 = new ClassConfiguration("c1",
199:                        ConfigTestClass.class.getName(), null, null, null, true);
200:                try {
201:                    config1.addProperty("getterOnly", true, true);
202:                    fail("Should produce an exception due to not finding the methods");
203:                } catch (final IllegalStateException e) {
204:                    assertTrue(true);
205:                }
206:            }
207:
208:            /**
209:             * Test for throwing exception when setter method is not defined
210:             *
211:             * @throws Exception - Exception on error
212:             */
213:            public void testNoFunctionMethod() throws Exception {
214:                final ClassConfiguration config1 = new ClassConfiguration("c1",
215:                        ConfigTestClass.class.getName(), null, null, null, true);
216:                try {
217:                    config1.addFunction("noTestFunction");
218:                    fail("Should produce an exception due to not finding the methods");
219:                } catch (final IllegalStateException e) {
220:                    assertTrue(true);
221:                }
222:            }
223:
224:            /**
225:             * test class
226:             */
227:            protected class ConfigTestClass {
228:                private boolean test_ = false;
229:
230:                /**
231:                 * Dummy function
232:                 */
233:                public void jsxFunction_testFunction() {
234:                }
235:
236:                /**
237:                 * @return boolean
238:                 */
239:                public boolean jsxGet_test() {
240:                    return test_;
241:                }
242:
243:                /**
244:                 * @return boolean
245:                 */
246:                public boolean jsxGet_getterOnly() {
247:                    return test_;
248:                }
249:
250:                /**
251:                 * @param testFlag - test value
252:                 */
253:                public void jsxSet_test(final boolean testFlag) {
254:                    test_ = testFlag;
255:                }
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.