Source Code Cross Referenced for JxpProcessorTest.java in  » Template-Engine » jxp » org » onemind » jxp » 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 » Template Engine » jxp » org.onemind.jxp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 TiongHiang Lee
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not,  write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         * Email: thlee@onemindsoft.org
019:         */
020:
021:        package org.onemind.jxp;
022:
023:        import java.io.*;
024:        import java.util.HashMap;
025:        import java.util.Map;
026:        import junit.framework.TestCase;
027:        import org.onemind.jxp.parser.ParseException;
028:
029:        /**
030:         * JxpProcessor unit test
031:         * @author TiongHiang Lee (thlee@onemindsoft.org)
032:         * 
033:         */
034:        public class JxpProcessorTest extends TestCase {
035:
036:            /** the processor * */
037:            private JxpProcessor _processor;
038:
039:            /** the source * */
040:            private JxpPageSource _source;
041:
042:            public void setUp() throws Exception {
043:                //_source = new ResourceStreamPageSource("/org/onemind/jxp", "UTF-8"); //eclipse bin
044:                _source = new FilePageSource("src/test/org/onemind/jxp",
045:                        "UTF-8"); //eclipse bin
046:                _processor = new JxpProcessor(new JxpContext(_source));
047:                _processor.setDoMethodStats(true);
048:            }
049:
050:            /** test import and declaration * */
051:            public void testImportAndDeclaration() throws Exception {
052:                _process("testImportAndDeclaration.jxp");
053:            }
054:
055:            /** test the include **/
056:            public void testInclude() throws Exception {
057:                _process("/included/testInclude.jxp");
058:            }
059:
060:            /** test try statement * */
061:            public void testTry() throws Exception {
062:                _process("testTry.jxp");
063:            }
064:
065:            /** test switch statement **/
066:            public void testSwitch() throws Exception {
067:                _process("testSwitch.jxp");
068:            }
069:
070:            /** test function declaration and call **/
071:            public void testFunction() throws Exception {
072:                _process("testFunction.jxp");
073:            }
074:
075:            /** test function declaration and call **/
076:            public void testJsp() throws Exception {
077:                _process("testJsp.jxp");
078:            }
079:
080:            /** test statements **/
081:            public void testPrintStatement() throws Exception {
082:                Map m = new HashMap();
083:                m.put("test1", "test1");
084:                m.put("test2", "test2");
085:                _process("testPrintStatement.jxp", m);
086:            }
087:
088:            /** test statements **/
089:            public void testStatements() throws Exception {
090:                _process("testStatements.jxp");
091:            }
092:
093:            /** test array related operation * */
094:            public void testArray() throws Exception {
095:                _process("testArray.jxp");
096:            }
097:
098:            /** test misc control flow statements * */
099:            public void testControlFlow() throws Exception {
100:                _process("testControlFlow.jxp");
101:            }
102:
103:            /** test misc control flow statements * */
104:            public void testStatic() throws Exception {
105:                Map m = new HashMap();
106:                m.put("result", new Integer(1));
107:                _process("testStatic.jxp", m);
108:                m.put("result", new Integer(2));
109:                _process("testStatic.jxp", m);
110:            }
111:
112:            /** test operators * */
113:            public void testOperators() throws Exception {
114:                _process("testOperators.jxp");
115:            }
116:
117:            /** test synchronize * */
118:            public void testSynchronized() throws Exception {
119:                _process("testSynchronized.jxp");
120:            }
121:
122:            public void testParsing() throws Exception {
123:                _process("testParsing.jxp");
124:            }
125:
126:            /** test return * */
127:            public void testReturn() throws Exception {
128:                _process("testReturn.jxp");
129:            }
130:
131:            /** test reflection * */
132:            public void testReflect() throws Exception {
133:                _process("testReflect.jxp");
134:            }
135:
136:            /** test jdk15 **/
137:            public void testJdk15() throws Exception {
138:                _process("testJdk15.jxp");
139:            }
140:
141:            public void testBufferedPageSource() throws Exception {
142:                ByteArrayPageSource ps = new ByteArrayPageSource();
143:                JxpContext context = new JxpContext(ps);
144:                JxpProcessor processor = new JxpProcessor(context);
145:                ps.putPageBuffer("test", "<% System.out.println(\"a\"); %> "
146:                        .getBytes());
147:                processor.process("test", new OutputStreamWriter(System.out));
148:            }
149:
150:            public void dumpSyntax(String filename) throws Exception {
151:                _source.getJxpPage(filename).getJxpDocument().dump("");
152:            }
153:
154:            /** process the given script */
155:            private void _process(String filename) throws Exception {
156:                _process(filename, new HashMap());
157:            }
158:
159:            /** process the given script */
160:            private void _process(String filename, Map env) throws Exception {
161:                Writer writer = new OutputStreamWriter(System.out, "UTF-8");
162:                try {
163:                    _processor.process(filename, writer, env);
164:                } catch (ParseException pe) {
165:                    throw pe;
166:                } catch (Exception e) {
167:                    System.out.println("Dumping syntax of " + filename);
168:                    System.out.println(e.getMessage());
169:                    //            /dumpSyntax(filename);
170:                    throw e;
171:                } finally {
172:                    writer.flush();
173:                }
174:            }
175:
176:            public void printMethodStats() {
177:                System.out.println(_processor.getMethodStats());
178:            }
179:
180:            public static void main(String argsp[]) throws Exception {
181:                JxpProcessorTest test = new JxpProcessorTest();
182:                test.setUp();
183:                //        test.testArray();
184:                //        test.testControlFlow();
185:                //        test.testFunction();
186:                //        test.testImportAndDeclaration();
187:                //        test.testInclude();
188:                //        test.testOperators();
189:                //        test.testReflect();
190:                //        test.testReturn();
191:                //        test.testStatements();
192:                //        test.testSwitch();
193:                //        test.testSynchronized();
194:                //        test.testTry();
195:                //test.testPrintStatement();
196:                test.testParsing();
197:                test.printMethodStats();
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.