| <?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="ant-attribute-test" default="antunit" |
| xmlns:au="antlib:org.apache.ant.antunit" |
| xmlns:if="ant:if" |
| xmlns:unless="ant:unless" |
| > |
| |
| <import file="../antunit-base.xml" /> |
| |
| <target name="test-if-set"> |
| <echo message="message1" if:set="not-set"/> |
| <au:assertLogDoesntContain text="message1"/> |
| </target> |
| |
| <target name="test-unless-set"> |
| <echo message="message2" unless:set="not-set"/> |
| <au:assertLogContains text="message2"/> |
| </target> |
| |
| <target name="test-if-true"> |
| <property name="sample" value="true"/> |
| <echo message="message3" if:true="${sample}"/> |
| <au:assertLogContains text="message3"/> |
| </target> |
| |
| <target name="test-if-true-false"> |
| <property name="sample-1" value="false"/> |
| <echo message="message4" if:true="${sample-1}"/> |
| <au:assertLogDoesntContain text="message4"/> |
| </target> |
| |
| <target name="test-unless-true-false"> |
| <property name="sample-1" value="false"/> |
| <echo message="message5" unless:true="${sample-1}"/> |
| <au:assertLogContains text="message5"/> |
| </target> |
| |
| <target name="test-if-blank"> |
| <property name="sample-1" value=""/> |
| <echo message="message6" if:blank="${sample-1}"/> |
| <au:assertLogContains text="message6"/> |
| </target> |
| |
| |
| |
| |
| <target name="test-macrodef"> |
| <property name="verbose" value="true"/> |
| <macrodef name="sayhi"> |
| <sequential> |
| <echo>hi</echo> |
| </sequential> |
| </macrodef> |
| <sayhi if:set="verbose" /> |
| <au:assertLogContains text="hi"/> |
| </target> |
| |
| </project> |