From 745031fad77dc006d12f34731b46f0e755343ea5 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 17 Jan 2003 10:35:10 +0000 Subject: [PATCH] Add (disabled) tests for 10755 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273820 13f79535-47bb-0310-9956-ffa450edef68 --- src/etc/testcases/taskdefs/jar.xml | 56 +++++++++++++++--- src/main/org/apache/tools/ant/XmlLogger.java | 2 +- .../apache/tools/ant/taskdefs/JarTest.java | 59 +++++++++++++++++-- 3 files changed, 103 insertions(+), 14 deletions(-) diff --git a/src/etc/testcases/taskdefs/jar.xml b/src/etc/testcases/taskdefs/jar.xml index 3bbfdf766..999dc92fd 100644 --- a/src/etc/testcases/taskdefs/jar.xml +++ b/src/etc/testcases/taskdefs/jar.xml @@ -2,6 +2,8 @@ + + @@ -22,23 +24,63 @@ - - + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java index d883bc631..cdee1d4c9 100644 --- a/src/main/org/apache/tools/ant/XmlLogger.java +++ b/src/main/org/apache/tools/ant/XmlLogger.java @@ -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 diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java index b589c425c..bdebfda63 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java @@ -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()); } }