ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1026334 - in /ant/core/trunk/src: etc/testcases/taskdefs/signjar.xml tests/antunit/taskdefs/signjar-test.xml tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
Date Fri, 22 Oct 2010 14:08:10 GMT
Author: bodewig
Date: Fri Oct 22 14:08:09 2010
New Revision: 1026334

URL: http://svn.apache.org/viewvc?rev=1026334&view=rev
Log:
move bulk of signjar tests to AntUnit tests

Added:
    ant/core/trunk/src/tests/antunit/taskdefs/signjar-test.xml
      - copied, changed from r1026315, ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml
Modified:
    ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java

Modified: ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml?rev=1026334&r1=1026333&r2=1026334&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml Fri Oct 22 14:08:09 2010
@@ -85,18 +85,12 @@
     <assertSigned/>             
   </target>
 
-  <target name="maxmemory" depends="jar">
-    <sign maxmemory="128m"/>
-    <assertSigned/>             
-  </target>
-
   <target name="urlKeystoreFile" depends="jar">
     <sign keystore="file://../testkeystore"
        maxmemory="128m"/>
     <assertSigned/>             
   </target>
 
-  
   <target name="urlKeystoreHTTP" depends="jar">
     <sign
       keystore="http://ant.apache.org/webtest/testkeystore"
@@ -104,191 +98,9 @@
     <assertSigned/>             
   </target>
 
-  <target name="preserveLastModified" depends="jar">
-    <touch file="${test.jar}" datetime="06/28/2000 2:02 pm"/>
-    <sign 
-    	preservelastmodified="true"/>
-    <assertSigned />
-    <fail message="preserveLastModified did not preserve the last modified time">
-      <condition>
-        <not>
-          <isfileselected file="${test.jar}" >
-            <date datetime="06/28/2000 2:02 pm" when="equal"/>
-          </isfileselected>
-        </not>
-      </condition>
-    </fail>
-  </target>
-
-  <target name="testFileset" depends="jar">
-    <sign-base>
-      <fileset file="${test.jar}" />
-    </sign-base>
-    <assertSigned/>
-  </target>
-
-  <target name="testFilesetAndJar" depends="jar">
-    <sign-base jar="${test.jar}" lazy="true">
-      <fileset file="${test.jar}" />
-    </sign-base>
-    <assertSigned/>
-  </target>
-  
-  <target name="testFilesetAndSignedJar" depends="jar">
-    <sign-base signedjar="${sign.dir}/newfile.jar">
-      <fileset file="${test.jar}" />
-    </sign-base>
-  </target>
-  
-  <target name="testPath" depends="jar">
-    <sign-base>
-      <path>
-        <fileset file="${test.jar}" />
-      </path>
-    </sign-base>
-    <assertSigned/>
-  </target>
-
-  <target name="testPathAndJar" depends="jar">
-    <sign-base jar="${test.jar}" lazy="true">
-      <path>
-        <fileset file="${test.jar}" />
-      </path>
-    </sign-base>
-    <assertSigned/>
-  </target>
-  
-  <target name="testPathAndSignedJar" depends="jar">
-    <sign-base signedjar="${sign.dir}/newfile.jar">
-      <path>
-        <fileset file="${test.jar}" />
-      </path>
-    </sign-base>
-  </target>
-  
-  <target name="testSignedJar" depends="jar">
-    <sign signedjar="${subdirtest.jar}"/>
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-
-  <target name="testDestDirAndSignedJar" depends="jar">
-    <sign destDir="${subdir}" signedjar="${sign.dir}/newfile.jar"/>
-  </target>
-
-  <target name="testDestDir" depends="jar">
-    <sign destDir="${subdir}" />
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-  
-  <target name="testDestDirFileset" depends="jar">
-    <sign-base destDir="${subdir}">
-      <fileset file="${test.jar}" />
-    </sign-base>
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-  
-  <target name="testDestDirPath" depends="jar">
-    <sign-base destDir="${subdir}">
-      <path>
-        <fileset file="${test.jar}" />
-      </path>
-    </sign-base>
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-  
-  <target name="testMapperNoDest" depends="jar">
-    <sign-base >
-      <flattenmapper />
-      <fileset file="${test.jar}" />
-    </sign-base>
-  </target>
-  
-  <target name="testMapperFileset" depends="jar">
-    <sign-base destDir="${subdir}">
-      <fileset file="${test.jar}" />
-      <flattenmapper />
-    </sign-base>
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-
-  <target name="testMapperPath" depends="jar">
-    <sign-base destDir="${subdir}">
-      <path>
-        <pathelement location="${test.jar}" />
-      </path>
-      <flattenmapper />
-    </sign-base>
-    <assertSigned jar="${subdirtest.jar}"/>
-  </target>
-
-  <target name="testTwoMappers" depends="jar">
-    <sign-base destDir="${subdir}">
-      <fileset file="${test.jar}" />
-      <flattenmapper />
-      <flattenmapper />
-    </sign-base>
-  </target>
-
-  <target name="testNoAlias" depends="jar">
-    <signjar keystore="testkeystore"
-       jar="${test.jar}"
-       storepass="apacheant"/>
-  </target>
-
-  <target name="testNoFiles" >
-    <sign-base />
-  </target>
-
-  <target name="testNoStorePass" depends="jar">
-    <signjar keystore="testkeystore"
-       alias="testonly"
-       jar="${test.jar}"/>
-  </target>
-
   <target name="testTsaLocalhost" depends="jar">
     <sign tsaurl="http://localhost:0/" />
   </target>
