stevel 02/02/27 01:00:18
Modified: src/etc/testcases/taskdefs gzip.xml
src/testcases/org/apache/tools/ant/taskdefs GzipTest.java
src/main/org/apache/tools/ant/taskdefs Pack.java
Log:
time checking on gzip, with tests.
submitted by Jeff Martin <[EMAIL PROTECTED]>
Revision Changes Path
1.6 +5 -0 jakarta-ant/src/etc/testcases/taskdefs/gzip.xml
Index: gzip.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/gzip.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- gzip.xml 19 Nov 2001 15:53:14 -0000 1.5
+++ gzip.xml 27 Feb 2002 09:00:18 -0000 1.6
@@ -22,6 +22,11 @@
<gzip src="../asf-logo.gif" zipfile="asf-logo.gif.gz" />
</target>
+ <target name="testDateCheck">
+ <touch file="asf-logo.gif.gz"/>
+ <gzip src="../asf-logo.gif" zipfile="asf-logo.gif.gz" />
+ </target>
+
<target name="cleanup">
<delete file="asf-logo.gif.gz" />
</target>
1.7 +21 -0
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java
Index: GzipTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GzipTest.java 10 Jan 2002 10:13:12 -0000 1.6
+++ GzipTest.java 27 Feb 2002 09:00:18 -0000 1.7
@@ -86,4 +86,25 @@
expectBuildException("test4", "attribute zipfile invalid");
}
+ public void testGZip(){
+ executeTarget("realTest");
+ String log = getLog();
+ assertTrue("Expecting message starting with 'Building:' but got '"
+ + log + "'", log.startsWith("Building:"));
+ assertTrue("Expecting message ending with 'asf-logo.gif.gz' but got
'"
+ + log + "'", log.endsWith("asf-logo.gif.gz"));
+ }
+
+ public void testDateCheck(){
+ executeTarget("testDateCheck");
+ String log = getLog();
+ assertTrue(
+ "Expecting message ending with 'asf-logo.gif.gz is up to date.'
but got '" + log + "'",
+ log.endsWith("asf-logo.gif.gz is up to date."));
+ }
+
+ public void tearDown(){
+ executeTarget("cleanup");
+ }
+
}
1.3 +10 -4
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Pack.java
Index: Pack.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Pack.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Pack.java 10 Jan 2002 13:59:31 -0000 1.2
+++ Pack.java 27 Feb 2002 09:00:18 -0000 1.3
@@ -83,11 +83,11 @@
}
private void validate() {
- if (zipFile == null) {
+ if (zipFile == null || zipFile.getName().equals("")) {
throw new BuildException("zipfile attribute is required",
location);
}
- if (source == null) {
+ if (source == null || source.getName().equals("")) {
throw new BuildException("src attribute is required", location);
}
@@ -99,8 +99,14 @@
public void execute() throws BuildException {
validate();
- log("Building: " + zipFile.getAbsolutePath());
- pack();
+
+ if(zipFile.lastModified() < source.lastModified()){
+ log("Building: " + zipFile.getAbsolutePath());
+ pack();
+ }else{
+ log("Nothing to do: " + zipFile.getAbsolutePath() +
+ " is up to date.");
+ }
}
private void zipFile(InputStream in, OutputStream zOut)
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>