ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r530664 - in /ant/core/trunk: docs/manual/CoreTasks/manifest.html src/etc/testcases/taskdefs/manifest.xml src/main/org/apache/tools/ant/taskdefs/ManifestTask.java src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
Date Fri, 20 Apr 2007 06:25:06 GMT
Author: jhm
Date: Thu Apr 19 23:25:05 2007
New Revision: 530664

URL: http://svn.apache.org/viewvc?view=rev&rev=530664
Log:
Add tests. Document the regexp for attribute name.

Modified:
    ant/core/trunk/docs/manual/CoreTasks/manifest.html
    ant/core/trunk/src/etc/testcases/taskdefs/manifest.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java

Modified: ant/core/trunk/docs/manual/CoreTasks/manifest.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/manifest.html?view=diff&rev=530664&r1=530663&r2=530664
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/manifest.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/manifest.html Thu Apr 19 23:25:05 2007
@@ -94,7 +94,9 @@
   </tr>
   <tr>
     <td valign="top">name</td>
-    <td valign="top">the name of the attribute.</td>
+    <td valign="top">the name of the attribute, <br>
+        must match the regexp <tt>[A-Za-z0-9][A-Za-z0-9-_]*</tt>.
+    </td>
     <td valign="top" align="center">Yes</td>
   </tr>
   <tr>

Modified: ant/core/trunk/src/etc/testcases/taskdefs/manifest.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/manifest.xml?view=diff&rev=530664&r1=530663&r2=530664
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/manifest.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/manifest.xml Thu Apr 19 23:25:05 2007
@@ -227,6 +227,24 @@
     </manifest>
   </target>
 
+  <target name="testIllegalNameBegin">
+    <manifest file="mftestillegalnamebegin.mf">
+      <attribute name="-name" value="value"/>
+    </manifest>
+  </target>
+
+  <target name="testIllegalName2">
+    <manifest file="mftestillegalnamebegin.mf">
+      <attribute name="has.point" value="value"/>
+    </manifest>
+  </target>
+
+  <target name="testIllegalName3">
+    <manifest file="mftestillegalnamebegin.mf">
+      <attribute name="has*star" value="value"/>
+    </manifest>
+  </target>
+
   <target name="clean">
     <delete>
       <fileset dir="." includes="mftest*"/>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java?view=diff&rev=530664&r1=530663&r2=530664
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java Thu Apr 19 23:25:05
2007
@@ -139,20 +139,20 @@
      * check each character.
      * 
      * @param attribute The attribute to check
-     * @throws ManifestException if the check fails
+     * @throws BuildException if the check fails
      */
-    private void checkAttribute(Manifest.Attribute attribute) throws ManifestException {
+    private void checkAttribute(Manifest.Attribute attribute) throws BuildException {
         String name = attribute.getName();
         char ch = name.charAt(0);
 
         if (ch == '-' || ch == '_') {
-            throw new ManifestException("Manifest attribute names must not contain '" + ch
+ "'");
+            throw new BuildException("Manifest attribute names must not contain '" + ch +
"' at the begin.");
         }
         
         for (int i = 0; i < name.length(); i++) {
             ch = name.charAt(i);
             if (VALID_ATTRIBUTE_CHARS.indexOf(ch) < 0) {
-                throw new ManifestException("Manifest attribute names must not contain '"
+ ch + "'");
+                throw new BuildException("Manifest attribute names must not contain '" +
ch + "'");
             }
         }
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java?view=diff&rev=530664&r1=530663&r2=530664
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java Thu Apr
19 23:25:05 2007
@@ -331,17 +331,27 @@
     public void testFrom() {
         expectLogContaining("testFrom", Manifest.ERROR_FROM_FORBIDDEN);
     }
-    
+
     public void testIllegalName() {
-        //expectBuildException("testIllegalName", "Attribute name is not valid according
to the specification.");
+        expectBuildException("testIllegalName", "Manifest attribute names must not contain
' '");
     }
-    
+
     public void testIllegalNameInSection() {
-        //expectBuildException("testIllegalNameInSection", "Attribute name is not valid according
to the specification.");
+        expectBuildException("testIllegalNameInSection", "Manifest attribute names must not
contain ' '");
     }
-    
-    
-    
+
+    public void testIllegalNameBegin() {
+        expectBuildException("testIllegalNameInSection", "Manifest attribute names must not
contain '-' at the begin.");
+    }
+
+    public void testIllegalName2() {
+        expectBuildException("testIllegalName", "Manifest attribute names must not contain
'.'");
+    }
+
+    public void testIllegalName3() {
+        expectBuildException("testIllegalName", "Manifest attribute names must not contain
'*'");
+    }
+
     /**
      * Reads mftest.mf.
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message