-  
-  <target name="testSysProperty" depends="jar">
-    <sign>
-      <sysproperty key="ant.home" value="${ant.home}" />
-    </sign>
-    <assertSigned/>    
-  </target>
-  
-  <target name="testVerifyJar" depends="basic">
-    <verify-base jar="${test.jar}"/>
-  </target>
-
-  <target name="testVerifyJarCertificates" depends="basic">
-    <verify-base jar="${test.jar}" certificates="true" verbose="true"/>
-  </target>
-  
-  <target name="testVerifyJarUnsigned" depends="jar">
-    <verify-base jar="${test.jar}"/>
-  </target>
-  
-  <target name="testVerifyJarNotInKeystore" depends="basic">
-    <verifyjar jar="${test.jar}" certificates="true" verbose="true"/>
-  </target>
-    
-  <target name="testVerifyFileset" depends="basic">
-    <verify-base >
-      <fileset file="${test.jar}" />
-    </verify-base>
-  </target>
 
-  <target name="testVerifyPath" depends="basic">
-    <verify-base >
-      <path>
-        <pathelement location="${test.jar}" />
-      </path>
-    </verify-base>
-  </target>
-
-  <target name="testVerifyNoArgs">
-    <verify-base />
-  </target>
-  
 </project>
 

Copied: ant/core/trunk/src/tests/antunit/taskdefs/signjar-test.xml (from r1026315, ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml)
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/signjar-test.xml?p2=ant/core/trunk/src/tests/antunit/taskdefs/signjar-test.xml&p1=ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml&r1=1026315&r2=1026334&rev=1026334&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/signjar.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/signjar-test.xml Fri Oct 22 14:08:09 2010
@@ -15,96 +15,63 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project name="signjartest" default="help" basedir="..">
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
 
-  <property name="classes.dir" value="../../../build/classes"/>
-  <property name="sign.dir" location="signedjars" />
+  <import file="../antunit-base.xml" />
+
+  <property name="classes.dir" value="../../../../build/classes"/>
+  <property name="sign.dir" location="${output}" />
   <property name="subdir" location="${sign.dir}/subdir" />
   <property name="test.jar" location="${sign.dir}/signtest.jar" />
   <property name="subdirtest.jar" location="${subdir}/signtest.jar" />
-  
+  <property name="testkeystore" location="../../../etc/testcases/testkeystore"/>
   
   <macrodef name="assertSigned">
     <attribute name="jar" default="${test.jar}" />
     <sequential>
-      <fail message="not signed: @{jar}" >
-        <condition>
-          <not><issigned file="@{jar}" /></not>
-        </condition>
-      </fail>
+      <au:assertTrue message="not signed: @{jar}">
+        <issigned file="@{jar}"/>
+      </au:assertTrue>
     </sequential>
   </macrodef>
 
   <presetdef name="sign-base">
