You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2013/11/23 00:11:10 UTC

svn commit: r1544710 - /ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java

Author: jlboudart
Date: Fri Nov 22 23:11:10 2013
New Revision: 1544710

URL: http://svn.apache.org/r1544710
Log:
Refactor some tests with TemporaryFolder rule

Modified:
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java?rev=1544710&r1=1544709&r2=1544710&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/EasyAntEngineTest.java Fri Nov 22 23:11:10 2013
@@ -48,13 +48,12 @@ import org.apache.tools.ant.BuildLogger;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.input.DefaultInputHandler;
 import org.apache.tools.ant.input.PropertyFileInputHandler;
-import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.util.ProxySetup;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class EasyAntEngineTest {
     private EasyAntConfiguration easyAntConfiguration = new EasyAntConfiguration();
@@ -64,30 +63,15 @@ public class EasyAntEngineTest {
 
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
+    @Rule
+    public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
     @Before
-    public void setUp() throws URISyntaxException {
-        createCache();
+    public void setUp() throws IOException {
+        File cache = temporaryFolder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
     @Test
     public void shouldAddBuildListener() {
         easyAntConfiguration.getListeners().add(MultiModuleLogger.class.getCanonicalName());
@@ -269,8 +253,7 @@ public class EasyAntEngineTest {
 
     @Test
     public void shouldReturnDefaultGlobalEasyAntIvySettingsLocationIfExists() throws IOException {
-        File f = new File(System.getProperty("java.io.tmpdir"), "easyant-ivysettings.xml");
-        f.deleteOnExit();
+        File f = temporaryFolder.newFile("easyant-ivysettings.xml");
         FileOutputStream fos = null;
         try {
             // write file