Browse Source

Add (disabled) tests for 10755

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273820 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
745031fad7
3 changed files with 103 additions and 14 deletions
  1. +49
    -7
      src/etc/testcases/taskdefs/jar.xml
  2. +1
    -1
      src/main/org/apache/tools/ant/XmlLogger.java
  3. +53
    -6
      src/testcases/org/apache/tools/ant/taskdefs/JarTest.java

+ 49
- 7
src/etc/testcases/taskdefs/jar.xml View File

@@ -2,6 +2,8 @@

<project name="jar-test" basedir="." default="test1">

<property name="tmp.jar" location="tmp.jar"/>

<target name="test1">
<jar/>
</target>
@@ -22,23 +24,63 @@

<target name="test4">
<jar
destfile="tmp.jar"
destfile="${tmp.jar}"
basedir="."
includes="jar.xml"
/>
</target>

<!-- This test is to make sure upToDate is working -->
<target name="test5">
<target name="testNoRecreateWithUpdate">
<jar
destfile="tmp.jar"
basedir="."
includes="jar.xml"
destfile="${tmp.jar}"
basedir="."
includes="jar.xml"
update="true"
/>
</target>

<target name="testRecreateNewerFileSetup" depends="test4">
<touch file="jar.xml"/>
<sleep seconds="2"/>
<touch file="${tmp.jar}"/>
</target>

<target name="testRecreateWithoutUpdateAdditionalFiles">
<jar
destfile="${tmp.jar}"
includes="*.xml"
basedir="."
/>
</target>

<target name="testRecreateWithUpdateAdditionalFiles">
<jar
destfile="${tmp.jar}"
basedir="."
includes="*.xml"
update="true"
/>
</target>

<target name="testRecreateWithoutUpdateNewerFile">
<jar
destfile="${tmp.jar}"
basedir="."
includes="jar.xml"
/>
</target>

<target name="testRecreateWithUpdateNewerFile">
<jar
destfile="${tmp.jar}"
basedir="."
includes="jar.xml"
update="true"
/>
</target>

<target name="cleanup">
<delete file="tmp.jar" />
<delete file="${tmp.jar}" />
</target>

</project>

+ 1
- 1
src/main/org/apache/tools/ant/XmlLogger.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without


+ 53
- 6
src/testcases/org/apache/tools/ant/taskdefs/JarTest.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,6 @@ import org.apache.tools.ant.BuildFileTest;
*/
public class JarTest extends BuildFileTest {

private static long jarModifiedDate;
private static String tempJar = "tmp.jar";

public JarTest(String name) {
@@ -94,12 +93,60 @@ public class JarTest extends BuildFileTest {
executeTarget("test4");
File jarFile = new File(getProjectDir(), tempJar);
assertTrue(jarFile.exists());
jarModifiedDate = jarFile.lastModified();
}

public void XXXtest5() {
executeTarget("test5");
public void testNoRecreateWithoutUpdate() {
testNoRecreate("test4");
}

public void testNoRecreateWithUpdate() {
testNoRecreate("testNoRecreateWithUpdate");
}

private void testNoRecreate(String secondTarget) {
executeTarget("test4");
File jarFile = new File(getProjectDir(), tempJar);
long jarModifiedDate = jarFile.lastModified();
try {
// give Windows a chance
Thread.currentThread().sleep(2500);
} catch (InterruptedException e) {
} // end of try-catch
executeTarget(secondTarget);
assertEquals("jar has not been recreated in " + secondTarget,
jarModifiedDate, jarFile.lastModified());
}

public void XtestRecreateWithoutUpdateAdditionalFiles() {
testRecreate("test4", "testRecreateWithoutUpdateAdditionalFiles");
}

public void XtestRecreateWithUpdateAdditionalFiles() {
testRecreate("test4", "testRecreateWithUpdateAdditionalFiles");
}

public void XtestRecreateWithoutUpdateNewerFile() {
testRecreate("testRecreateNewerFileSetup",
"testRecreateWithoutUpdateNewerFile");
}

public void XtestRecreateWithUpdateNewerFile() {
testRecreate("testRecreateNewerFileSetup",
"testRecreateWithUpdateNewerFile");
}

private void testRecreate(String firstTarget, String secondTarget) {
executeTarget(firstTarget);
try {
// give Windows a chance
Thread.currentThread().sleep(2500);
} catch (InterruptedException e) {
} // end of try-catch
File jarFile = new File(getProjectDir(), tempJar);
assertEquals(jarModifiedDate, jarFile.lastModified());
long jarModifiedDate = jarFile.lastModified();
executeTarget(secondTarget);
jarFile = new File(getProjectDir(), tempJar);
assertTrue("jar has been recreated in " + secondTarget,
jarModifiedDate < jarFile.lastModified());
}
}

Loading…
Cancel
Save