Source Code Cross Referenced for JspcTest.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional;
019:
020:        import java.io.File;
021:
022:        import org.apache.tools.ant.BuildFileTest;
023:        import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler;
024:        import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler;
025:        import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler;
026:        import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter;
027:        import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory;
028:
029:        /**
030:         * Tests the Jspc task.
031:         *
032:         * @created 07 March 2002
033:         * @since Ant 1.5
034:         */
035:        public class JspcTest extends BuildFileTest {
036:            /**
037:             * Description of the Field
038:             */
039:            private File baseDir;
040:            /**
041:             * Description of the Field
042:             */
043:            private File outDir;
044:
045:            /**
046:             * Description of the Field
047:             */
048:            private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
049:
050:            /**
051:             * Constructor for the JspcTest object
052:             *
053:             * @param name Description of Parameter
054:             */
055:            public JspcTest(String name) {
056:                super (name);
057:            }
058:
059:            /**
060:             * The JUnit setup method
061:             */
062:            public void setUp() {
063:                configureProject(TASKDEFS_DIR + "jspc.xml");
064:                baseDir = new File(System.getProperty("root"), TASKDEFS_DIR);
065:                outDir = new File(baseDir, "jsp/java");
066:            }
067:
068:            /**
069:             * The teardown method for JUnit
070:             */
071:            public void tearDown() {
072:                executeTarget("cleanup");
073:            }
074:
075:            /**
076:             * A unit test for JUnit
077:             */
078:            public void testSimple() throws Exception {
079:                executeJspCompile("testSimple", "simple_jsp.java");
080:            }
081:
082:            /**
083:             * A unit test for JUnit
084:             */
085:            public void testUriroot() throws Exception {
086:                executeJspCompile("testUriroot", "uriroot_jsp.java");
087:            }
088:
089:            /**
090:             * A unit test for JUnit
091:             */
092:            public void testXml() throws Exception {
093:                executeJspCompile("testXml", "xml_jsp.java");
094:            }
095:
096:            /**
097:             * try a keyword in a file
098:             */
099:            public void testKeyword() throws Exception {
100:                executeJspCompile("testKeyword", "default_jsp.java");
101:            }
102:
103:            /**
104:             * what happens to 1nvalid-classname
105:             */
106:            public void testInvalidClassname() throws Exception {
107:                executeJspCompile("testInvalidClassname",
108:                        "_1nvalid_0002dclassname_jsp.java");
109:            }
110:
111:            /**
112:             * A unit test for JUnit
113:             */
114:            public void testNoTld() throws Exception {
115:                //         expectBuildExceptionContaining("testNoTld",
116:                //                 "Jasper found an error in a file",
117:                //                 "Java returned: 9");
118:                expectBuildExceptionContaining("testNoTld", "not found",
119:                        "Java returned: 9");
120:            }
121:
122:            /**
123:             * A unit test for JUnit
124:             */
125:            public void testNotAJspFile() throws Exception {
126:                executeTarget("testNotAJspFile");
127:            }
128:
129:            /**
130:             * webapp test is currently broken, because it picks up
131:             * on the missing_tld file, and bails.
132:             */
133:            /*
134:             public void testWebapp()  throws Exception {
135:             executeTarget("testWebapp");
136:             }
137:             */
138:            /**
139:             * run a target then verify the named file gets created
140:             *
141:             * @param target Description of Parameter
142:             * @param javafile Description of Parameter
143:             * @exception Exception trouble
144:             */
145:            protected void executeJspCompile(String target, String javafile)
146:                    throws Exception {
147:                executeTarget(target);
148:                assertJavaFileCreated(javafile);
149:            }
150:
151:            /**
152:             * verify that a named file was created
153:             *
154:             * @param filename Description of Parameter
155:             * @exception Exception trouble
156:             */
157:            protected void assertJavaFileCreated(String filename)
158:                    throws Exception {
159:                File file = getOutputFile(filename);
160:                assertTrue("file " + filename + " not found", file.exists());
161:                assertTrue("file " + filename + " is empty", file.length() > 0);
162:            }
163:
164:            /**
165:             * Gets the OutputFile attribute of the JspcTest object
166:             *
167:             * @param subpath Description of Parameter
168:             * @return The OutputFile value
169:             */
170:            protected File getOutputFile(String subpath) {
171:                return new File(outDir, subpath);
172:            }
173:
174:            /**
175:             * verify that we select the appropriate mangler
176:             */
177:            public void testJasperNameManglerSelection() {
178:                JspCompilerAdapter adapter = JspCompilerAdapterFactory
179:                        .getCompiler("jasper", null, null);
180:                JspMangler mangler = adapter.createMangler();
181:                assertTrue(mangler instanceof  JspNameMangler);
182:                adapter = JspCompilerAdapterFactory.getCompiler("jasper41",
183:                        null, null);
184:                mangler = adapter.createMangler();
185:                assertTrue(mangler instanceof  Jasper41Mangler);
186:            }
187:
188:            public void testJasper41() {
189:                JspMangler mangler = new Jasper41Mangler();
190:                //java keywords are not special
191:                assertMapped(mangler, "for.jsp", "for_jsp");
192:                //underscores go in front of invalid start chars
193:                assertMapped(mangler, "0.jsp", "_0_jsp");
194:                //underscores at the front get an underscore too
195:                assertMapped(mangler, "_.jsp", "___jsp");
196:                //non java char at start => underscore then the the _hex value
197:                assertMapped(mangler, "-.jsp", "__0002d_jsp");
198:                //and paths are stripped
199:                char s = File.separatorChar;
200:                assertMapped(mangler, "" + s + s + "somewhere" + s + "file" + s
201:                        + "index.jsp", "index_jsp");
202:            }
203:
204:            /**
205:             * assert our mapping rules
206:             * @param mangler
207:             * @param filename
208:             * @param classname
209:             */
210:            protected void assertMapped(JspMangler mangler, String filename,
211:                    String classname) {
212:                String mappedname = mangler
213:                        .mapJspToJavaName(new File(filename));
214:                assertTrue(filename + " should have mapped to " + classname
215:                        + " but instead mapped to " + mappedname, classname
216:                        .equals(mappedname));
217:            }
218:
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.