Source Code Cross Referenced for StyleTest.java in  » Build » ANT » org » apache » tools » ant » taskdefs » 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 
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;
019:
020:        import java.io.FileReader;
021:        import java.io.IOException;
022:        import java.io.Reader;
023:
024:        import org.apache.tools.ant.BuildFileTest;
025:        import org.apache.tools.ant.taskdefs.optional.XsltTest;
026:        import org.apache.tools.ant.util.FileUtils;
027:
028:        /**
029:         * TestCases for {@link XSLTProcess} task.
030:         * XXX merge with {@link XsltTest}?
031:         * @version 2003-08-05
032:         */
033:        public class StyleTest extends BuildFileTest {
034:
035:            private static final FileUtils FILE_UTILS = FileUtils
036:                    .getFileUtils();
037:
038:            public StyleTest(String s) {
039:                super (s);
040:            }
041:
042:            protected void setUp() throws Exception {
043:                configureProject("src/etc/testcases/taskdefs/style/build.xml");
044:                //executeTarget("setup");
045:                //commented out for performance while target is empty
046:            }
047:
048:            protected void tearDown() throws Exception {
049:                executeTarget("teardown");
050:            }
051:
052:            public void testStyleIsSet() throws Exception {
053:                expectSpecificBuildException("testStyleIsSet",
054:                        "no stylesheet specified", "specify the "
055:                                + "stylesheet either as a filename in style "
056:                                + "attribute or as a nested resource");
057:            }
058:
059:            public void testTransferParameterSet() throws Exception {
060:                expectFileContains("testTransferParameterSet", // target
061:                        "out/out.xml", // file
062:                        "set='myvalue'"); // exptected string
063:            }
064:
065:            public void testTransferParameterEmpty() throws Exception {
066:                expectFileContains("testTransferParameterEmpty", "out/out.xml",
067:                        "empty=''");
068:            }
069:
070:            public void testTransferParameterUnset() throws Exception {
071:                expectFileContains("testTransferParameterUnset", "out/out.xml",
072:                        "undefined='${value}'");
073:            }
074:
075:            public void testTransferParameterUnsetWithIf() throws Exception {
076:                expectFileContains("testTransferParameterUnsetWithIf",
077:                        "out/out.xml", "undefined='undefined default value'");
078:            }
079:
080:            public void testNewerStylesheet() throws Exception {
081:                expectFileContains("testNewerStylesheet", "out/out.xml",
082:                        "new-value");
083:            }
084:
085:            public void testDefaultMapper() throws Exception {
086:                testDefaultMapper("testDefaultMapper");
087:            }
088:
089:            public void testExplicitFileset() throws Exception {
090:                testDefaultMapper("testExplicitFileset");
091:            }
092:
093:            public void testDefaultMapper(String target) throws Exception {
094:                assertTrue(!(FileUtils.getFileUtils().resolveFile(getProject()
095:                        .getBaseDir(), "out/data.html")).exists());
096:                expectFileContains(target, "out/data.html", "set='myvalue'");
097:            }
098:
099:            public void testCustomMapper() throws Exception {
100:                assertTrue(!FILE_UTILS.resolveFile(getProject().getBaseDir(),
101:                        "out/out.xml").exists());
102:                expectFileContains("testCustomMapper", "out/out.xml",
103:                        "set='myvalue'");
104:            }
105:
106:            public void testTypedMapper() throws Exception {
107:                assertTrue(!FILE_UTILS.resolveFile(getProject().getBaseDir(),
108:                        "out/out.xml").exists());
109:                expectFileContains("testTypedMapper", "out/out.xml",
110:                        "set='myvalue'");
111:            }
112:
113:            public void testDirectoryHierarchyWithDirMatching()
114:                    throws Exception {
115:                executeTarget("testDirectoryHierarchyWithDirMatching");
116:                assertTrue(FILE_UTILS.resolveFile(getProject().getBaseDir(),
117:                        "out/dest/level1/data.html").exists());
118:            }
119:
120:            public void testDirsWithSpaces() throws Exception {
121:                executeTarget("testDirsWithSpaces");
122:                assertTrue(FILE_UTILS.resolveFile(getProject().getBaseDir(),
123:                        "out/d est/data.html").exists());
124:            }
125:
126:            public void testWithStyleAttrAndResource() throws Exception {
127:                expectSpecificBuildException("testWithStyleAttrAndResource",
128:                        "Must throws a BuildException", "specify the "
129:                                + "stylesheet either as a filename in style "
130:                                + "attribute or as a nested resource but not "
131:                                + "as both");
132:            }
133:
134:            public void testWithFileResource() throws Exception {
135:                expectFileContains("testWithFileResource", "out/out.xml",
136:                        "set='value'");
137:            }
138:
139:            public void testWithUrlResource() throws Exception {
140:                expectFileContains("testWithUrlResource", "out/out.xml",
141:                        "set='value'");
142:            }
143:
144:            public void testFilenameAsParam() throws Exception {
145:                executeTarget("testFilenameAsParam");
146:                assertFileContains("out/out/one.txt", "filename='one.xml'");
147:                assertFileContains("out/out/two.txt", "filename='two.xml'");
148:                assertFileContains("out/out/three.txt", "filename='three.xml'");
149:                assertFileContains("out/out/dir/four.txt",
150:                        "filename='four.xml'");
151:                assertFileContains("out/out/dir/four.txt",
152:                        "filedir ='-not-set-'");
153:            }
154:
155:            public void testFilenameAsParamNoSetting() throws Exception {
156:                executeTarget("testFilenameAsParamNoSetting");
157:                assertFileContains("out/out/one.txt", "filename='-not-set-'");
158:                assertFileContains("out/out/two.txt", "filename='-not-set-'");
159:                assertFileContains("out/out/three.txt", "filename='-not-set-'");
160:                assertFileContains("out/out/dir/four.txt",
161:                        "filename='-not-set-'");
162:            }
163:
164:            public void testFilenameAndFiledirAsParam() throws Exception {
165:                executeTarget("testFilenameAndFiledirAsParam");
166:                assertFileContains("out/out/one.txt", "filename='one.xml'");
167:                assertFileContains("out/out/one.txt", "filedir ='.'");
168:                assertFileContains("out/out/dir/four.txt",
169:                        "filename='four.xml'");
170:                assertFileContains("out/out/dir/four.txt", "filedir ='dir'");
171:            }
172:
173:            // *************  copied from ConcatTest  *************
174:
175:            // ------------------------------------------------------
176:            //   Helper methods - should be in BuildFileTest
177:            // -----------------------------------------------------
178:
179:            private String getFileString(String filename) throws IOException {
180:                Reader r = null;
181:                try {
182:                    r = new FileReader(getProject().resolveFile(filename));
183:                    return FileUtils.readFully(r);
184:                } finally {
185:                    FileUtils.close(r);
186:                }
187:            }
188:
189:            private void expectFileContains(String target, String filename,
190:                    String contains) throws IOException {
191:                executeTarget(target);
192:                assertFileContains(filename, contains);
193:            }
194:
195:            private void assertFileContains(String filename, String contains)
196:                    throws IOException {
197:                String content = getFileString(filename);
198:                assertTrue("expecting file " + filename + " to contain "
199:                        + contains + " but got " + content, content
200:                        .indexOf(contains) > -1);
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.