Source Code Cross Referenced for UIComponentFactoryTest.java in  » Testing » UISpec4J » org » uispec4j » utils » 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 » UISpec4J » org.uispec4j.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.uispec4j.utils;
002:
003:        import org.uispec4j.UIComponent;
004:        import org.uispec4j.assertion.Assertion;
005:
006:        import javax.swing.*;
007:        import java.awt.*;
008:        import java.util.ArrayList;
009:        import java.util.HashMap;
010:        import java.util.Map;
011:
012:        public class UIComponentFactoryTest extends UnitTestCase {
013:
014:            public void testInitWithDummyComponent() throws Exception {
015:                Map result = new HashMap();
016:                UIComponentFactory.fillSwingToUISpecMap(result,
017:                        new Class[] { ComponentWithSwingClassesField.class });
018:                assertEquals(ComponentWithSwingClassesField.class, result
019:                        .get(JButton.class));
020:            }
021:
022:            public void testInitErrorForClassWithoutSwingClassesField()
023:                    throws Exception {
024:                checkInitError(
025:                        ComponentWithoutSwingClassesField.class,
026:                        "Class "
027:                                + ComponentWithoutSwingClassesField.class
028:                                + " should have a field 'static Class[] SWING_CLASSES'");
029:            }
030:
031:            public void testInitErrorForClassWithUninitialisedSwingClassesField()
032:                    throws Exception {
033:                checkInitError(
034:                        ComponentWithUninitializedSwingClassesField.class,
035:                        "Field 'static Class[] SWING_CLASSES' in class "
036:                                + ComponentWithUninitializedSwingClassesField.class
037:                                + " should be initialized");
038:            }
039:
040:            public void testNonSwingClassInSwingClassesField() throws Exception {
041:                checkInitError(ComponentWithInvalidSwingClass.class, "Class '"
042:                        + String.class
043:                        + "' in field 'SWING_CLASSES' of class '"
044:                        + ComponentWithInvalidSwingClass.class
045:                        + "' should extend '" + Container.class + "'");
046:            }
047:
048:            public void testInitErrorForClassWithoutTypeName() throws Exception {
049:                checkInitError(
050:                        ComponentWithoutTypeName.class,
051:                        "Class "
052:                                + ComponentWithoutTypeName.class
053:                                + " should have a field 'public static String TYPE_NAME'");
054:            }
055:
056:            public void testInitErrorForClassWithUninitialisedTypeName()
057:                    throws Exception {
058:                checkInitError(ComponentWithUninitializedTypeNameField.class,
059:                        "Field 'static String TYPE_NAME' in class "
060:                                + ComponentWithUninitializedTypeNameField.class
061:                                + " should be initialized");
062:            }
063:
064:            public void testInitErrorForClassWithPrivateTypeName()
065:                    throws Exception {
066:                checkInitError(ComponentWithPrivateTypeNameField.class,
067:                        "Field 'static String TYPE_NAME' in class "
068:                                + ComponentWithPrivateTypeNameField.class
069:                                + " should be public");
070:            }
071:
072:            public void testInitErrorForClassWithUnexpectedTypeNameClass()
073:                    throws Exception {
074:                checkInitError(ComponentWithoutUnexpectedTypeNameClass.class,
075:                        "Static field 'TYPE_NAME' in class "
076:                                + ComponentWithoutUnexpectedTypeNameClass.class
077:                                + " should be of type String");
078:            }
079:
080:            public void testComponentClassesMustImplementUIComponent()
081:                    throws Exception {
082:                checkInitError(String.class, "Class '" + String.class
083:                        + "' should implement " + UIComponent.class);
084:            }
085:
086:            private void checkInitError(Class swingClass, String message) {
087:                try {
088:                    UIComponentFactory.initUIComponentClasses(
089:                            new Class[] { swingClass }, new ArrayList());
090:                    fail();
091:                } catch (RuntimeException e) {
092:                    assertEquals(message, e.getMessage());
093:                }
094:            }
095:
096:            private static class ComponentWithSwingClassesField extends
097:                    DummyUIComponent {
098:                public static Class[] SWING_CLASSES = { JButton.class };
099:                public static String TYPE_NAME = "Type";
100:            }
101:
102:            private static class ComponentWithoutSwingClassesField extends
103:                    DummyUIComponent {
104:                public static String TYPE_NAME = "Type";
105:            }
106:
107:            private static class ComponentWithUninitializedSwingClassesField
108:                    extends DummyUIComponent {
109:                static Class[] SWING_CLASSES;
110:                public static String TYPE_NAME = "Type";
111:            }
112:
113:            private static class ComponentWithInvalidSwingClass extends
114:                    DummyUIComponent {
115:                static Class[] SWING_CLASSES = { String.class };
116:                public static String TYPE_NAME = "Type";
117:            }
118:
119:            private static class ComponentWithoutTypeName extends
120:                    DummyUIComponent {
121:                public static Class[] SWING_CLASSES = { org.uispec4j.AbstractButton.class };
122:            }
123:
124:            private static class ComponentWithUninitializedTypeNameField extends
125:                    DummyUIComponent {
126:                public static Class[] SWING_CLASSES = { org.uispec4j.AbstractButton.class };
127:                public static String TYPE_NAME;
128:            }
129:
130:            private static class ComponentWithPrivateTypeNameField extends
131:                    DummyUIComponent {
132:                public static Class[] SWING_CLASSES = { org.uispec4j.AbstractButton.class };
133:                private static String TYPE_NAME = "Type";
134:            }
135:
136:            private static class ComponentWithoutUnexpectedTypeNameClass extends
137:                    DummyUIComponent {
138:                public static Class[] SWING_CLASSES = { org.uispec4j.AbstractButton.class };
139:                public static Object TYPE_NAME = new Integer(3);
140:            }
141:
142:            private static class DummyUIComponent implements  UIComponent {
143:
144:                public Component getAwtComponent() {
145:                    return null;
146:                }
147:
148:                public String getDescription() {
149:                    return null;
150:                }
151:
152:                public String getDescriptionTypeName() {
153:                    return null;
154:                }
155:
156:                public Assertion isEnabled() {
157:                    return new Assertion() {
158:                        public void check() {
159:                        }
160:                    };
161:                }
162:
163:                public String getName() {
164:                    return null;
165:                }
166:
167:                public String getLabel() {
168:                    return null;
169:                }
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.