Source Code Cross Referenced for ImportTest.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:
019:        package org.apache.tools.ant.taskdefs;
020:
021:        import java.io.File;
022:        import java.io.IOException;
023:
024:        import org.apache.tools.ant.BuildException;
025:        import org.apache.tools.ant.BuildFileTest;
026:        import org.apache.tools.ant.Location;
027:        import org.apache.tools.ant.Project;
028:
029:        /**
030:         */
031:        public class ImportTest extends BuildFileTest {
032:
033:            public ImportTest(String name) {
034:                super (name);
035:            }
036:
037:            public void setUp() {
038:            }
039:
040:            public void tearDown() {
041:            }
042:
043:            public void testSimpleImport() {
044:                configureProject("src/etc/testcases/taskdefs/import/import.xml");
045:                assertLogContaining("Before importIn imported topAfter import");
046:            }
047:
048:            public void testUnnamedNesting() {
049:                configureProject(
050:                        "src/etc/testcases/taskdefs/import/unnamedImport.xml",
051:                        Project.MSG_WARN);
052:                String log = getLog();
053:                assertTrue("Warnings logged when not expected: " + log, log
054:                        .length() == 0);
055:            }
056:
057:            public void testSerial() {
058:                configureProject("src/etc/testcases/taskdefs/import/subdir/serial.xml");
059:                assertLogContaining("Unnamed2.xmlUnnamed1.xml");
060:                String fullLog = getFullLog();
061:                String substring = "Skipped already imported file";
062:                assertTrue("expecting full log to contain \"" + substring
063:                        + "\" full log was \"" + fullLog + "\"", fullLog
064:                        .indexOf(substring) >= 0);
065:            }
066:
067:            // allow this as imported in targets are only tested when a target is run
068:            public void testImportInTargetNoEffect() {
069:                configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml");
070:                expectPropertyUnset("no-import", "foo");
071:                assertTrue(null == getProject().getReference("baz"));
072:            }
073:
074:            // deactivate this test as imports within targets are not allowed
075:            public void notTestImportInTargetWithEffect() {
076:                configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml");
077:                expectPropertySet("do-import", "foo", "bar");
078:                assertNotNull(getProject().getReference("baz"));
079:            }
080:
081:            public void testImportInTargetNotAllowed() {
082:                configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml");
083:                expectBuildExceptionContaining("do-import",
084:                        "not a top level task",
085:                        "import only allowed as a top-level task");
086:            }
087:
088:            public void testImportInSequential() {
089:                configureProject("src/etc/testcases/taskdefs/import/subdir/importinsequential.xml");
090:                expectPropertySet("within-imported", "foo", "bar");
091:                assertNotNull(getProject().getReference("baz"));
092:            }
093:
094:            public void testImportSameTargets() {
095:                try {
096:                    configureProject("src/etc/testcases/taskdefs/import/same_target.xml");
097:                } catch (BuildException ex) {
098:                    String message = ex.getMessage();
099:                    if (message.indexOf("Duplicate target") == -1) {
100:                        assertTrue("Did not see 'Duplicate target' in '"
101:                                + message + "'", false);
102:                    }
103:                    return;
104:                }
105:                assertTrue("Did not see build exception", false);
106:            }
107:
108:            public void testImportError() {
109:                try {
110:                    configureProject("src/etc/testcases/taskdefs/import/import_bad_import.xml");
111:                } catch (BuildException ex) {
112:                    Location lo = ex.getLocation();
113:                    assertTrue(
114:                            "expected location of build exception to be set",
115:                            (lo != null));
116:                    assertTrue(
117:                            "expected location to contain calling file",
118:                            lo.getFileName().indexOf("import_bad_import.xml") != -1);
119:                    assertTrue("expected message of ex to contain called file",
120:                            ex.getMessage().indexOf("bad.xml") != -1);
121:                    return;
122:                }
123:                assertTrue("Did not see build exception", false);
124:            }
125:
126:            public void testSymlinkedImports() throws Exception {
127:                String ln = "/usr/bin/ln";
128:                if (!new File(ln).exists()) {
129:                    ln = "/bin/ln";
130:                }
131:                if (!new File(ln).exists()) {
132:                    // Running on Windows or something, so skip it.
133:                    return;
134:                }
135:                String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b";
136:                File symlinkFile = new File(System.getProperty("root"), symlink);
137:                if (Runtime.getRuntime().exec(
138:                        new String[] { ln, "-s", "d3a",
139:                                symlinkFile.getAbsolutePath() }).waitFor() != 0) {
140:                    throw new IOException("'" + ln + " -s d3a " + symlink
141:                            + "' failed");
142:                }
143:                try {
144:                    configureProject("src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
145:                    assertPropertyEquals(
146:                            "ant.file.p2",
147:                            new File(System.getProperty("root"),
148:                                    "src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml")
149:                                    .getAbsolutePath());
150:                    assertPropertyEquals(
151:                            "ant.file.p3",
152:                            new File(System.getProperty("root"),
153:                                    "src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml")
154:                                    .getAbsolutePath());
155:                } finally {
156:                    symlinkFile.delete();
157:                }
158:            }
159:
160:            public void testTargetFirst() {
161:                configureProject("src/etc/testcases/taskdefs/import/importtargetfirst.xml");
162:                assertLogContaining("Importing targetfirstAfter target firstAfter importing");
163:            }
164:
165:            public void testTargetName() {
166:                configureProject("src/etc/testcases/taskdefs/import/c.xml");
167:            }
168:
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.