Source Code Cross Referenced for TagManagerTest.java in  » XML-UI » JAXX » jaxx » junit » 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 » XML UI » JAXX » jaxx.junit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jaxx.junit;
002:
003:        import java.awt.*;
004:        import java.io.*;
005:        import javax.swing.*;
006:        import org.w3c.dom.*;
007:        import junit.framework.TestCase;
008:
009:        import jaxx.compiler.*;
010:        import jaxx.reflect.*;
011:        import jaxx.tags.*;
012:
013:        public class TagManagerTest extends TestCase {
014:            private JAXXCompiler compiler = JAXXCompiler.createDummyCompiler();
015:
016:            public static class TestHandler extends DefaultObjectHandler {
017:                public TestHandler(ClassDescriptor beanClass) {
018:                    super (beanClass);
019:                }
020:            }
021:
022:            public void setUp() {
023:                compiler.addImport("javax.swing.*");
024:            }
025:
026:            public void testRegisterBean() {
027:                TagManager.registerBean(ClassDescriptorLoader
028:                        .getClassDescriptor(InputStream.class),
029:                        TestHandler.class);
030:
031:                assertTrue(TagManager.getTagHandler(ClassDescriptorLoader
032:                        .getClassDescriptor(InputStream.class)) instanceof  TestHandler);
033:                assertTrue(TagManager.getTagHandler(ClassDescriptorLoader
034:                        .getClassDescriptor(FileInputStream.class)) instanceof  TestHandler);
035:            }
036:
037:            public void testRegisterDefaultNamespace() {
038:                TagManager.registerBean(ClassDescriptorLoader
039:                        .getClassDescriptor(OutputStream.class),
040:                        TestHandler.class);
041:
042:                TagManager
043:                        .registerDefaultNamespace("OutputStream", "java.io.*");
044:                assertTrue(
045:                        "Could not find handler for OutputStream despite default namespace",
046:                        TagManager
047:                                .getTagHandler(null, "OutputStream", compiler) instanceof  TestHandler);
048:
049:                PrintStream oldErr = System.err;
050:                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
051:                System.setErr(new PrintStream(buffer));
052:                TagManager.registerDefaultNamespace("OutputStream",
053:                        "java.dummy.*");
054:                assertNull(
055:                        "Found handler for OutputStream despite ambiguous default namespace",
056:                        TagManager
057:                                .getTagHandler(null, "OutputStream", compiler));
058:                System.setErr(oldErr);
059:                assertTrue(
060:                        "No errors were produced with an ambiguous default namespace",
061:                        buffer.size() > 0);
062:                assertTrue(buffer.size() > 0);
063:            }
064:
065:            public void testResolveClassName() {
066:                assertEquals("Could not resolve class name 'Object'",
067:                        TagManager.resolveClassName("Object", compiler),
068:                        "java.lang.Object");
069:                assertEquals("Could not resolve class name 'java.lang.Object'",
070:                        TagManager.resolveClassName("java.lang.Object",
071:                                compiler), "java.lang.Object");
072:                assertNull(
073:                        "Unexpectedly resolved class name 'java.awt.Object'",
074:                        TagManager
075:                                .resolveClassName("java.awt.Object", compiler));
076:            }
077:
078:            public void testPackages() {
079:                assertNull("Unexpectedly found handler for java.awt.JButton",
080:                        TagManager.getTagHandler(null, "java.awt.JButton",
081:                                compiler));
082:                assertNotNull(
083:                        "Did not find handler for JButton with default namespace of java.awt.*",
084:                        TagManager.getTagHandler("java.awt.*", "JButton",
085:                                compiler));
086:                assertNull("Unexpectedly found handler for java.awt.*:JButton",
087:                        TagManager.getTagHandler("java.awt.*", "JButton", true,
088:                                compiler));
089:                assertNotNull("Did not find handler for javax.swing.JButton",
090:                        TagManager.getTagHandler(null, "javax.swing.JButton",
091:                                compiler));
092:                assertNotNull(
093:                        "Did not find handler for JButton with default namespace of java.swing.*",
094:                        TagManager.getTagHandler("java.swing.*", "JButton",
095:                                compiler));
096:                assertNotNull("Did not find handler for javax.swing.*:JButton",
097:                        TagManager.getTagHandler("javax.swing.*", "JButton",
098:                                true, compiler));
099:            }
100:
101:            public void testImport() {
102:                assertNull(
103:                        "Found handler for ActionListener despite no java.awt.event.* import",
104:                        TagManager.getTagHandler(null, "ActionListener",
105:                                compiler));
106:
107:                compiler.addImport("java.awt.event.*");
108:
109:                assertNotNull(
110:                        "Did not find ActionListener with java.awt.event.* import",
111:                        TagManager.getTagHandler(null, "ActionListener",
112:                                compiler));
113:            }
114:
115:            public void testAmbiguousImport() throws Exception {
116:                compiler.addImport("java.sql.*");
117:                assertNotNull(
118:                        "Did not find java.sql.Date with only java.sql.* imported",
119:                        TagManager.getTagHandler(null, "Date", compiler));
120:
121:                PrintStream oldErr = System.err;
122:                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
123:                System.setErr(new PrintStream(buffer));
124:                compiler.addImport("java.util.*");
125:                TagManager.reset();
126:                assertNull(
127:                        "Still found a handler for Date with an ambiguous import",
128:                        TagManager.getTagHandler(null, "Date", compiler));
129:                System.setErr(oldErr);
130:                assertTrue("No errors were produced with an ambiguous import",
131:                        buffer.size() > 0);
132:
133:                compiler.addImport("java.util.Date");
134:                assertNotNull(
135:                        "Did not find java.util.Date with a disambiguating import",
136:                        TagManager.getTagHandler(null, "Date", compiler));
137:            }
138:
139:            public void testInnerClass() {
140:                TagHandler handler = TagManager.getTagHandler(null,
141:                        "JPopupMenu.Separator", compiler);
142:                assertTrue("Unable to resolve tag <JPopupMenu.Separator>",
143:                        handler instanceof  DefaultComponentHandler);
144:                assertTrue(((DefaultComponentHandler) handler).getBeanClass()
145:                        .getName().equals(JPopupMenu.Separator.class.getName()));
146:
147:                handler = TagManager.getTagHandler(null,
148:                        "javax.swing.JPopupMenu.Separator", compiler);
149:                assertTrue(
150:                        "Unable to resolve tag <javax.swing.JPopupMenu.Separator>",
151:                        handler instanceof  DefaultComponentHandler);
152:                assertTrue(((DefaultComponentHandler) handler).getBeanClass()
153:                        .getName().equals(JPopupMenu.Separator.class.getName()));
154:            }
155:
156:            public void testWrongCase() {
157:                assertNull("Unexpectedly found handler for 'object'",
158:                        TagManager.getTagHandler(null, "object", compiler));
159:                assertNull("Unexpectedly found handler for 'tagmanagertest'",
160:                        TagManager.getTagHandler(null, "tagmanagertest",
161:                                compiler));
162:            }
163:
164:            public void testAliasing() {
165:                assertEquals(
166:                        "JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox",
167:                        "jaxx.runtime.swing.JAXXComboBox", TagManager
168:                                .resolveClassName("JComboBox", compiler));
169:                assertEquals(
170:                        "javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox",
171:                        "jaxx.runtime.swing.JAXXComboBox", TagManager
172:                                .resolveClassName("javax.swing.JComboBox",
173:                                        compiler));
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.