-    <signjar alias="testonly" keystore="testkeystore"
+    <signjar alias="testonly" keystore="${testkeystore}"
            storepass="apacheant"/>
   </presetdef>
 
   <presetdef name="verify-base">
-    <verifyjar keystore="testkeystore"
+    <verifyjar keystore="${testkeystore}"
            storepass="apacheant"/>
   </presetdef>
 
-
-  
   <presetdef name="sign">
     <sign-base jar="${test.jar}" />
   </presetdef>
 
-  <target name="init">
+  <target name="setUp">
     <mkdir dir="${sign.dir}" />
     <mkdir dir="${subdir}" />
   </target>
   
-  <target name="jar" depends="init">
+  <target name="jar" depends="setUp">
     <jar jarfile="${test.jar}" basedir="${classes.dir}" includes="**/Task.class"/>
   </target>  
 
-  
-  
-  <target name="clean">
-    <delete dir="${sign.dir}"/>
-  </target>
-
-  <target name="help">
-    <echo>This build is for use with Ant's test cases</echo>
-  </target>
-  
   <target name="basic" depends="jar">
     <sign />
-    <assertSigned/>             
   </target>
 
-  <target name="sigfile" depends="jar">
-    <sign sigfile="TEST"/>
+  <target name="testBasic" depends="basic">
     <assertSigned/>             
   </target>
 
-  <target name="invalidchars" depends="jar">
-    <sign alias="test@nly"/>
-    <assertSigned/>             
-  </target>
-
-  <target name="maxmemory" depends="jar">
+  <target name="testMaxmemory" depends="jar">
     <sign maxmemory="128m"/>
     <assertSigned/>             
   </target>
 
-  <target name="urlKeystoreFile" depends="jar">
-    <sign keystore="file://../testkeystore"
-       maxmemory="128m"/>
-    <assertSigned/>             
-  </target>
-
-  
-  <target name="urlKeystoreHTTP" depends="jar">
-    <sign
-      keystore="http://ant.apache.org/webtest/testkeystore"
-      />
-    <assertSigned/>             
-  </target>
-
-  <target name="preserveLastModified" depends="jar">
+  <target name="testPreserveLastModified" depends="jar">
     <touch file="${test.jar}" datetime="06/28/2000 2:02 pm"/>
     <sign 
     	preservelastmodified="true"/>
@@ -135,9 +102,11 @@
   </target>
   
   <target name="testFilesetAndSignedJar" depends="jar">
-    <sign-base signedjar="${sign.dir}/newfile.jar">
-      <fileset file="${test.jar}" />
-    </sign-base>
+    <au:expectfailure expectedMessage="You cannot specify the signed JAR when using paths
or filesets">
+      <sign-base signedjar="${sign.dir}/newfile.jar">
+        <fileset file="${test.jar}" />
+      </sign-base>
+    </au:expectfailure>
   </target>
   
   <target name="testPath" depends="jar">
@@ -159,11 +128,13 @@
   </target>
   
   <target name="testPathAndSignedJar" depends="jar">
-    <sign-base signedjar="${sign.dir}/newfile.jar">
-      <path>
-        <fileset file="${test.jar}" />
-      </path>
-    </sign-base>
+    <au:expectfailure expectedMessage="You cannot specify the signed JAR when using paths
or filesets">
+      <sign-base signedjar="${sign.dir}/newfile.jar">
+        <path>
+          <fileset file="${test.jar}" />
+        </path>
+      </sign-base>
+    </au:expectfailure>
   </target>
   
   <target name="testSignedJar" depends="jar">
@@ -172,7 +143,9 @@
   </target>
 
   <target name="testDestDirAndSignedJar" depends="jar">
-    <sign destDir="${subdir}" signedjar="${sign.dir}/newfile.jar"/>
+    <au:expectfailure expectedMessage="'destdir' and 'signedjar' cannot both be set">
+      <sign destDir="${subdir}" signedjar="${sign.dir}/newfile.jar"/>
+    </au:expectfailure>
   </target>
 
   <target name="testDestDir" depends="jar">
@@ -197,10 +170,12 @@
   </target>
   
   <target name="testMapperNoDest" depends="jar">
