Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 43405 invoked from network); 14 Nov 2001 13:54:26 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 14 Nov 2001 13:54:26 -0000 Received: (qmail 20835 invoked by uid 97); 14 Nov 2001 13:54:18 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 20780 invoked by uid 97); 14 Nov 2001 13:54:17 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 20769 invoked by uid 97); 14 Nov 2001 13:54:17 -0000 Date: 14 Nov 2001 13:40:53 -0000 Message-ID: <20011114134053.90523.qmail@icarus.apache.org> From: conor@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs ManifestTest.java JarTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N conor 01/11/14 05:40:53 Modified: src/main/org/apache/tools/ant/taskdefs Manifest.java src/testcases/org/apache/tools/ant BuildFileTest.java src/testcases/org/apache/tools/ant/taskdefs JarTest.java Added: src/etc/testcases/taskdefs manifest.xml src/etc/testcases/taskdefs/manifests test1.mf test2.mf test3.mf test4.mf test5.mf src/testcases/org/apache/tools/ant/taskdefs ManifestTest.java Log: Initial cut at Manifest tests. This is in preparation for handling multiple Class-Path entries. More to come. Revision Changes Path 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifest.xml Index: manifest.xml =================================================================== 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifests/test1.mf Index: test1.mf =================================================================== 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifests/test2.mf Index: test2.mf =================================================================== Manifest-Version: 2.0 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifests/test3.mf Index: test3.mf =================================================================== Manifest-Version: 1.0 Header-without-colon maybe mistyped 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifests/test4.mf Index: test4.mf =================================================================== Manifest-Version: 1.0 Can't start with a continuation line 1.1 jakarta-ant/src/etc/testcases/taskdefs/manifests/test5.mf Index: test5.mf =================================================================== Manifest-Version: 1.0 Name: test5 1.8 +4 -3 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java Index: Manifest.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -u -r1.7 -r1.8 --- Manifest.java 2001/10/28 21:26:29 1.7 +++ Manifest.java 2001/11/14 13:40:53 1.8 @@ -149,7 +149,8 @@ public void parse(String line) throws ManifestException { int index = line.indexOf(": "); if (index == -1) { - throw new ManifestException("Manifest line \"" + line + "\" is not valid"); + throw new ManifestException("Manifest line \"" + line + "\" is not valid as it does not " + + "contain a name and a value separated by ': ' "); } name = line.substring(0, index); value = line.substring(index + 2); @@ -377,8 +378,8 @@ public void addConfiguredAttribute(Attribute attribute) throws ManifestException { String check = addAttributeAndCheck(attribute); if (check != null) { - throw new BuildException("Use the \"name\" attribute of the
element rather than using " + - "the \"Name\" attribute"); + throw new BuildException("Specify the section name using the \"name\" attribute of the
element rather " + + "than using a \"Name\" manifest attribute"); } } 1.3 +15 -2 jakarta-ant/src/testcases/org/apache/tools/ant/BuildFileTest.java Index: BuildFileTest.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/BuildFileTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -u -r1.2 -r1.3 --- BuildFileTest.java 2001/11/09 13:45:04 1.2 +++ BuildFileTest.java 2001/11/14 13:40:53 1.3 @@ -200,13 +200,26 @@ try { executeTarget(target); } catch (org.apache.tools.ant.BuildException ex) { - if ((null != msg) && (ex.getMessage() != msg)) { - fail("Should throw BuildException because '" + cause + "' with message '" + msg + "' (received message '" + ex.getMessage() + "' instead)"); + if ((null != msg) && (!ex.getMessage().equals(msg))) { + fail("Should throw BuildException because '" + cause + "' with message '" + msg + "' (actual message '" + ex.getMessage() + "' instead)"); } return; } fail("Should throw BuildException because: " + cause); } + + protected void expectBuildExceptionContaining(String target, String cause, String contains) { + try { + executeTarget(target); + } catch (org.apache.tools.ant.BuildException ex) { + if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) { + fail("Should throw BuildException because '" + cause + "' with message containing'" + contains + "' (actual message '" + ex.getMessage() + "' instead)"); + } + return; + } + fail("Should throw BuildException because: " + cause); + } + private class AntOutputStream extends java.io.OutputStream { public void write(int b) { outBuffer.append((char)b); 1.6 +1 -1 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java Index: JarTest.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -u -r1.5 -r1.6 --- JarTest.java 2001/11/14 12:25:30 1.5 +++ JarTest.java 2001/11/14 13:40:53 1.6 @@ -79,7 +79,7 @@ } public void test2() { - expectBuildException("test2", "manifect file does not exist"); + expectBuildException("test2", "manifest file does not exist"); } public void test3() { 1.1 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java Index: ManifestTest.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 2000 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 java.io.File; import java.util.Date; import org.apache.tools.ant.BuildFileTest; /** * Testcase for the Manifest class used in the jar task. * * @author Conor MacNeill */ public class ManifestTest extends BuildFileTest { public ManifestTest(String name) { super(name); } public void setUp() { configureProject("src/etc/testcases/taskdefs/manifest.xml"); } public void tearDown() { executeTarget("clean"); } /** * Empty manifest - is OK */ public void test1() { executeTarget("test1"); } /** * Simple Manifest with version 2.0 */ public void test2() { executeTarget("test2"); } /** * Malformed manifest - no : on the line */ public void test3() { expectBuildExceptionContaining("test3", "Manifest is invalid - no colon on header line", "Invalid Manifest"); } /** * Malformed manifest - starts with continuation line */ public void test4() { expectBuildExceptionContaining("test4", "Manifest is invalid - section starts with continuation line", "Invalid Manifest"); } /** * Malformed manifest - Name attribute in main section */ public void test5() { executeTarget("test5"); String output = getLog(); boolean hasWarning = output.indexOf("Manifest warning: \"Name\" attributes should not occur in the main section") != -1; assertEquals("Expected warning about Name in main section", true, hasWarning); } } -- To unsubscribe, e-mail: For additional commands, e-mail: