<?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 xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
  <import file="C:/ant/svn-repository/ant/core/src/tests/antunit/antunit-base.xml"/>
  <taskdef name="autoconf" classname="org.apache.tools.ant.taskdefs.AutoconfTask" classpath="../../build/classes"/>
  
  <target name="testIgnoreNonAttributeValues">
    <property name="echo.notAnAttribute" value="Default Message"/>
    <autoconf/>
    <echo/>
    <au:assertLogDoesntContain text="Default Message"/>
  </target>
  
  <target name="testNoDefault">
    <autoconf/>
    <echo message="Individual Message"/>
    <au:assertLogContains text="Individual Message"/>
  </target>
  
  <target name="testDirectValue">
    <property name="echo.message" value="Default Message"/>
    <autoconf/>
    <echo message="Individual Message"/>
    <au:assertLogContains text="Individual Message"/>
  </target>

  <target name="testDefault">
    <property name="echo.message" value="Default Message"/>
    <autoconf/>
    <echo/>
    <au:assertLogContains text="Default Message"/>
  </target>
  
  <target name="testPresetDef">
    <property name="myecho.message" value="Default Message"/>
    <presetdef name="myecho"><echo/></presetdef>
    <autoconf/>
    <myecho/>
    <au:assertLogContains text="Default Message"/>
  </target>

  <target name="testPresetDefIndividualValue">
    <property name="myecho.message" value="Default Message"/>
    <presetdef name="myecho"><echo/></presetdef>
    <autoconf/>
    <myecho message="Individual Message"/>
    <au:assertLogContains text="Individual Message"/>
  </target>

  <target name="testPresetDefButTasknameProperty">
    <property name="myecho.message" value="Default Preset Message"/>
    <property name="echo.message" value="Default Task Message"/>
    <presetdef name="myecho"><echo/></presetdef>
    <autoconf/>
    <myecho/>
    <au:assertLogContains text="Default Preset Message"/>
  </target>
  
  <target name="testMacroDef">
    <property name="myecho.message" value="Default Message"/>
    <macrodef name="myecho">
      <attribute name="message"/>
      <sequential>
        <echo message="@{message}"/>
      </sequential>
    </macrodef>
    <autoconf/>
    <myecho/>
    <au:assertLogContains text="Default Message"/>
  </target>

  <target name="testMacroDefIndividualValue">
    <property name="myecho.message" value="Default Message"/>
    <macrodef name="myecho">
      <attribute name="message"/>
      <sequential>
        <echo message="@{message}"/>
      </sequential>
    </macrodef>
    <autoconf/>
    <myecho message="Individual Message"/>
    <au:assertLogContains text="Individual Message"/>
  </target>
  
  <target name="testStartStop">
    <property name="myecho.message" value="Autoconf Message"/>
    <presetdef name="myecho"><echo message="Default Message"/></presetdef>
    <myecho/>
    <au:assertLogContains text="Default Message"/>
    <autoconf/>
    <myecho/>
    <au:assertLogContains text="Autoconf Message"/>
    <autoconf action="stop"/>
    <myecho/>
    <au:assertLogContains text="Default Message"/>
  </target>
  
  <target name="testPrefix">
    <property name="echo.message" value="wrong message"/>
    <property name="prefix.echo.message" value="correct message"/>
    <autoconf prefix="prefix."/>
    <echo/>
    <au:assertLogContains text="correct message"/>
  </target>
</project>