Source Code Cross Referenced for ViewSchema_Test.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » compiler » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ****************************************************************************
002:         * ViewSchema_Test.java
003:         * ****************************************************************************/
004:
005:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006:         * Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
007:         * Use is subject to license terms.                                            *
008:         * J_LZ_COPYRIGHT_END *********************************************************/
009:
010:        package org.openlaszlo.compiler;
011:
012:        import java.io.*;
013:        import java.util.*; // import org.apache.oro.text.regex.*;
014:        import org.jdom.*;
015:        import org.openlaszlo.compiler.ViewSchema;
016:        import org.openlaszlo.utils.ChainedException;
017:        import org.jdom.input.SAXBuilder;
018:        import org.xml.sax.InputSource;
019:
020:        /*
021:         * junit.awtui.TestRunner
022:         * junit.swingui.TestRunner
023:         * junit.textui.TestRunner
024:         *
025:         *
026:         * java  junit.textui.TestRunner  org.openlaszlo.ic.ViewSchema_Test
027:         */
028:
029:        import junit.framework.*;
030:
031:        public class ViewSchema_Test extends TestCase {
032:            public ViewSchema_Test(String name) {
033:                super (name);
034:            }
035:
036:            public void setUp() {
037:            }
038:
039:            public void testParseColors() {
040:                ViewSchema schema = new ViewSchema();
041:                assertEquals("parseColor #FFFFFF", 0XFFFFFF, schema
042:                        .parseColor("#FFFFFF"));
043:                assertEquals("parseColor #FF0000", 0xFF0000, schema
044:                        .parseColor("#FF0000"));
045:                assertEquals("parseColor #800080", 0x800080, schema
046:                        .parseColor("#800080"));
047:                assertEquals("parseColor #FF00FF", 0xFF00FF, schema
048:                        .parseColor("#FF00FF"));
049:                assertEquals("parseColor #123456", 0x123456, schema
050:                        .parseColor("#123456"));
051:                assertEquals("parseColor #DEADBE", 0xDEADBE, schema
052:                        .parseColor("#DEADBE"));
053:                assertEquals("parseColor #000000", 0x000000, schema
054:                        .parseColor("#000000"));
055:                assertEquals("parseColor black", 0x000000, schema
056:                        .parseColor("black"));
057:                assertEquals("parseColor green", 0x008000, schema
058:                        .parseColor("green"));
059:                assertEquals("parseColor silver", 0xC0C0C0, schema
060:                        .parseColor("silver"));
061:                assertEquals("parseColor lime", 0x00FF00, schema
062:                        .parseColor("lime"));
063:                assertEquals("parseColor gray", 0x808080, schema
064:                        .parseColor("gray"));
065:                assertEquals("parseColor olive", 0x808000, schema
066:                        .parseColor("olive"));
067:                assertEquals("parseColor white", 0xFFFFFF, schema
068:                        .parseColor("white"));
069:                assertEquals("parseColor yellow", 0xFFFF00, schema
070:                        .parseColor("yellow"));
071:                assertEquals("parseColor maroon", 0x800000, schema
072:                        .parseColor("maroon"));
073:                assertEquals("parseColor navy", 0x000080, schema
074:                        .parseColor("navy"));
075:                assertEquals("parseColor red", 0xFF0000, schema
076:                        .parseColor("red"));
077:                assertEquals("parseColor blue", 0x0000FF, schema
078:                        .parseColor("blue"));
079:                assertEquals("parseColor purple", 0x800080, schema
080:                        .parseColor("purple"));
081:                assertEquals("parseColor teal", 0x008080, schema
082:                        .parseColor("teal"));
083:                assertEquals("parseColor fuchsia", 0xFF00FF, schema
084:                        .parseColor("fuchsia"));
085:                assertEquals("parseColor aqua", 0x00FFFF, schema
086:                        .parseColor("aqua"));
087:
088:            }
089:
090:            public void testHTMLContent() {
091:                ViewSchema schema = new ViewSchema();
092:
093:                assertTrue("hasHTMLContent text", schema
094:                        .hasHTMLContent(new Element("text")));
095:                assertTrue("hasHTMLContent class", !schema
096:                        .hasHTMLContent(new Element("class")));
097:                assertTrue("hasHTMLContent method", !schema
098:                        .hasHTMLContent(new Element("method")));
099:                assertTrue("hasHTMLContent property", !schema
100:                        .hasHTMLContent(new Element("property")));
101:                assertTrue("hasHTMLContent script", !schema
102:                        .hasHTMLContent(new Element("script")));
103:            }
104:
105:            public void testSetAttributes() {
106:
107:                ViewSchema schema = new ViewSchema();
108:                CompilationEnvironment env = new CompilationEnvironment();
109:                try {
110:                    schema.loadSchema(env);
111:                } catch (JDOMException e) {
112:                    throw new RuntimeException(e.getMessage());
113:                } catch (IOException e) {
114:                    throw new RuntimeException(e.getMessage());
115:                }
116:
117:                String class1 = "mynewclass";
118:                String subclass = "mynewsubclass";
119:
120:                Element elt1 = new Element("classdef1");
121:                Element elt2 = new Element("classdef2");
122:
123:                schema.addElement(elt1, "mynewclass", "view", new ArrayList(),
124:                        env);
125:                schema.addElement(elt2, "mynewsubclass", "mynewclass",
126:                        new ArrayList(), env);
127:
128:                assertEquals("undefined class superclass", "Object", schema
129:                        .getBaseClassname("view"));
130:
131:                assertEquals(" superclass", "view", schema
132:                        .getSuperclassName("mynewclass"));
133:
134:                assertEquals(" superclass", "mynewclass", schema
135:                        .getSuperclassName("mynewsubclass"));
136:
137:                assertEquals("mynewclass superclass", "Object", schema
138:                        .getBaseClassname("mynewclass"));
139:
140:                assertEquals("mynewsubclass superclass", "Object", schema
141:                        .getBaseClassname("mynewsubclass"));
142:
143:                schema.setAttributeType(elt1, "mynewclass", "foo-width",
144:                        new AttributeSpec("foo-width",
145:                                schema.SIZE_EXPRESSION_TYPE, null, null));
146:                schema.setAttributeType(elt1, "mynewclass", "barbaz",
147:                        new AttributeSpec("barbaz", schema.STRING_TYPE, null,
148:                                null));
149:
150:                schema.setAttributeType(elt1, "mynewsubclass", "baz-width",
151:                        new AttributeSpec("baz-width",
152:                                schema.SIZE_EXPRESSION_TYPE, null, null));
153:                schema.setAttributeType(elt1, "mynewsubclass", "barbaz",
154:                        new AttributeSpec("barbaz", schema.EVENT_HANDLER_TYPE,
155:                                null, null));
156:
157:                assertEquals("mynewclass foo-width type",
158:                        schema.SIZE_EXPRESSION_TYPE, schema.getAttributeType(
159:                                class1, "foo-width"));
160:
161:                assertEquals("mynewclass barbaz type", schema.STRING_TYPE,
162:                        schema.getAttributeType(class1, "barbaz"));
163:
164:                // Check subclass attribute types
165:                assertEquals("mynewsubclass foo-width type",
166:                        schema.SIZE_EXPRESSION_TYPE, schema.getAttributeType(
167:                                subclass, "foo-width"));
168:
169:                assertEquals("mynewsubclass baz-width type",
170:                        schema.SIZE_EXPRESSION_TYPE, schema.getAttributeType(
171:                                subclass, "baz-width"));
172:
173:                // Attribute type of subclass should override superclass type
174:                assertEquals("mynewsubclass barbaz type",
175:                        schema.EVENT_HANDLER_TYPE, schema.getAttributeType(
176:                                subclass, "barbaz"));
177:
178:                // test for duplicate attributes, undefined superclass, redefined class, attr inheritance
179:
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.