diff --git a/build.xml b/build.xml index bf049862b..dd507fac4 100644 --- a/build.xml +++ b/build.xml @@ -547,6 +547,8 @@ + @@ -565,6 +567,8 @@ src="${dist.base}/bin/${dist.name}-bin.tar"/> + @@ -572,6 +576,8 @@ + @@ -588,6 +594,8 @@ src="${dist.base}/src/${dist.name}-src.tar"/> + diff --git a/docs/manual/CoreTasks/checksum.html b/docs/manual/CoreTasks/checksum.html index 4775c957c..cec54ca6c 100644 --- a/docs/manual/CoreTasks/checksum.html +++ b/docs/manual/CoreTasks/checksum.html @@ -134,8 +134,9 @@ Works just like Example 1, but generates a .MD5 file for every file that begins </checksum> </condition> -Works like Example 4, but sets isChecksumEqual to either true or false. -This example demonstrates use with the Condition task. +Works like Example 4, but only sets isChecksumEqual to true, if the +checksum matches - it will never be set to false. This example +demonstrates use with the Condition task.

Note:

diff --git a/src/etc/testcases/asf-logo.gif b/src/etc/testcases/asf-logo.gif new file mode 100644 index 000000000..22eb9d735 Binary files /dev/null and b/src/etc/testcases/asf-logo.gif differ diff --git a/src/etc/testcases/taskdefs/checksum.xml b/src/etc/testcases/taskdefs/checksum.xml new file mode 100644 index 000000000..b0ea72e11 --- /dev/null +++ b/src/etc/testcases/taskdefs/checksum.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/etc/testcases/taskdefs/expected/asf-logo.gif.md5 b/src/etc/testcases/taskdefs/expected/asf-logo.gif.md5 new file mode 100644 index 000000000..5c886a5f5 --- /dev/null +++ b/src/etc/testcases/taskdefs/expected/asf-logo.gif.md5 @@ -0,0 +1 @@ +0541d3df42520911f268abc730f3afe0 \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ChecksumTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ChecksumTest.java new file mode 100644 index 000000000..d8d558c00 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/ChecksumTest.java @@ -0,0 +1,113 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Ant", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package org.apache.tools.ant.taskdefs; + +import org.apache.tools.ant.BuildFileTest; +import org.apache.tools.ant.util.FileUtils; + +import java.io.IOException; + +/** + * @author Stefan Bodewig + * @version $Revision$ + */ +public class ChecksumTest extends BuildFileTest { + + public ChecksumTest(String name) { + super(name); + } + + public void setUp() { + configureProject("src/etc/testcases/taskdefs/checksum.xml"); + } + + public void tearDown() { + executeTarget("cleanup"); + } + + public void testCreateMd5() throws IOException { + FileUtils fileUtils = FileUtils.newFileUtils(); + executeTarget("createMd5"); + assertTrue(fileUtils.contentEquals(project.resolveFile("expected/asf-logo.gif.md5"), + project.resolveFile("../asf-logo.gif.md5"))); + } + + public void testSetProperty() { + executeTarget("setProperty"); + assertEquals("0541d3df42520911f268abc730f3afe0", + project.getProperty("logo.md5")); + assertTrue(!project.resolveFile("../asf-logo.gif.MD5").exists()); + } + + public void testVerifyAsTask() { + testVerify("verifyAsTask"); + assertNotNull(project.getProperty("no.logo.md5")); + assertEquals("false", project.getProperty("no.logo.md5")); + } + + public void testVerifyAsCondition() { + testVerify("verifyAsCondition"); + assertNull(project.getProperty("no.logo.md5")); + } + + private void testVerify(String target) { + assertNull(project.getProperty("logo.md5")); + assertNull(project.getProperty("no.logo.md5")); + executeTarget(target); + assertNotNull(project.getProperty("logo.md5")); + assertEquals("true", project.getProperty("logo.md5")); + } + +}