Browse Source

antunit-ize and FIX (they were severely broken) DependSet tests

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@477939 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 19 years ago
parent
commit
b994c52004
3 changed files with 101 additions and 175 deletions
  1. +0
    -105
      src/etc/testcases/taskdefs/dependset.xml
  2. +101
    -0
      src/tests/antunit/taskdefs/dependset-test.xml
  3. +0
    -70
      src/tests/junit/org/apache/tools/ant/taskdefs/DependSetTest.java

+ 0
- 105
src/etc/testcases/taskdefs/dependset.xml View File

@@ -1,105 +0,0 @@
<?xml version="1.0"?>

<project name="dependset-test" basedir="." default="test1">

<target name="test1">
<dependset/>
</target>

<target name="test2">
<dependset>
<srcfilelist dir="." includes="test2.tmp"/>
</dependset>
</target>

<target name="test3">
<dependset>
<targetfileset dir="." files="test3.tmp"/>
</dependset>
</target>

<target name="test4">
<touch file="test4.tmp"/>
<dependset>
<srcfilelist dir="." files="test4.tmp"/>
<targetfileset id="targetfs" dir="." includes="i-do-not-exist"/>
</dependset>
</target>

<target name="test5">
<touch file="older.tmp"/>
<sleep seconds="3" />
<touch file="newer.tmp"/>
<dependset>
<srcfilelist dir="." files="newer.tmp"/>
<targetfilelist dir="." files="older.tmp"/>
</dependset>
<fail>
<condition>
<available file="older.tmp" />
</condition>
</fail>
</target>

<target name="test6">
<touch file="older.tmp"/>
<sleep seconds="3" />
<touch file="newer.tmp"/>
<dependset>
<sources>
<file file="newer.tmp" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<fail>
<condition>
<available file="older.tmp" />
</condition>
</fail>
</target>

<target name="test7">
<touch file="older.tmp"/>
<dependset>
<sources>
<propertyresource name="thereisnosuchproperty" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<fail>
<condition>
<available file="older.tmp" />
</condition>
</fail>
</target>

<target name="test8">
<touch file="older.tmp" />
<property name="foo" value="bar" />
<dependset>
<sources>
<propertyresource name="foo" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<fail>
<condition>
<not>
<available file="older.tmp" />
</not>
</condition>
</fail>
</target>

<target name="cleanup">
<delete file="test4.tmp"/>
<delete file="older.tmp"/>
<delete file="newer.tmp"/>
</target>
</project>

+ 101
- 0
src/tests/antunit/taskdefs/dependset-test.xml View File

@@ -0,0 +1,101 @@
<?xml version="1.0"?>

<project name="dependset-test" xmlns:au="antlib:org.apache.ant.antunit">

<target name="test1">
<au:expectfailure expectedMessage="At least one set of source resources must be specified">
<dependset />
</au:expectfailure>
</target>

<target name="test2">
<au:expectfailure expectedMessage="At least one set of target files must be specified">
<dependset>
<srcfilelist dir="." files="test2.tmp" />
</dependset>
</au:expectfailure>
</target>

<target name="test3">
<au:expectfailure expectedMessage="At least one set of source resources must be specified">
<dependset>
<targetfileset dir="." includes="test3.tmp" />
</dependset>
</au:expectfailure>
</target>

<target name="test4">
<touch file="test4.tmp" />
<dependset>
<srcfilelist dir="." files="test4.tmp" />
<targetfileset id="targetfs" dir="." includes="i-do-not-exist" />
</dependset>
</target>

<target name="test5">
<touch file="older.tmp" />
<sleep seconds="3" />
<touch file="newer.tmp" />
<dependset>
<srcfilelist dir="." files="newer.tmp" />
<targetfilelist dir="." files="older.tmp" />
</dependset>
<au:assertFalse>
<available file="older.tmp" />
</au:assertFalse>
</target>

<target name="test6">
<touch file="older.tmp" />
<sleep seconds="3" />
<touch file="newer.tmp" />
<dependset>
<sources>
<file file="newer.tmp" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<au:assertFalse>
<available file="older.tmp" />
</au:assertFalse>
</target>

<target name="test7">
<touch file="older.tmp" />
<dependset>
<sources>
<propertyresource name="thereisnosuchproperty" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<au:assertFalse>
<available file="older.tmp" />
</au:assertFalse>
</target>

<target name="test8">
<touch file="older.tmp" />
<property name="foo" value="bar" />
<dependset>
<sources>
<propertyresource name="foo" />
</sources>
<targets>
<filelist dir="." files="older.tmp" />
</targets>
</dependset>
<au:assertTrue>
<available file="older.tmp" />
</au:assertTrue>
</target>

<target name="tearDown">
<delete file="test4.tmp" />
<delete file="older.tmp" />
<delete file="newer.tmp" />
</target>
</project>

+ 0
- 70
src/tests/junit/org/apache/tools/ant/taskdefs/DependSetTest.java View File

@@ -1,70 +0,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.
*
*/

package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.BuildFileTest;

/**
* Tests DependSet.
*
*/
public class DependSetTest extends BuildFileTest {

public DependSetTest(String name) {
super(name);
}

public void setUp() {
configureProject("src/etc/testcases/taskdefs/dependset.xml");
}

public void test1() {
expectBuildException("test1","At least one <srcfileset> or <srcfilelist> element must be set");
}

public void tearDown() {
executeTarget("cleanup");
}

public void test2() {
expectBuildException("test2","At least one <targetfileset> or <targetfilelist> element must be set");
}

public void test3() {
expectBuildException("test1","At least one <srcfileset> or <srcfilelist> element must be set");
}

public void test4() {
executeTarget("test4");
}

public void test5() {
executeTarget("test5");
}

public void test6() {
executeTarget("test6");
}
public void test7() {
executeTarget("test7");
}
public void test8() {
executeTarget("test8");
}
}

Loading…
Cancel
Save