-    <sign-base >
-      <flattenmapper />
-      <fileset file="${test.jar}" />
-    </sign-base>
+    <au:expectfailure expectedMessage="The destDir attribute is required if a mapper is
set">
+      <sign-base >
+        <flattenmapper />
+        <fileset file="${test.jar}" />
+      </sign-base>
+    </au:expectfailure>
   </target>
   
   <target name="testMapperFileset" depends="jar">
@@ -222,33 +197,37 @@
   </target>
 
   <target name="testTwoMappers" depends="jar">
-    <sign-base destDir="${subdir}">
-      <fileset file="${test.jar}" />
-      <flattenmapper />
-      <flattenmapper />
-    </sign-base>
+    <au:expectfailure expectedMessage="Too many mappers">
+      <sign-base destDir="${subdir}">
+        <fileset file="${test.jar}" />
+        <flattenmapper />
+        <flattenmapper />
+      </sign-base>
+    </au:expectfailure>
   </target>
 
   <target name="testNoAlias" depends="jar">
-    <signjar keystore="testkeystore"
-       jar="${test.jar}"
-       storepass="apacheant"/>
+    <au:expectfailure expectedMessage="alias attribute must be set">
+      <signjar keystore="${testkeystore}"
+               jar="${test.jar}"
+               storepass="apacheant"/>
+    </au:expectfailure>
   </target>
 
   <target name="testNoFiles" >
-    <sign-base />
+    <au:expectfailure expectedMessage="jar must be set through jar attribute">
+      <sign-base />
+    </au:expectfailure>
   </target>
 
   <target name="testNoStorePass" depends="jar">
-    <signjar keystore="testkeystore"
-       alias="testonly"
-       jar="${test.jar}"/>
+    <au:expectfailure expectedMessage="storepass attribute must be set">
+      <signjar keystore="${testkeystore}"
+               alias="testonly"
+               jar="${test.jar}"/>
+    </au:expectfailure>
   </target>
 
-  <target name="testTsaLocalhost" depends="jar">
-    <sign tsaurl="http://localhost:0/" />
-  </target>
-  
   <target name="testSysProperty" depends="jar">
     <sign>
       <sysproperty key="ant.home" value="${ant.home}" />
@@ -265,11 +244,15 @@
   </target>
   
   <target name="testVerifyJarUnsigned" depends="jar">
-    <verify-base jar="${test.jar}"/>
+    <au:expectfailure expectedMessage="Failed to verify ${test.jar}">
+      <verify-base jar="${test.jar}"/>
+    </au:expectfailure>
   </target>
   
-  <target name="testVerifyJarNotInKeystore" depends="basic">
-    <verifyjar jar="${test.jar}" certificates="true" verbose="true"/>
+  <target name="NOtestVerifyJarNotInKeystore" depends="basic">
+    <au:expectfailure>
+      <verifyjar jar="${test.jar}" certificates="true" verbose="true"/>
+    </au:expectfailure>
   </target>
     
   <target name="testVerifyFileset" depends="basic">
@@ -287,7 +270,9 @@
   </target>
 
   <target name="testVerifyNoArgs">
-    <verify-base />
+    <au:expectfailure expectedMessage="jar must be set through jar attribute">
+      <verify-base />
+    </au:expectfailure>
   </target>
   
 </project>

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java?rev=1026334&r1=1026333&r2=1026334&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java Fri Oct
22 14:08:09 2010
@@ -51,10 +51,6 @@ public class SignJarTest extends BuildFi
     private boolean isOffline() {
         return Boolean.getBoolean("offline");
     }
-    public void testBasicSigning() {
-        executeTarget("basic");
-    }
-
     public void testSigFile() {
         executeTarget("sigfile");
         SignJarChild sj = new SignJarChild();
@@ -91,10 +87,6 @@ public class SignJarTest extends BuildFi
         }
     }
 
-    public void testMaxMemory() {
-        executeTarget("maxmemory");
-    }
-
     public void testURLKeystoreFile() {
         executeTarget("urlKeystoreFile");
     }
@@ -105,104 +97,6 @@ public class SignJarTest extends BuildFi
         }
     }
 
