aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/get-test.xml
blob: 0bca337c73c10ad10a27a1a15cf0f2bc05e6e340 (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
<?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 name="get-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
  <import file="../antunit-base.xml" />

  <property name="location" value="http://ant.apache.org/webtest/gettest" />
    
  <target name="setUp">
    <mkdir dir="${output}" />
  </target>

  <target name="testSeeOtherRedirect">
    <get  src="${location}/other.txt" dest="${output}/other.tmp"/>
      <au:assertTrue>
            <resourcecount count="1">
              <restrict>
                <file file="${output}/other.tmp" />
                <contains text="seeother redirect succeeded" />
              </restrict>
            </resourcecount>
          </au:assertTrue>
    <au:assertLogContains text="other.txt moved to http" />  
  </target>
    
    <target name="testPermanentRedirect">
      <get  src="${location}/permanent.txt" dest="${output}/permanent.tmp"/>
        <au:assertTrue>
          <resourcecount count="1">
            <restrict>
              <file file="${output}/permanent.tmp" />
              <contains text="permanent redirect succeeded" />
            </restrict>
          </resourcecount>
        </au:assertTrue>
        <au:assertLogContains text="permanent.txt permanently moved to http" />
    </target>
    
    <target name="testTemporaryRedirect">
      <get  src="${location}/temp.txt" dest="${output}/temp.txt"/>
        <au:assertTrue>
          <resourcecount count="1">
            <restrict>
              <file file="${output}/temp.txt" />
              <contains text="temporary redirect succeeded" />
            </restrict>
          </resourcecount>
        </au:assertTrue>
        <au:assertLogContains text="temp.txt moved to http" />
    </target>
    
    <target name="testStatusCode307Redirect">
      <get  src="${location}/307.txt" dest="${output}/307.txt"/>
        <au:assertTrue>
          <resourcecount count="1">
            <restrict>
              <file file="${output}/307.txt" />
              <contains text="307 status code redirect succeeded" />
            </restrict>
          </resourcecount>
        </au:assertTrue>
        <au:assertLogContains text="307.txt moved to http" />
    </target>
    
    <target name="test5LevelsOfRedirect">
      <get  src="${location}/redir5.txt" dest="${output}/redir5.tmp"/>
        <au:assertTrue>
          <resourcecount count="1">
            <restrict>
              <file file="${output}/redir5.tmp" />
              <contains text="5 levels of redirect succeeded" />
            </restrict>
          </resourcecount>
        </au:assertTrue>

        <au:assertLogContains text="redir5.txt moved to http" />

        <au:assertLogContains text="redir5-4.txt moved to http" />
    </target>
    
    
    <target name="testInfiniteRedirect">
        <au:expectfailure expectedmessage="More than 25 times redirected, giving up">
      <get  src="${location}/infinite.txt" dest="${output}/infinite.tmp"/>
        </au:expectfailure>
    </target>


    <target name="testNestedResources">
      <get dest="${output}/downloads">
        <url url="http://ant.apache.org/index.html"/> 
        <url url="http://ant.apache.org/faq.html"/>
      </get>
      <au:assertFileExists file="${output}/downloads/index.html"/>
      <au:assertFileExists file="${output}/downloads/faq.html"/>
    </target>

  <target name="XtestRelativeRedirect">
    <get  src="${location}/local.cgi" dest="${output}/other.tmp"/>
    <au:assertTrue>
      <resourcecount count="1">
        <restrict>
          <file file="${output}/other.tmp" />
          <contains text="local redirect succeeded"/>
        </restrict>
      </resourcecount>
    </au:assertTrue>
    <au:assertLogContains text="local.cgi moved to http" />  
  </target>
</project>