You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by gs...@apache.org on 2007/09/07 17:58:08 UTC

svn commit: r573647 - in /incubator/ivy/core/trunk/test/java/org/apache/ivy: ant/ core/resolve/ plugins/report/ plugins/resolver/ util/

Author: gscokart
Date: Fri Sep  7 10:58:07 2007
New Revision: 573647

URL: http://svn.apache.org/viewvc?rev=573647&view=rev
Log:
try to remove my cache cleaning issue (sorry to 'work by coincidence', I have really no idea what goes wrong, but I found the new code is a little bit cleaner, so I share it)

Added:
    incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java   (with props)
Modified:
    incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/report/XmlReportOutputterTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java?rev=573647&r1=573646&r2=573647&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java Fri Sep  7 10:58:07 2007
@@ -23,11 +23,11 @@
 
 import org.apache.ivy.TestHelper;
 import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.util.CacheCleaner;
 import org.apache.ivy.util.DefaultMessageImpl;
 import org.apache.ivy.util.Message;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 
 public class IvyPostResolveTaskTest extends TestCase {
     private File cache;
@@ -58,14 +58,7 @@
     }
 
     protected void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
+        CacheCleaner.deleteDir(cache);
     }
 
     public void testWithPreviousResolveInSameBuildAndLessConfs() throws Exception {

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRetrieveTest.java?rev=573647&r1=573646&r2=573647&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRetrieveTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRetrieveTest.java Fri Sep  7 10:58:07 2007
@@ -24,9 +24,9 @@
 
 import org.apache.ivy.TestHelper;
 import org.apache.ivy.core.IvyPatternHelper;
+import org.apache.ivy.util.CacheCleaner;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 
 public class IvyRetrieveTest extends TestCase {
     private static final String IVY_RETRIEVE_PATTERN = 
@@ -43,7 +43,7 @@
 
     protected void setUp() throws Exception {
         createCache();
-        cleanTestLib();
+        CacheCleaner.deleteDir(new File("build/test/lib"));
         project = new Project();
         project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
 
@@ -59,22 +59,8 @@
     }
 
     protected void tearDown() throws Exception {
-        cleanCache();
-        cleanTestLib();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    private void cleanTestLib() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(new File("build/test/lib"));
-        del.execute();
+        CacheCleaner.deleteDir(cache);
+        CacheCleaner.deleteDir(new File("build/test/lib"));
     }
 
     public void testSimple() throws Exception {

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=573647&r1=573646&r2=573647&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Fri Sep  7 10:58:07 2007
@@ -53,6 +53,7 @@
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.resolver.DualResolver;
 import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.util.CacheCleaner;
 import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
@@ -88,15 +89,9 @@
     }
 
     protected void tearDown() throws Exception {
-        cleanCache();
+        CacheCleaner.deleteDir(cache);
     }
 
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
 
     public void testResolveWithRetainingArtifactName() throws Exception {
         settings.setCacheArtifactPattern(ivy.substitute("[module]/[originalname].[ext]"));
@@ -2115,7 +2110,7 @@
         assertTrue(cacheManager.getIvyFileInCache(
             ModuleRevisionId.newInstance("org8", "mod8.1", "1.0")).exists());
 
-        cleanCache();
+        CacheCleaner.deleteDir(cache);
         createCache();
         report = ivy.resolve(new File("test/repositories/2/mod14.4/ivy-1.1.xml").toURL(),
             getResolveOptions(new String[] {"standalone"}));

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/report/XmlReportOutputterTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/report/XmlReportOutputterTest.java?rev=573647&r1=573646&r2=573647&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/report/XmlReportOutputterTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/report/XmlReportOutputterTest.java Fri Sep  7 10:58:07 2007
@@ -26,8 +26,7 @@
 import org.apache.ivy.core.cache.CacheManager;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
+import org.apache.ivy.util.CacheCleaner;
 
 public class XmlReportOutputterTest extends TestCase {
     private final Ivy _ivy;
@@ -53,10 +52,7 @@
     }
 
     private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(_cache);
-        del.execute();
+        CacheCleaner.deleteDir(_cache);
     }
 
     public void testWriteOrigin() throws Exception {

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java?rev=573647&r1=573646&r2=573647&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java Fri Sep  7 10:58:07 2007
@@ -46,6 +46,7 @@
 import org.apache.ivy.core.sort.SortEngine;
 import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
 import org.apache.ivy.plugins.latest.LatestTimeStrategy;
+import org.apache.ivy.util.CacheCleaner;
 import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
@@ -100,10 +101,7 @@
     }
 
     protected void tearDown() throws Exception {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
+        CacheCleaner.deleteDir(cache);
     }
 
     public void testFixedRevision() throws Exception {
@@ -154,7 +152,7 @@
     }
 
     private DownloadOptions getDownloadOptions(boolean useOrigin) {
-        return new DownloadOptions(settings, cacheManager, null, useOrigin);
+        return new DownloadOptions(cacheManager, null, useOrigin);
     }
 
     public void testMaven2() throws Exception {

Added: incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java?rev=573647&view=auto
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java (added)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java Fri Sep  7 10:58:07 2007
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.util;
+
+import java.io.File;
+
+public class CacheCleaner {
+
+    /** Delete the directory and all it contains.
+     * Previously, we used the ant delete task, but it occasionaly failed (access denied)
+     * on my machine for unknown reason.  The next code seems to work better (but I don't
+     * see the difference with ant task... 
+     **/
+    public static void deleteDir(File toDelete) {
+        if (toDelete.isFile()) {
+            System.out.println("delete file : " + toDelete);
+            toDelete.delete();
+        } else if (toDelete.isDirectory()) {
+            File[] childs = toDelete.listFiles();
+            for (int i = 0; i < childs.length; i++) {
+                deleteDir(childs[i]);
+            }
+            System.out.println("delete dir :" + toDelete);
+            toDelete.delete();
+        }
+        if (toDelete.exists()) {
+            System.out.println("!!! I just deleted '" + toDelete+"', and it is still there !!!");
+        }
+    }
+
+}

Propchange: incubator/ivy/core/trunk/test/java/org/apache/ivy/util/CacheCleaner.java
------------------------------------------------------------------------------
    svn:eol-style = native