aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/import-url-test.xml
blob: 103ece3ec3b0d524e91a6336df73040b51d19528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
  <import file="../antunit-base.xml" />

  <mkdir dir="${output}"/>
  <mkdir dir="${input}/a/b"/>
  <mkdir dir="${input}/a/c"/>
  <echo file="${input}/a/b/outer.xml"><![CDATA[
<project name="outer">
  <import file="../c/inner.xml"/>
</project>
]]></echo>
  <echo file="${input}/a/c/inner.xml"><![CDATA[
<project name="inner">
  <target name="foo">
    <echo>In inner</echo>
    <echo>ant.file.inner is ${ant.file.inner}</echo>
    <echo>type is ${ant.file.type.inner}</echo>
    <loadproperties>
      <url baseUrl="${ant.file.inner}" relativePath="test.properties"/>
    </loadproperties>
    <echo>foo is ${foo}</echo>
  </target>
</project>]]></echo>
  <echo file="${input}/a/c/test.properties"><![CDATA[
foo=bar
]]></echo>
  <echo file="${input}/a/b/external-import.xml"><![CDATA[
<project name="external-import">
  <import file="${output}/imported.xml"/>
</project>
]]></echo>
  <echo file="${output}/imported.xml"><![CDATA[
<project name="imported">
  <target name="bar">
    <echo>In imported</echo>
  </target>
</project>
]]></echo>
  <jar destfile="${test.jar}">
    <fileset dir="${input}"/>
  </jar>
  <delete dir="${input}"/>

  <import>
    <javaresource name="a/b/outer.xml">
      <classpath location="${test.jar}"/>
    </javaresource>
  </import>
  <import>
    <javaresource name="a/b/outer.xml">
      <classpath location="${test.jar}"/>
    </javaresource>
  </import>
  <import>
    <javaresource name="a/b/external-import.xml">
      <classpath location="${test.jar}"/>
    </javaresource>
  </import>

  <target name="testImportOfNestedFile" depends="foo">
    <au:assertLogContains text="In inner"/>
    <au:assertLogContains text="type is url"/>
    <au:assertLogContains text="foo is bar"/>
  </target>

  <target name="testImportOfNestedFileWithAbsolutePath" depends="bar"
          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50953">
    <au:assertLogContains text="In imported"/>
  </target>

  <target name="tearDown">
    <taskdef name="close"
             classname="org.apache.tools.ant.taskdefs.CloseResources"/>
    <close>
      <javaresource name="a/b/outer.xml">
        <classpath location="${test.jar}"/>
      </javaresource>
    </close>
    <delete file="${test.jar}" quiet="true" deleteonexit="true"/>
    <!-- Calling antunit-base.tearDown sometimes causes ISEs in <import> in Ant-Build-Matrix: -->
    <delete dir="${input}"/>
    <delete dir="${output}"/>
  </target>
</project>