aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/javadoc-test.xml
blob: 200082bab5472c6e157c9f7984e408366e642029 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?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" />

  <target name="-makeTestClass">
    <macrodef name="mktest">
      <attribute name="package"/>
      <attribute name="class"/>
      <sequential>
        <mkdir dir="${input}/@{package}"/>
        <echo file="${input}/@{package}/@{class}.java"><![CDATA[
package @{package};

/**
 * This is a test class.
 */
public class @{class} {
    /**
     * With a test method.
     */
    public void foo(String bar) {}
}
]]></echo>
      </sequential>
    </macrodef>
    <mktest package="test" class="A"/>
  </target>

  <target name="-makeTwoTestClasses" depends="-makeTestClass">
    <mktest package="test2" class="B"/>
  </target>

  <target name="testBottomWithLineBreaksWithFile" depends="-makeTestClass">
    <javadoc destdir="${output}" useexternalfile="true">
      <fileset dir="${input}"/>
      <bottom><![CDATA[
<hr/>
Hello World
]]></bottom>
    </javadoc>
    <au:assertFileExists file="${output}/test/A.html"/>
  </target>

  <target name="-setUpDocFilesTests" depends="-makeTestClass">
    <mkdir dir="${input}/test/doc-files/a"/>
    <mkdir dir="${input}/test/doc-files/b"/>
    <macrodef name="mkfoo">
      <attribute name="file"/>
      <sequential>
        <echo file="@{file}"><![CDATA[<p>Hello, world!</p>]]></echo>
      </sequential>
    </macrodef>
    <mkfoo file="${input}/test/doc-files/foo.html"/>
    <mkfoo file="${input}/test/doc-files/a/foo.html"/>
    <mkfoo file="${input}/test/doc-files/b/foo.html"/>
  </target>

  <target name="-create-file-with-warning">
    <mkdir dir="${input}/test"/>
        <echo file="${input}/test/Foo.java"><![CDATA[
package test;

/**
 * This is a test class.
 */
public class Foo {
    /**
     * With a test method.
     * @param baz wrong parameter name should cause warning.
     */
    public void foo(String bar) {}
}
]]></echo>
  </target>

  <target name="testPackageSetNoExcludes" depends="-makeTwoTestClasses">
    <javadoc destdir="${output}">
      <packageset dir="${input}"/>
    </javadoc>
    <au:assertFileExists file="${output}/test/A.html"/>
    <au:assertFileExists file="${output}/test2/B.html"/>
  </target>

  <target name="testPackageSetWithExcludes"
          depends="-makeTwoTestClasses"
          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=47196">
    <javadoc destdir="${output}">
      <packageset dir="${input}">
        <exclude name="test2"/>
      </packageset>
    </javadoc>
    <au:assertFileExists file="${output}/test/A.html"/>
    <au:assertFileDoesntExist file="${output}/test2/B.html"/>
  </target>

  <!-- basically tests no exception is thrown -->
  <target name="testDontFailOnWarning"
          depends="-create-file-with-warning">
    <javadoc destdir="${output}">
      <packageset dir="${input}"/>
    </javadoc>
  </target>

  <target name="testFailOnWarning"
          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=55015"
          depends="-create-file-with-warning">
    <au:expectfailure>
      <javadoc destdir="${output}" failonwarning="true">
        <packageset dir="${input}"/>
      </javadoc>
    </au:expectfailure>
  </target>

  <target name="XtestNoDocFiles" depends="-setUpDocFilesTests">
    <javadoc destdir="${output}">
      <packageset dir="${input}"/>
    </javadoc>
    <au:assertFileExists file="${output}/test/doc-files/foo.html"/>
    <au:assertFileDoesntExist file="${output}/test/doc-files/a/foo.html"/>
  </target>

  <target name="XtestDocFiles" depends="-setUpDocFilesTests">
    <javadoc destdir="${output}" docfilessubdirs="true">
      <packageset dir="${input}"/>
    </javadoc>
    <au:assertFileExists file="${output}/test/doc-files/foo.html"/>
    <au:assertFileExists file="${output}/test/doc-files/a/foo.html"/>
    <au:assertFileExists file="${output}/test/doc-files/b/foo.html"/>
  </target>

  <target name="XtestDocFilesWithExclude" depends="-setUpDocFilesTests">
    <javadoc destdir="${output}" docfilessubdirs="true"
             excludedocfilessubdir="a">
      <packageset dir="${input}"/>
    </javadoc>
    <au:assertFileExists file="${output}/test/doc-files/foo.html"/>
    <au:assertFileDoesntExist file="${output}/test/doc-files/a/foo.html"/>
    <au:assertFileExists file="${output}/test/doc-files/b/foo.html"/>
  </target>

</project>