-    public void testPreserveLastModified() {
-        executeTarget("preserveLastModified");
-    }
-
-    public void testFileset() {
-        executeTarget("testFileset");
-    }
-
-    public void testFilesetAndJar() {
-        executeTarget("testFilesetAndJar");
-    }
-
-    public void testFilesetAndSignedJar() {
-        expectBuildExceptionContaining("testFilesetAndSignedJar",
-                "incompatible attributes",
-                SignJar.ERROR_SIGNEDJAR_AND_PATHS);
-    }
-
-    public void testPath() {
-        executeTarget("testPath");
-    }
-
-    public void testPathAndJar() {
-        executeTarget("testPathAndJar");
-    }
-
-    public void testPathAndSignedJar() {
-        expectBuildExceptionContaining("testPathAndSignedJar",
-                "incompatible attributes",
-                SignJar.ERROR_SIGNEDJAR_AND_PATHS);
-    }
-
-    public void testSignedJar() {
-        executeTarget("testSignedJar");
-    }
-
-    public void testDestDir() {
-        executeTarget("testDestDir");
-    }
-
-    public void testDestDirAndSignedJar() {
-        expectBuildExceptionContaining("testFilesetAndSignedJar",
-                "incompatible attributes",
-                SignJar.ERROR_SIGNEDJAR_AND_PATHS);
-    }
-
-    public void testDestDirAndSignedJar2() {
-        expectBuildExceptionContaining("testPathAndSignedJar",
-                "incompatible attributes",
-                SignJar.ERROR_SIGNEDJAR_AND_PATHS);
-    }
-
-    public void testDestDirFileset() {
-        executeTarget("testDestDirFileset");
-    }
-
-    public void testMapperFileset() {
-        executeTarget("testMapperFileset");
-    }
-
-    public void testDestDirPath() {
-        executeTarget("testDestDirPath");
-    }
-
-    public void testMapperPath() {
-        executeTarget("testMapperPath");
-    }
-
-    public void testMapperNoDest() {
-        expectBuildExceptionContaining("testMapperNoDest",
-                "two mappers",
-                SignJar.ERROR_MAPPER_WITHOUT_DEST);
-    }
-
-    public void testTwoMappers() {
-        expectBuildExceptionContaining("testTwoMappers",
-                "two mappers",
-                SignJar.ERROR_TOO_MANY_MAPPERS);
-    }
-
-    public void testNoAlias() {
-        expectBuildExceptionContaining("testNoAlias",
-                "no alias",
-                SignJar.ERROR_NO_ALIAS);
-    }
-
-    public void testNoFiles() {
-        expectBuildExceptionContaining("testNoFiles",
-                "no files",
-                SignJar.ERROR_NO_SOURCE);
-    }
-
-    public void testNoStorePass() {
-        expectBuildExceptionContaining("testNoStorePass",
-                "no password",
-                SignJar.ERROR_NO_STOREPASS);
-    }
-
     public void testTsaLocalhost() {
         //only test on java1.5+
         if(JavaEnvUtils.getJavaVersionNumber()>=15) {
@@ -212,38 +106,4 @@ public class SignJarTest extends BuildFi
         }
     }
 
-    public void testSysProperty() {
-        executeTarget("testSysProperty");
-    }
-
-    public void testVerifyJar() {
-        executeTarget("testVerifyJar");
-    }
-
-    public void testVerifyNoArgs() {
-        expectBuildExceptionContaining("testVerifyNoArgs",
-                "no args",
-                AbstractJarSignerTask.ERROR_NO_SOURCE);
-    }
-
-    public void testVerifyJarUnsigned() {
-        expectBuildExceptionContaining("testVerifyJarUnsigned",
-                "unsigned JAR file",
-                VerifyJar.ERROR_NO_VERIFY);
-    }
-
-    public void NotestVerifyJarNotInKeystore() {
-        expectBuildExceptionContaining("testVerifyJarNotInKeystore",
-                "signature not in keystore",
-                VerifyJar.ERROR_NO_VERIFY);
-    }
-
-    public void testVerifyFileset() {
-        executeTarget("testVerifyFileset");
-    }
-
-    public void testVerifyPath() {
-        executeTarget("testVerifyPath");
-    }
-
 }



Mime
View raw message